twitch-autosave/lifeChk.py

23 lines
656 B
Python
Raw Normal View History

2019-11-09 01:29:29 +03:00
#!/usr/bin/python3
#################
2020-02-22 12:28:28 +03:00
# return 0 if streamer is live (continue execution while in bash), 1 if not
2019-11-09 01:29:29 +03:00
#################
import sys
import config_python
2019-11-09 01:29:29 +03:00
#if not sys.argv[1]:
2019-11-10 17:42:39 +03:00
# sys.exit(2)
2019-11-09 01:29:29 +03:00
from twitch import TwitchClient
2020-02-17 21:46:13 +03:00
2021-04-21 21:43:30 +03:00
client = TwitchClient(client_id=config_python.twitchid) #client init
2019-11-09 01:29:29 +03:00
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):
2019-11-10 17:42:39 +03:00
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)
2019-11-09 01:29:29 +03:00
2019-11-10 17:42:39 +03:00
sys.exit(1)