From aaf2173894cab61e531f81b6dd93be2aa6fc943b Mon Sep 17 00:00:00 2001 From: Melon Bread Date: Mon, 8 Apr 2024 12:49:28 -0400 Subject: [PATCH] More clean up with type hints --- main.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 60381d5..91390e9 100755 --- a/main.py +++ b/main.py @@ -7,9 +7,10 @@ import sys import time from datetime import datetime from pathlib import Path +from typing import List import requests -channel_list = [] +channel_list: List[str] = [] downloading = {} # Default Config Settings @@ -18,7 +19,7 @@ download_location: str = f"{Path.home()}/Downloads/Streams" skip_ads: bool = False -def load_config(): +def load_config() -> None: print("Reading config file...") config = configparser.ConfigParser() config.read("config.ini") @@ -41,7 +42,7 @@ def load_config(): print("Config file loaded") -def write_log(channel): +def write_log(channel: str) -> None: """Writes the latest stdout of a process to log.txt""" with open("log.txt", "a") as log: line = downloading[channel].stdout.readline() @@ -49,7 +50,7 @@ def write_log(channel): log.write(line.decode()) -def download_stream(channel): +def download_stream(channel: str) -> None: """Downloads a given channel name in its own subprocess""" # TODO: Just clean this up at somepoint addtional_parms = "" @@ -68,7 +69,7 @@ def download_stream(channel): write_log(channel) -def check_system(): +def check_system() -> None: """Makes sure everything is place for the script to run""" # Checks for config file @@ -95,7 +96,7 @@ def check_system(): os.makedirs(download_location) -def stop_downloads(): +def stop_downloads() -> None: """Goes through every process and stops it if running""" print("\nCleaning up...") for name, proc in downloading.items(): @@ -103,7 +104,7 @@ def stop_downloads(): print(f"Stopping download of {name}") -def main(): +def main() -> None: """Main entry point of the app""" # Grab all the channels from channel_list.txt and put them in a list with open("channel_list.txt", "r") as file: