mirror of
https://gitgud.io/Melon__Bread/auto-ttv-grabber.git
synced 2024-11-25 00:38:35 -05:00
More clean up with type hints
This commit is contained in:
parent
4218dc827f
commit
aaf2173894
15
main.py
15
main.py
@ -7,9 +7,10 @@ import sys
|
|||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import List
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
channel_list = []
|
channel_list: List[str] = []
|
||||||
downloading = {}
|
downloading = {}
|
||||||
|
|
||||||
# Default Config Settings
|
# Default Config Settings
|
||||||
@ -18,7 +19,7 @@ download_location: str = f"{Path.home()}/Downloads/Streams"
|
|||||||
skip_ads: bool = False
|
skip_ads: bool = False
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config() -> None:
|
||||||
print("Reading config file...")
|
print("Reading config file...")
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read("config.ini")
|
config.read("config.ini")
|
||||||
@ -41,7 +42,7 @@ def load_config():
|
|||||||
print("Config file loaded")
|
print("Config file loaded")
|
||||||
|
|
||||||
|
|
||||||
def write_log(channel):
|
def write_log(channel: str) -> None:
|
||||||
"""Writes the latest stdout of a process to log.txt"""
|
"""Writes the latest stdout of a process to log.txt"""
|
||||||
with open("log.txt", "a") as log:
|
with open("log.txt", "a") as log:
|
||||||
line = downloading[channel].stdout.readline()
|
line = downloading[channel].stdout.readline()
|
||||||
@ -49,7 +50,7 @@ def write_log(channel):
|
|||||||
log.write(line.decode())
|
log.write(line.decode())
|
||||||
|
|
||||||
|
|
||||||
def download_stream(channel):
|
def download_stream(channel: str) -> None:
|
||||||
"""Downloads a given channel name in its own subprocess"""
|
"""Downloads a given channel name in its own subprocess"""
|
||||||
# TODO: Just clean this up at somepoint
|
# TODO: Just clean this up at somepoint
|
||||||
addtional_parms = ""
|
addtional_parms = ""
|
||||||
@ -68,7 +69,7 @@ def download_stream(channel):
|
|||||||
write_log(channel)
|
write_log(channel)
|
||||||
|
|
||||||
|
|
||||||
def check_system():
|
def check_system() -> None:
|
||||||
"""Makes sure everything is place for the script to run"""
|
"""Makes sure everything is place for the script to run"""
|
||||||
|
|
||||||
# Checks for config file
|
# Checks for config file
|
||||||
@ -95,7 +96,7 @@ def check_system():
|
|||||||
os.makedirs(download_location)
|
os.makedirs(download_location)
|
||||||
|
|
||||||
|
|
||||||
def stop_downloads():
|
def stop_downloads() -> None:
|
||||||
"""Goes through every process and stops it if running"""
|
"""Goes through every process and stops it if running"""
|
||||||
print("\nCleaning up...")
|
print("\nCleaning up...")
|
||||||
for name, proc in downloading.items():
|
for name, proc in downloading.items():
|
||||||
@ -103,7 +104,7 @@ def stop_downloads():
|
|||||||
print(f"Stopping download of {name}")
|
print(f"Stopping download of {name}")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> None:
|
||||||
"""Main entry point of the app"""
|
"""Main entry point of the app"""
|
||||||
# Grab all the channels from channel_list.txt and put them in a list
|
# Grab all the channels from channel_list.txt and put them in a list
|
||||||
with open("channel_list.txt", "r") as file:
|
with open("channel_list.txt", "r") as file:
|
||||||
|
Loading…
Reference in New Issue
Block a user