mirror of
https://gitgud.io/Melon__Bread/auto-ttv-grabber.git
synced 2025-08-02 15:44:36 -04:00
Compare commits
4 Commits
config
...
4218dc827f
Author | SHA1 | Date | |
---|---|---|---|
4218dc827f | |||
660b7f1e82 | |||
ed2f65bee5 | |||
18c0f2123d |
@ -10,4 +10,4 @@
|
|||||||
This script relies on [streamlink](https://streamlink.github.io) being in your systems path.
|
This script relies on [streamlink](https://streamlink.github.io) being in your systems path.
|
||||||
You can find all of its requirements on the their project page.
|
You can find all of its requirements on the their project page.
|
||||||
This script loops through all of the channels in `channel_list.txt` once per minute checking to see if the channel is live via a HTTP request.
|
This script loops through all of the channels in `channel_list.txt` once per minute checking to see if the channel is live via a HTTP request.
|
||||||
Once a channel is live a [streamlink](https://streamlink.github.io) subprocess spawns in the background downloading the stream to it's default location (`$HOME/Videos/Stream/<channel_name>`)
|
Once a channel is live a [streamlink](https://streamlink.github.io) subprocess spawns in the background downloading the stream to it's default location (`$HOME/Downloads/Stream/<channel_name>`)
|
||||||
|
56
main.py
56
main.py
@ -13,34 +13,32 @@ channel_list = []
|
|||||||
downloading = {}
|
downloading = {}
|
||||||
|
|
||||||
# Default Config Settings
|
# Default Config Settings
|
||||||
config = configparser.ConfigParser()
|
streamlink_location: str = "streamlink"
|
||||||
streamlink_location = "streamlink"
|
download_location: str = f"{Path.home()}/Downloads/Streams"
|
||||||
download_location = f"{Path.home()}/Downloads/Streams"
|
skip_ads: bool = False
|
||||||
skip_ads = False
|
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
print("Reading config file...")
|
print("Reading config file...")
|
||||||
if os.path.exists("config.ini"):
|
config = configparser.ConfigParser()
|
||||||
config.read("config.ini")
|
config.read("config.ini")
|
||||||
if (
|
if (
|
||||||
config.has_option("settings", "streamlink_location")
|
config.has_option("settings", "streamlink_location")
|
||||||
and not config["settings"]["streamlink_location"].strip()
|
and not config["settings"]["streamlink_location"].strip()
|
||||||
):
|
):
|
||||||
streamlink_location = config["settings"]["streamlink_location"]
|
streamlink_location = config["settings"]["streamlink_location"]
|
||||||
if (
|
print(f"Streamlink location: {streamlink_location}")
|
||||||
config.has_option("settings", "download_location")
|
if (
|
||||||
and not config["settings"]["download_location"].strip()
|
config.has_option("settings", "download_location")
|
||||||
):
|
and not config["settings"]["download_location"].strip()
|
||||||
download_location = config["settings"]["download_location"]
|
):
|
||||||
if (
|
download_location = config["settings"]["download_location"]
|
||||||
config.has_option("settings", "skip_ads")
|
print(f"Download location: {download_location}")
|
||||||
and not config["settings"]["skip_ads"]
|
if config.has_option("settings", "skip_ads") and not config["settings"]["skip_ads"]:
|
||||||
):
|
skip_ads = bool(config["settings"]["skip_ads"])
|
||||||
skip_ads = bool(config["settings"]["skip_ads"])
|
print(f"Skip ads: {skip_ads}")
|
||||||
print("Config file loaded")
|
|
||||||
else:
|
print("Config file loaded")
|
||||||
print("No config file found using default values!")
|
|
||||||
|
|
||||||
|
|
||||||
def write_log(channel):
|
def write_log(channel):
|
||||||
@ -55,6 +53,7 @@ def download_stream(channel):
|
|||||||
"""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 = ""
|
||||||
|
print(str(skip_ads))
|
||||||
if 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"
|
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"
|
file_name = f"{channel}_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.ts"
|
||||||
@ -71,6 +70,11 @@ def download_stream(channel):
|
|||||||
|
|
||||||
def check_system():
|
def check_system():
|
||||||
"""Makes sure everything is place for the script to run"""
|
"""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
|
# Checks if streamlink is in the systems path
|
||||||
if not shutil.which("streamlink"):
|
if not shutil.which("streamlink"):
|
||||||
sys.exit("ERROR: streamlink is not found in the systems path!")
|
sys.exit("ERROR: streamlink is not found in the systems path!")
|
||||||
@ -141,10 +145,10 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
""" This is executed when run from the command line """
|
"""This is executed when run from the command line"""
|
||||||
try:
|
try:
|
||||||
load_config()
|
|
||||||
check_system()
|
check_system()
|
||||||
|
load_config()
|
||||||
main()
|
main()
|
||||||
finally:
|
finally:
|
||||||
stop_downloads()
|
stop_downloads()
|
||||||
|
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
certifi==2024.2.2
|
||||||
|
charset-normalizer==3.3.2
|
||||||
|
idna==3.6
|
||||||
|
requests==2.31.0
|
||||||
|
urllib3==2.2.1
|
Reference in New Issue
Block a user