mirror of
https://gitgud.io/Melon__Bread/auto-ttv-grabber.git
synced 2024-11-24 16:28:30 -05:00
Compare commits
No commits in common. "d519900ba8c9ca2d3e194951e8574698835258e4" and "3957eb40ca17d18ae4541610d6334a07508cbee4" have entirely different histories.
d519900ba8
...
3957eb40ca
11
README.md
11
README.md
@ -1,13 +1,8 @@
|
||||
# Auto TTV Grabber
|
||||
|
||||
<!--toc:start-->
|
||||
- [Auto TTV Grabber](#auto-ttv-grabber)
|
||||
- [Getting started](#getting-started)
|
||||
<!--toc:end-->
|
||||
|
||||
## Getting started
|
||||
|
||||
This script relies on [streamlink](https://streamlink.github.io) being in your systems path.
|
||||
This script relies on [dl-stream](https://codeberg.org/bashuser30/dl-stream) being in your systems path.
|
||||
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.
|
||||
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>`)
|
||||
This script loops through all of the channels in `channel_list.txt` once per minute checking to seeif the channel is live via a HTTP request.
|
||||
Once a channel is live a [dl-stream](https://codeberg.org/bashuser30/dl-stream) subprocess spawns in the background downloading the stream to it's default location (`$HOME/Videos/dl-stream/<channel_name>`)
|
||||
|
42
main.py
42
main.py
@ -16,7 +16,7 @@ downloading = {}
|
||||
# Default Config Settings
|
||||
config = configparser.ConfigParser()
|
||||
streamlink_location = "streamlink"
|
||||
download_location = f"{Path.home()}/Downloads/Streams"
|
||||
download_location = str(f"{Path.home()}/Downloads/Streams/")
|
||||
skip_ads = False
|
||||
|
||||
|
||||
@ -54,41 +54,22 @@ def write_log(channel):
|
||||
|
||||
def download_stream(channel):
|
||||
"""Downloads a given channel name in its own subprocess"""
|
||||
addtional_parms = ""
|
||||
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"
|
||||
# cmd = [
|
||||
# f"{streamlink_location}",
|
||||
# "--loglevel none",
|
||||
# "--retry-max 10",
|
||||
# f"{addtional_parms}",
|
||||
# f"-o {download_location}/{channel}/{file_name}",
|
||||
# f"twitch.tv/{channel}",
|
||||
# "best",
|
||||
# ]
|
||||
# print(cmd)
|
||||
downloading[channel] = subprocess.Popen(
|
||||
[
|
||||
f"{streamlink_location}",
|
||||
"--loglevel none",
|
||||
"--retry-max 10",
|
||||
f"{addtional_parms}",
|
||||
f"-o {download_location}/{channel}/{file_name}",
|
||||
"twitch.tv/ActionButton",
|
||||
"best",
|
||||
]
|
||||
["dl-stream", "-r", channel],
|
||||
start_new_session=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
# write_log(channel)
|
||||
write_log(channel)
|
||||
|
||||
|
||||
def check_system():
|
||||
"""Makes sure everything is place for the script to run"""
|
||||
# Checks if streamlink is in the systems path
|
||||
if not shutil.which("streamlink"):
|
||||
sys.exit("ERROR: streamlink is not found in the systems path!")
|
||||
# TODO: Make it fallback to streamlink if dl-stream not present
|
||||
# Checks if dl-stream is in the systems path
|
||||
if not shutil.which("dl-stream"):
|
||||
sys.exit("ERROR: dl-stream is not found in the systems path!")
|
||||
|
||||
# TODO: Combine the channel_list into the config
|
||||
# Checks if the channel_list exists and if not makes one
|
||||
if not os.path.exists("channel_list.txt"):
|
||||
print("ERROR:'channel_list.txt' does not exist, creating now!")
|
||||
@ -129,7 +110,6 @@ def main():
|
||||
print("\n------------------------------------")
|
||||
for channel in channel_list:
|
||||
channel = channel.strip()
|
||||
# TODO: Have steamlink itself check if the channel is live
|
||||
contents = requests.get("https://www.twitch.tv/" + channel).content.decode(
|
||||
"utf-8"
|
||||
)
|
||||
@ -138,7 +118,7 @@ def main():
|
||||
if channel not in downloading:
|
||||
download_stream(channel)
|
||||
else:
|
||||
print(f"{channel} is already downloading")
|
||||
print("f{channel} is already downloading")
|
||||
write_log(channel)
|
||||
else:
|
||||
print("\033[1m" + channel + "\033[0m is \033[31mnot live\033[0m.")
|
||||
|
Loading…
Reference in New Issue
Block a user