forked from KFERMercer/chaturbate-grabber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctbcap
executable file
·587 lines (529 loc) · 17.3 KB
/
ctbcap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
#!/usr/bin/env sh
#
# Copyright (C) 2019-2025 KFERMercer <https://github.com/KFERMercer>
#
# A simple webcam capturer for CB & SC.
#
CTBCAP_VERSION=3.0
CTBCAP_RELEASE=4
# Command Options > Environment Variables > Default Arguments
defaulting_args() {
# Recorded files saving path
[ -n "${SAVE_PATH}" ] || SAVE_PATH="${PWD}/rec"
# Log files saving path
[ -n "${LOG_PATH}" ] || LOG_PATH="${SAVE_PATH}/log"
# Streamer's Username or Room URL.
[ -n "${MODEL}" ] || MODEL=
# Platform that streaming at. Choose "chaturbate" or "stripchat".
[ -n "${PLATFORM}" ] || PLATFORM="chaturbate"
# Used as number of seconds to cut the recording file in real time.
# Don't cut if set to 0.
[ -n "${CUT_TIME}" ] || CUT_TIME=3600
# https://jnrbsn.github.io/user-agents/user-agents.json
[ -n "${UA}" ] || UA='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
# Edging Mode.
# Delay initial requests to servers to avoid time-specific request waves caused by large-scale deployments.
# Inactive if not 1.
[ "${EDGING_MODE}" = "1" ] || EDGING_MODE=
# Debug Mode. Inactive if not 1.
[ "${DEBUG_MODE}" = "1" ] || DEBUG_MODE=
# Link Mode. Only grab stream link. Inactive if not 1.
[ "${LINK_MODE}" = "1" ] || LINK_MODE=
}
doc() {
case "$1" in
neon)
# Multi-line message should not be larger than 55 columns per line:
# ↓ 55 columns ↓
echo "8=====================================================D"
echo " ┌─┐┬ ┬┌─┐┌┬┐┬ ┬┬─┐┌┐ ┌─┐┌┬┐┌─┐ ┌─┐┬─┐┌─┐┌┐ ┌┐ ┌─┐┬─┐"
echo " │ ├─┤├─┤ │ │ │├┬┘├┴┐├─┤ │ ├┤───│ ┬├┬┘├─┤├┴┐├┴┐├┤ ├┬┘"
echo " └─┘┴ ┴┴ ┴ ┴ └─┘┴└─└─┘┴ ┴ ┴ └─┘ └─┘┴└─┴ ┴└─┘└─┘└─┘┴└─"
echo " v${CTBCAP_VERSION}-r${CTBCAP_RELEASE}"
echo "8=====================================================D"
echo " Simping Stream from CB & SC"
;;
help)
echo "Usage: ctbcap [options...] <username|url>"
echo
echo "<username|url> Streamer's Username or Chat"
echo " Room URL."
echo
echo "-c <int number> Will be use as number of"
echo " <seconds> to [c]ut recording"
echo " file at real time. Don't cut"
echo " if set to 0."
echo " Default: 3600 (60 min)."
echo
echo "-d [D]ebug Mode."
echo " Show the raw crawler data."
echo
echo "-e [E]dging Mode."
echo " Delay initial requests to"
echo " servers by Random Time in 10"
echo " min to avoid time-specific"
echo " request waves caused by"
echo " large-scale deployments."
echo
echo "-f </path/to/recdir> Recording [f]iles will save"
echo " to this path."
echo " Default: /\${PWD}/rec/"
echo " NO Change if Runs in Docker."
echo
echo "-h Get [H]elp for Commands."
echo
echo "-l [L]ink Mode. Capture Stream"
echo " Link but don't recording it."
echo
echo "-o </path/to/logdir> L[o]gging files will save to"
echo " this path."
echo " Default: <recdir>/log/"
echo " NO Change if Runs in Docker."
echo
echo "-p <chaturbate|stripchat> Specify Stream [P]latform"
echo " to <chaturbate> (default) or"
echo " <stripchat>. also support"
echo " <ctb|cb> or <stc|sc|st>."
echo " Change if online detection"
echo " goes wrong."
echo
echo "-v Show version info and quit."
echo
echo
echo "Chaturbate-Grabber (aka CtbCap) is made by KFERMercer"
echo "with Sweat and Cum. Please use Her under GPLv3, and"
echo "kindly ask you that don't use for any commercial "
echo "operations. If you like this toy, please visit the"
echo "official REPO to Star/Fork, Issue/PR are also open."
echo "<https://github.com/KFERMercer/chaturbate-grabber>"
;;
ver)
echo "Chaturbate-Grabber (aka CtbCap) v${CTBCAP_VERSION}-r${CTBCAP_RELEASE}."
echo
echo "System Time: $(date "+%Y%m%d-%H%M%S")"
echo
echo "We defend the ideals of Communism and Anarky, Believe"
echo "the transmission of knowledge and information cannot"
echo "receive any perceived impediment."
echo
echo "Copyright (C) 2019-2025 KFERMercer <https://github.com/KFERMercer>"
echo
echo "UA: ${UA}"
;;
esac
}
# Produce Runtime Variables.
genesis_juicer() {
[ -z "$1" ] && [ -z "${MODEL}" ] && {
echo "(NOTICE) No Option Specified! Show Help Message..."
echo
doc help
return 2
}
while getopts ':c:def:hlo:p:v' OPT; do
case ${OPT} in
c)
[ "$(echo "${OPTARG}" | cut -c1)" = "-" ] && {
echo "(ERROR) No Cut Time Specified!" >&2
echo >&2
echo "See [ $0 -h ] for help." >&2
return 1
}
CUT_TIME=${OPTARG}
;;
d) DEBUG_MODE=1 ;;
e) EDGING_MODE=1 ;;
f)
[ "$(echo "${OPTARG}" | cut -c1)" = "-" ] && {
echo "(ERROR) No Recording Saving Path Specified!" >&2
echo >&2
echo "See [ $0 -h ] for help." >&2
return 1
}
SAVE_PATH=${OPTARG}
;;
h) doc help && return 2 ;;
l) LINK_MODE=1 ;;
o)
[ "$(echo "${OPTARG}" | cut -c1)" = "-" ] && {
echo "(ERROR) No Log Saving Path Specified!" >&2
echo >&2
echo "See [ $0 -h ] for help." >&2
return 1
}
LOG_PATH=${OPTARG}
;;
p)
[ "$(echo "${OPTARG}" | cut -c1)" = "-" ] && {
echo "(ERROR) No Cut Time Specified!" >&2
echo >&2
echo "See [ $0 -h ] for help." >&2
return 1
}
PLATFORM=${OPTARG}
;;
v)
defaulting_args
doc ver
return 2
;;
\?)
echo "(ERROR) Invalid Option [${OPTARG}] !" >&2
echo >&2
echo "See [ $0 -h ] for help."
return 1
;;
:)
case "${OPTARG}" in
c) echo "(ERROR) No Cut Time Specified!" >&2 ;;
f) echo "(ERROR) No Recording Saving Path Specified!" >&2 ;;
o) echo "(ERROR) No Log Saving Path Specified!" >&2 ;;
p) echo "(ERROR) No Platform Specified!" >&2 ;;
esac
echo >&2
echo "See [ $0 -h ] for help." >&2
return 1
;;
esac
done
shift $((OPTIND - 1))
[ -n "$1" ] && MODEL=$1
defaulting_args
[ -z "${MODEL}" ] && {
echo "(ERROR) No Username or URL Specified!" >&2
echo >&2
echo "See [ $0 -h ] for help." >&2
return 1
}
# Assume ${MODEL} contain some URL form, process & cut invalid chars.
local _MODEL="$(echo "${MODEL}" \
| tr '[:upper:]' '[:lower:]' \
| grep -oE 'http[s]?://[a-z0-9-]?+[.]?[a-z0-9-]+[.][a-z]+[/][^ /]+' \
| cut -d '/' -f4 \
| grep -oE '[a-z0-9_-]+' \
| head -n 1)"
[ -n "${_MODEL}" ] && MODEL="${_MODEL}"
# If ${MODEL} not URL form, cut invalid chars.
[ -z "${_MODEL}" ] && local _MODEL="$(echo "${MODEL}" | tr '[:upper:]' '[:lower:]'| grep -oE '[a-z0-9_-]+' | head -n 1)"
[ -z "${_MODEL}" ] && {
echo "(ERROR) Invalid Username or URL! [${MODEL}]" >&2
echo >&2
echo "See [ $0 -h ] for help." >&2
return 1
}
[ -n "${_MODEL}" ] && MODEL="${_MODEL}"
PLATFORM=$(echo "${PLATFORM}" | tr '[:upper:]' '[:lower:]')
case ${PLATFORM} in
chaturbate|ctb|cb)
PLATFORM=chaturbate
LINK="https://chaturbate.com/api/chatvideocontext/${MODEL}/" # Must keep " / " at the end
;;
stripchat|stc|sc|st)
PLATFORM=stripchat
LINK="https://stripchat.com/api/front/v2/models/username/${MODEL}/cam"
;;
*)
echo "(ERROR) Unknown Platform: [${PLATFORM}] !" >&2
echo >&2
echo "See [ $0 -h ] for help." >&2
return 1
;;
esac
CUT_TIME=$(echo "${CUT_TIME}" | cut -c -9) #Cut to INT range
[ -z "$(echo "${CUT_TIME}" | grep -oE '^[0-9]+$')" ] && {
echo "(ERROR) Cut Time Must be Some INT Number! [${CUT_TIME}]" >&2
echo >&2
echo "See [ $0 -h ] for help." >&2
return 1
}
SAVE_PATH="$(realpath -m "${SAVE_PATH}" 2>/dev/null)"
LOG_PATH="$(realpath -m "${LOG_PATH}" 2>/dev/null)"
return 0
}
# Power Tools
utils() {
case $1 in
connect_status)
curl "$2" \
-4 -L -s -I \
-A "${UA}" \
--compressed \
--connect-timeout 5 --retry 5 --retry-delay 2 \
2>/dev/null | head -n 1 | grep -oE '[0-9]{3}' \
|| echo 000
;;
connect_dump)
curl "$2" \
-4 -L -s -i\
-A "${UA}" \
--compressed \
--connect-timeout 5 --retry 5 --retry-delay 2 \
2>/dev/null | tr -d '\r'
;;
# Reuse results of connect_dump to get HTTP status code at the time.
dump2status)
echo "$2" \
| head -n 1 \
| cut -c -15 \
| grep -oE '[0-9]{3}' || echo 000
;;
# RE-Implement RANDOM NUM Tool on POSIX Shell (B/E).
random_num)
# Usage: `utils random_num <SNUM> <BNUM>`
local SNUM=$2 # INT. Must >= 0. Small-end of Random Num you want.
local BNUM=$3 # INT. Must < (2^32)/2. Big-end of Random Num you want.
local BNUM=$(( BNUM + 1 )) # Add ${BNUM} to the pool, make method become B/E Random.
local RSEED=$(od -An -N4 -tu4 /dev/urandom) # Gen random num B/E 0 - (2^32-1) as Seed.
local SEEDMIN=$(( 4294967295 % ( BNUM - SNUM ) )) # ${SEED} <= ${SEEDMIN} will cause redundant modulus.
while [ "${RSEED}" -le "${SEEDMIN}" ]; do
local RSEED=$(od -An -N4 -tu4 /dev/urandom) # If ${SEED} <= ${SEEDMIN}, Reshake ${RSEED} till isn't.
done
echo $(( RSEED % ( BNUM - SNUM ) + SNUM )) # Format Same as $((RANDOM)) in Bash.
;;
check_depend)
command -v "$2" 1>/dev/null 2>&1 || {
echo "(ERROR) Command [$2] not found! Check \$PATH or install it." >&2
return 1
}
return 0
;;
esac
}
init_dir() {
printf '%s\n' "$@" | while IFS='' read -r DIR ; do
[ -z "${DIR%"/"}" ] && echo "(ERROR) Root directory are not allowed!" >&2 && return 1
mkdir -p "${DIR}" 1>/dev/null 2>&1
[ ! -e "${DIR}" ] && echo "(ERROR) Unable to create directory [${DIR}] !" >&2 && return 1
[ ! -d "${DIR}" ] && echo "(ERROR) [${DIR}] is not a directory!" >&2 && return 1
[ ! -w "${DIR}" ] && echo "(ERROR) Cannot Write To [${DIR}/] !" >&2 && return 1
true
done
return $?
}
# Sleep time (s) before initial request to server. Range better EQ to watchdog().while.case.1).echo .
edging() {
local EDGING_TIME=$(utils random_num 0 600)
echo "Edging Mode is On."
echo
echo "Delay [${EDGING_TIME}]s before Simping [${MODEL}]".
echo
echo "Considering we won't send any requests to [${PLATFORM}]"
echo "server until Edging is over, So please make sure that"
echo "[${MODEL}] exists on [${PLATFORM}]. "
echo
echo "Edging..."
echo
sleep ${EDGING_TIME}
echo "Edging Enough...Cum..."
}
# Core platform methods.
# Fetch ${STREAM_LINK_GENERIC} & ${STREAM_LINK}, show them & return 0.
# If no ${STREAM_LINK}, return 1.
# If chatroom is changed to new name, return 2.
# If can't find chatroom at all, return 3.
fetch_m3u() {
rm -f "${LOG_PATH}/${MODEL}-${PLATFORM}.online"
unset STREAM_LINK_GENERIC STREAM_LINK
[ -n "${LINK_NEW_NAME}" ] && local CONNECT_DUMP="$(utils connect_dump "${LINK_NEW_NAME}")"
[ -z "${LINK_NEW_NAME}" ] && local CONNECT_DUMP="$(utils connect_dump "${LINK}")"
local CONNECT_STATUS="$(utils dump2status "${CONNECT_DUMP}")"
case ${CONNECT_STATUS} in
2*|3*)
# Do nothing. leave to platform method to deal with.
;;
401)
echo "[$(date "+%Y%m%d-%H%M%S")] Room [${MODEL}] might require password. [${CONNECT_STATUS}]" >&2
return 1
;;
404)
# Do nothing. leave to platform method to deal with.
;;
4*)
echo "[$(date "+%Y%m%d-%H%M%S")] You might gotten blocked by CAPTCHA. [${CONNECT_STATUS}]" >&2
return 1
;;
000)
echo "[$(date "+%Y%m%d-%H%M%S")] Internet Connection Error. [${CONNECT_STATUS}]" >&2
return 1
;;
1*|5*|*)
echo "[$(date "+%Y%m%d-%H%M%S")] ${PLATFORM} Server on failure now. [${CONNECT_STATUS}]" >&2
return 1
;;
esac
# Core methods by each Platform:
case ${PLATFORM} in
chaturbate)
# Check if Model change to new name
[ "${CONNECT_STATUS}" = 404 ] && {
local CONNECT_DUMP=$(utils connect_dump "https://chaturbate.com/${MODEL}/")
local CONNECT_STATUS="$(utils dump2status "${CONNECT_DUMP}")"
MODEL_NEW_NAME=$(echo "${CONNECT_DUMP}" | grep -oE 'location:[ ]?/[^/]+/' | head -n 1 | cut -d '/' -f2)
[ -n "${MODEL_NEW_NAME}" ] && {
LINK_NEW_NAME=$(echo "${LINK}" | sed "s|${MODEL}|${MODEL_NEW_NAME}|g")
echo "[$(date "+%Y%m%d-%H%M%S")] (WARNING) [${MODEL}] has changed her name to [${MODEL_NEW_NAME}]. [${CONNECT_STATUS}]" >&2
return 2
}
[ -z "${MODEL_NEW_NAME}" ] && {
echo "(ERROR) Can't find [${MODEL}] on [${PLATFORM}]. [${CONNECT_STATUS}]" >&2
return 3
}
}
[ -n "${MODEL_NEW_NAME}" ] \
&& echo "[$(date "+%Y%m%d-%H%M%S")] (NOTICE) Due to name change, [${MODEL_NEW_NAME}] will now be used for actual requests." >&2
# Check if online:
local ROOM_STATUS="$(echo "${CONNECT_DUMP}" | grep -oE '"room_status":[ ]?"[^"]+"' | cut -d '"' -f4)"
if [ -n "$(echo "${CONNECT_DUMP}" | grep -oE 'http[s]?://edge[^ ]+\.m3u8')" ]; then
STREAM_LINK_GENERIC=$(echo "${CONNECT_DUMP}" | grep -oE 'http[s]?://edge[^ ]+\.m3u8' | head -n 1)
STREAM_LINK=$(utils connect_dump "${STREAM_LINK_GENERIC}" | tail -n 1)
[ -n "${STREAM_LINK}" ] && STREAM_LINK=$(echo "${STREAM_LINK_GENERIC}" | sed 's|playlist.m3u8.*||')${STREAM_LINK}
else
echo "[$(date "+%Y%m%d-%H%M%S")] [${MODEL}] is ${ROOM_STATUS} now. [${CONNECT_STATUS}]"
return 1
fi
;;
stripchat)
[ "${CONNECT_STATUS}" = 404 ] && {
# TODO: Name changing detection for Stripchat method.
echo "(ERROR) Can't find [${MODEL}] on [${PLATFORM}]. [${CONNECT_STATUS}]" >&2
return 3
}
if [ -n "$(echo "${CONNECT_DUMP}" | grep -o '"isCamAvailable":true')" ]; then
local STREAMNAME="$(echo "${CONNECT_DUMP}" | grep '"streamName":' | head -n 1 | sed 's|.*"streamName":"||'| sed 's|".*||')"
STREAM_LINK_GENERIC="https://edge-hls.doppiocdn.com/hls/${STREAMNAME}/master/${STREAMNAME}_auto.m3u8"
STREAM_LINK=$(utils connect_dump "${STREAM_LINK_GENERIC}" | grep -oE 'http[s]?://[^ ]+\.m3u8' | head -n 1)
else
echo "[$(date "+%Y%m%d-%H%M%S")] [${MODEL}] is offline/private now. [${CONNECT_STATUS}]"
return 1
fi
;;
esac
# If successfully grabed ${STREAM_LINK_GENERIC} ${STREAM_LINK}, show them.
if [ -n "${STREAM_LINK}" ]; then
echo "[$(date "+%Y%m%d-%H%M%S")] [${MODEL}] is online now! [$([ -n "${ROOM_STATUS}" ] && echo "${ROOM_STATUS}" || echo online)]"
echo "[$(date "+%Y%m%d-%H%M%S")] Successfully Captured Stream Link:"
echo "[$(date "+%Y%m%d-%H%M%S")] ${STREAM_LINK_GENERIC}"
echo "[$(date "+%Y%m%d-%H%M%S")] Highest Definition Stream Link:"
echo "[$(date "+%Y%m%d-%H%M%S")] ${STREAM_LINK}"
return 0
else
echo "[$(date "+%Y%m%d-%H%M%S")] Failed to fetch stream link! [$(utils connect_status "${STREAM_LINK_GENERIC}")]"
return 1
fi
return 0
}
grab_stream() {
local FFMPEG_LOGFILE="${LOG_PATH}/${MODEL}-${PLATFORM}.ffmpeg.log"
local CAPTURE_TIME=$(date "+%Y%m%d-%H%M%S")
{
echo
echo "========== [${CAPTURE_TIME}] =========="
echo
} >> ${FFMPEG_LOGFILE}
# Core FFmpeg method.
# After making any changes, must confirm the compatibility of tailored FFmpeg in Dockerfile.
ffmpeg \
-user_agent "${UA}" \
-i "${STREAM_LINK}" \
-c copy \
$( [ -z "${DEBUG_MODE}" ] && \
printf "%s" "-loglevel warning" \
) \
$( [ "${CUT_TIME}" = 0 ] \
&& printf "%s" "
${SAVE_PATH}/${MODEL}-${CAPTURE_TIME}.mkv" \
|| printf "%s" "
-f segment \
-segment_time ${CUT_TIME} \
-segment_start_number 1 \
-reset_timestamps 1 \
${SAVE_PATH}/${MODEL}-${CAPTURE_TIME}_%03d.mkv" \
) \
>> ${FFMPEG_LOGFILE} 2>&1
}
watchdog() {
while true; do
fetch_m3u
# See the notes above fetch_m3u() .
case $? in
0)
echo "[$(date "+%Y%m%d-%H%M%S")] Now start recording..."
echo "${STREAM_LINK}" > "${LOG_PATH}/${MODEL}-${PLATFORM}.online" # Build online flag file
grab_stream
# If recording interrupt by first time
while true; do
echo "[$(date "+%Y%m%d-%H%M%S")] Recording Interrupted..."
local STREAM_TEMP_STATUS="$(utils connect_status "${STREAM_LINK}")"
case ${STREAM_TEMP_STATUS} in
2*|3*)
# Reconnect.
echo "[$(date "+%Y%m%d-%H%M%S")] Restart recording... [${STREAM_TEMP_STATUS}]"
grab_stream
;;
*)
echo "[$(date "+%Y%m%d-%H%M%S")] Stream Link closed... [${STREAM_TEMP_STATUS}]"
break
;;
esac
done
rm -f "${LOG_PATH}/${MODEL}-${PLATFORM}.online" # Delete online flag file
# Too short time may cause the platform to enable CAPTCHA to you.
echo "[$(date "+%Y%m%d-%H%M%S")] Sleep for around 5 min & try reconnect..."
sleep $(utils random_num 240 360) # Random num B/E 240 - 360
;;
1)
# Too short time may cause the platform to enable CAPTCHA to you.
echo "[$(date "+%Y%m%d-%H%M%S")] Sleep for around 10 min..."
sleep $(utils random_num 480 720)
;;
2) sleep $(utils random_num 4 6) ;;
3)
# Too short time may cause the platform to enable CAPTCHA to you.
echo "[$(date "+%Y%m%d-%H%M%S")] Sleep for around 1 hr..."
sleep $(utils random_num 3300 3900)
;;
*)
echo "Logic is dead. It's tinfoil hat time."
;;
esac
done
}
{ # Execution Entry
trap '{
rm -f "${LOG_PATH}/${MODEL}-${PLATFORM}.online"
echo
echo "BYE (. Y .) BYE"
echo
exit 0
}' HUP INT QUIT TERM
echo
doc neon
echo
genesis_juicer "$@"
case $? in
0)
echo "Simping Streamer: [${MODEL}] (${PLATFORM})"
;;
2) echo; exit 0 ;;
*) echo >&2; exit 1 ;;
esac
echo
[ "${DEBUG_MODE}" = "1" ] && set -x # Debug Mode
utils check_depend curl || { echo >&2; exit 1; }
[ "${LINK_MODE}" = "1" ] && {
fetch_m3u
case $? in
2)
sleep $(utils random_num 4 6)
fetch_m3u && { echo; exit 0; } || { echo >&2; exit 1; }
;;
0) echo; exit 0 ;;
*) echo >&2; exit 1 ;;
esac
}
utils check_depend ffmpeg || { echo >&2; exit 1; }
init_dir "${SAVE_PATH}" "${LOG_PATH}" || { echo >&2; exit 1; }
[ "${EDGING_MODE}" = "1" ] && { edging; echo; }
watchdog 2>&1 | tee -a "${LOG_PATH}/${MODEL}-${PLATFORM}.log" 2>/dev/null
}
exit 0