From c49ba072c14a56de91adfb0f38c0bae1ef03ca3e Mon Sep 17 00:00:00 2001 From: l0sted Date: Sun, 10 Nov 2019 17:42:39 +0300 Subject: [PATCH] added check for rerun (lifeChk.py) --- .vscode/settings.json | 3 +++ lifeChk.py | 12 +++++++----- main.py | 1 + cron.sh => main.sh | 0 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json mode change 100755 => 100644 lifeChk.py create mode 100644 main.py rename cron.sh => main.sh (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b26f7c4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/bin/python" +} \ No newline at end of file diff --git a/lifeChk.py b/lifeChk.py old mode 100755 new mode 100644 index 58f4c01..baaf437 --- a/lifeChk.py +++ b/lifeChk.py @@ -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) diff --git a/main.py b/main.py new file mode 100644 index 0000000..d8dbf66 --- /dev/null +++ b/main.py @@ -0,0 +1 @@ +#!/bin/python3 diff --git a/cron.sh b/main.sh similarity index 100% rename from cron.sh rename to main.sh