mirror of
https://gitgud.io/Melon__Bread/auto-ttv-grabber.git
synced 2024-11-28 10:18:21 -05:00
Compare commits
No commits in common. "4218dc827f91a9929554e7b85148ae9748bff733" and "ed2f65bee521d7124d8d5dd90bd990e33e7a992a" have entirely different histories.
4218dc827f
...
ed2f65bee5
58
main.py
58
main.py
@ -1,44 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
import configparser
|
||||
import os
|
||||
import requests
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
import requests
|
||||
|
||||
channel_list = []
|
||||
downloading = {}
|
||||
|
||||
# Default Config Settings
|
||||
streamlink_location: str = "streamlink"
|
||||
download_location: str = f"{Path.home()}/Downloads/Streams"
|
||||
skip_ads: bool = False
|
||||
config = configparser.ConfigParser()
|
||||
streamlink_location = "streamlink"
|
||||
download_location = f"{Path.home()}/Downloads/Streams"
|
||||
skip_ads = False
|
||||
|
||||
|
||||
def load_config():
|
||||
print("Reading config file...")
|
||||
config = configparser.ConfigParser()
|
||||
config.read("config.ini")
|
||||
if (
|
||||
config.has_option("settings", "streamlink_location")
|
||||
and not config["settings"]["streamlink_location"].strip()
|
||||
):
|
||||
streamlink_location = config["settings"]["streamlink_location"]
|
||||
print(f"Streamlink location: {streamlink_location}")
|
||||
if (
|
||||
config.has_option("settings", "download_location")
|
||||
and not config["settings"]["download_location"].strip()
|
||||
):
|
||||
download_location = config["settings"]["download_location"]
|
||||
print(f"Download location: {download_location}")
|
||||
if config.has_option("settings", "skip_ads") and not config["settings"]["skip_ads"]:
|
||||
skip_ads = bool(config["settings"]["skip_ads"])
|
||||
print(f"Skip ads: {skip_ads}")
|
||||
|
||||
print("Config file loaded")
|
||||
if os.path.exists("config.ini"):
|
||||
config.read("config.ini")
|
||||
if (
|
||||
config.has_option("settings", "streamlink_location")
|
||||
and not config["settings"]["streamlink_location"].strip()
|
||||
):
|
||||
streamlink_location = config["settings"]["streamlink_location"]
|
||||
if (
|
||||
config.has_option("settings", "download_location")
|
||||
and not config["settings"]["download_location"].strip()
|
||||
):
|
||||
download_location = config["settings"]["download_location"]
|
||||
if (
|
||||
config.has_option("settings", "skip_ads")
|
||||
and not config["settings"]["skip_ads"]
|
||||
):
|
||||
skip_ads = bool(config["settings"]["skip_ads"])
|
||||
print("Config file loaded")
|
||||
else:
|
||||
print("No config file found using default values!")
|
||||
|
||||
|
||||
def write_log(channel):
|
||||
@ -53,7 +55,6 @@ def download_stream(channel):
|
||||
"""Downloads a given channel name in its own subprocess"""
|
||||
# TODO: Just clean this up at somepoint
|
||||
addtional_parms = ""
|
||||
print(str(skip_ads))
|
||||
if skip_ads:
|
||||
addtional_parms = "--twitch-proxy-playlist=https://lb-eu.cdn-perfprod.com,https://lb-eu2.cdn-perfprod.com,https://lb-na.cdn-perfprod.com,https://lb-as.cdn-perfprod.com,https://as.luminous.dev --twitch-disable-ads"
|
||||
file_name = f"{channel}_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.ts"
|
||||
@ -70,11 +71,6 @@ def download_stream(channel):
|
||||
|
||||
def check_system():
|
||||
"""Makes sure everything is place for the script to run"""
|
||||
|
||||
# Checks for config file
|
||||
if not os.path.exists("config.ini"):
|
||||
sys.exit("ERROR: config.ini is not found! See README.md for more info.")
|
||||
|
||||
# Checks if streamlink is in the systems path
|
||||
if not shutil.which("streamlink"):
|
||||
sys.exit("ERROR: streamlink is not found in the systems path!")
|
||||
@ -145,10 +141,10 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""This is executed when run from the command line"""
|
||||
""" This is executed when run from the command line """
|
||||
try:
|
||||
check_system()
|
||||
load_config()
|
||||
check_system()
|
||||
main()
|
||||
finally:
|
||||
stop_downloads()
|
||||
|
Loading…
Reference in New Issue
Block a user