More clean up with type hints

This commit is contained in:
Rain Clark 2024-04-08 12:49:28 -04:00
parent 4218dc827f
commit aaf2173894

15
main.py
View File

@ -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: