Skip to content

Commit 9482a74

Browse files
committed
ctbcap: fetch_m3u: add stream url not accessible case
1 parent d3e6c40 commit 9482a74

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

ctbcap

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ edging() {
409409
# If no ${STREAM_URL}, return 1.
410410
# If chatroom is changed to new name, return 2.
411411
# If can't find chatroom at all, return 3.
412+
# If ${STREAM_URL} is not accessible, return 4.
412413
fetch_m3u() {
413414
[ -n "${MODEL_NEW_NAME}" ] && {
414415
echo "[$(date "+%Y%m%d-%H%M%S")] (NOTICE) Due to name change, [${MODEL_NEW_NAME}] will now be used for actual requests."
@@ -431,14 +432,13 @@ fetch_m3u() {
431432
[ "$(utils connect_status "${STREAM_URL}")" -ge 400 ] && {
432433
STREAM_URL=$(echo "${STREAM_URL}" | sed 's|playlist.m3u8|playlist_sfm4s.m3u8|g' | sed 's|live-hls|live-c-fhls|g')
433434
[ "$(utils connect_status "${STREAM_URL}")" -ge 400 ] && {
434-
unset STREAM_URL
435435
echo "[$(date "+%Y%m%d-%H%M%S")] (ERROR) [${MODEL}] is Online now, but looks like the backend of [${PLATFORM}] has been changed." >&2
436-
return 1
436+
unset STREAM_URL && return 4
437437
}
438438
}
439439
true
440440
} || {
441-
echo "[$(date "+%Y%m%d-%H%M%S")] [${MODEL}] is ${ROOM_STATUS} now. [${CONNECT_STATUS}]"
441+
echo "[$(date "+%Y%m%d-%H%M%S")] [${MODEL}] is [${ROOM_STATUS}] now. [${CONNECT_STATUS}]"
442442
return 1
443443
}
444444
unset CONNECT_STATUS
@@ -469,6 +469,11 @@ fetch_m3u() {
469469
[ -n "$(echo "${CONNECT_DUMP}" | grep -o '"isCamAvailable":true' | head -n 1)" ] && {
470470
local STREAMNAME="$(echo "${CONNECT_DUMP}" | grep '"streamName":' | head -n 1 | sed 's|.*"streamName":"||'| sed 's|".*||')"
471471
STREAM_URL="https://edge-hls.doppiocdn.com/hls/${STREAMNAME}/master/${STREAMNAME}_auto.m3u8"
472+
local STREAM_URL_STATUS="$(utils connect_status "${STREAM_URL}")"
473+
[ "${STREAM_URL_STATUS}" -ge 400 ] && {
474+
echo "[$(date "+%Y%m%d-%H%M%S")] (ERROR) [${MODEL}] is Online, but can't access the stream now. [${STREAM_URL_STATUS}]" >&2
475+
unset STREAM_URL && return 4
476+
}
472477
true
473478
} || {
474479
echo "[$(date "+%Y%m%d-%H%M%S")] [${MODEL}] is offline/private now. [${CONNECT_STATUS}]"
@@ -636,6 +641,11 @@ watchdog() {
636641
sleep "$(utils random_num 3300 3900)"
637642
continue
638643
;;
644+
4)
645+
echo "[$(date "+%Y%m%d-%H%M%S")] Sleep for around 3 min..."
646+
sleep "$(utils random_num 150 210)"
647+
continue
648+
;;
639649
*)
640650
echo "[$(date "+%Y%m%d-%H%M%S")] Logic is dead. Time to Tin Foil Hat."
641651
sleep "$(utils random_num 32400 39600)"

0 commit comments

Comments
 (0)