added check for rerun (lifeChk.py)

This commit is contained in:
l0sted 2019-11-10 17:42:39 +03:00
parent 53cbd997d0
commit c49ba072c1
4 changed files with 11 additions and 5 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.pythonPath": "/bin/python"
}

12
lifeChk.py Executable file → Normal file
View File

@ -4,16 +4,18 @@
#################
import sys
#if not sys.argv[1]:
# sys.exit(2)
# sys.exit(2)
twitchid = "59hrsplx7dmvc17pqkqcm9l3n1uzc4"
from twitch import TwitchClient
twitchid = "59hrsplx7dmvc17pqkqcm9l3n1uzc4"
client = TwitchClient(client_id=twitchid) #client init
user_id=client.users.translate_usernames_to_ids(sys.argv[1])[0].id #get id
#get live by id (if var not empty)
if client.streams.get_stream_by_user(user_id):
sys.exit(0)
else:
sys.exit(1)
print(user_id)
print(client.streams.get_stream_by_user(user_id).stream_type)
if client.streams.get_stream_by_user(user_id).stream_type == 'live':
sys.exit(0)
sys.exit(1)

1
main.py Normal file
View File

@ -0,0 +1 @@
#!/bin/python3

View File