-
Notifications
You must be signed in to change notification settings - Fork 0
/
tar_cli_multi.py
57 lines (45 loc) · 1.62 KB
/
tar_cli_multi.py
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
from function import (function, twitch_api, recorder)
from datetime import datetime
import time
import sys
import os
import threading
function.console_print("Program started")
def stream_download_solo(user_login):
repeat_check = True
if not os.path.exists("{}".format(user_login)):
os.makedirs("{}".format(user_login))
while True:
stream_data = {}
while stream_data == {}:
if repeat_check:
function.console_print("[{user_login}] Waiting to start streaming".format(user_login=user_login))
repeat_check = False
try:
token, sig = recorder.get_stream_access_token(user_login)
stream_data = recorder.get_stream_m3u8_direct(user_login, sig, token)
except:
continue
time.sleep(1)
if stream_data != {}:
function.console_print("[{user_login}] Stream started".format(user_login=user_login))
try:
recorder.download_stream_direct(user_login, 'ts')
except Exception as e:
# print("Error: {}".format(e))
continue
function.console_print("[{user_login}] Stream ended".format(user_login=user_login))
repeat_check = True
try:
user_login_list = sys.argv[1:]
except:
print("streamer nickname is not exist")
exit()
if len(user_login_list) == 0:
print("streamer nickname is not exist")
exit()
for user_login in user_login_list:
thread = threading.Thread(target=stream_download_solo, args=(user_login,))
thread.start()
while True:
time.sleep(60)