From 8813f26cbe5b294d25fac45c59ea0c4ff6474ada Mon Sep 17 00:00:00 2001 From: Rain <20109-Melon__Bread@users.noreply.gitgud.io> Date: Wed, 3 Apr 2024 00:51:44 +0000 Subject: [PATCH] Initial Commit --- main.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..d8812a4 --- /dev/null +++ b/main.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import subprocess +import time +import requests + +downloading = [] + + +def download_stream(channel): + downloading.append(channel) + subprocess.run(["dl-stream", "-r", channel]) + + +# Grab all the channels from channel_list.txt and put them in a list +with open("channel_list.txt", "r") as file: + # channel_list = file.readlines() + channel_list = [ + line for line in file if line.strip() + ] # Removes all white spaces per line + + +# Run untill progam is killed +while True: + for channel in channel_list: + contents = requests.get("https://www.twitch.tv/" + channel).content.decode( + "utf-8" + ) + if "isLiveBroadcast" in contents: + print(channel + " is live!") + if channel not in downloading: + download_stream(channel) + else: + print(channel + " is already downloading") + else: + print(channel + " is not live.") + if channel in downloading: + downloading.remove(channel) + print(channel + " is no longer downloading") + time.sleep(60) # Wait 60 Seconds before trying again