mirror of
https://gitgud.io/Melon__Bread/auto-ttv-grabber.git
synced 2024-11-25 00:38:35 -05:00
Now read the channel list from the config.ini
This commit is contained in:
parent
33d7ae24fb
commit
e07dd0c5cd
4
.gitignore
vendored
4
.gitignore
vendored
@ -159,8 +159,8 @@ cython_debug/
|
|||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
# Channel List
|
# Configuration
|
||||||
channel_list.txt
|
config.ini
|
||||||
|
|
||||||
# dl-stream log
|
# dl-stream log
|
||||||
log.txt
|
log.txt
|
||||||
|
47
README.md
47
README.md
@ -2,12 +2,49 @@
|
|||||||
|
|
||||||
<!--toc:start-->
|
<!--toc:start-->
|
||||||
- [Auto TTV Grabber](#auto-ttv-grabber)
|
- [Auto TTV Grabber](#auto-ttv-grabber)
|
||||||
- [Getting started](#getting-started)
|
- [tl;dr](#tldr)
|
||||||
|
- [Configuration](#configuration)
|
||||||
|
- [Settings](#settings)
|
||||||
|
- [Adding streams](#adding-streams)
|
||||||
<!--toc:end-->
|
<!--toc:end-->
|
||||||
|
|
||||||
## Getting started
|
## tl;dr
|
||||||
|
|
||||||
This script relies on [streamlink](https://streamlink.github.io) being in your systems path.
|
This script relies on [streamlink](https://streamlink.github.io) being installed.
|
||||||
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 `config.ini`,
|
||||||
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>`)
|
once per minute checking to see if the channel is live via a HTTP request.
|
||||||
|
Once a channel is live a `streamlink` subprocess spawns in the background,
|
||||||
|
downloading the stream to it's default location (`$HOME/Downloads/Stream/<channel_name>`)
|
||||||
|
If you wish to change this location, you can find out how to below
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
You can copy `config.ini.example` from the repo to `config.ini` to begin.
|
||||||
|
Leaving a setting blank will render it being ignored and using the default value.
|
||||||
|
|
||||||
|
### Settings
|
||||||
|
|
||||||
|
- `streamlink_location`: If `streamlink` is not in your path you can specify
|
||||||
|
its absolute location here. Otherwise it looks for it in your path.
|
||||||
|
- `download_location`: You can specify the absolute path to where you would like
|
||||||
|
to save the steams. A subdirectory will be created for each channel as it goes live.
|
||||||
|
If left blank the default location is: `$HOME/Downloads/Streams/<channel_name>`
|
||||||
|
- `skip_ads` : Takes a `True` or `False` value. If `True` you will need to have
|
||||||
|
installed the [ttvlol](https://github.com/2bc4/streamlink-ttvlol) `streamlink`
|
||||||
|
plugin. Setting this to `True` without doing so will cause the
|
||||||
|
`streamlink` subprocess to fail. Default value is `False`
|
||||||
|
|
||||||
|
### Adding streams
|
||||||
|
|
||||||
|
You will need to add the channels Twitch username to `config.ini`:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[streams]
|
||||||
|
1 = coney
|
||||||
|
2 = dougdoug
|
||||||
|
3 = parkzer
|
||||||
|
```
|
||||||
|
|
||||||
|
As for as I know there is no limit to how many streams you can add this way,
|
||||||
|
just make sure when you add a new stream it is incremented by one
|
||||||
|
7
config.ini.example
Normal file
7
config.ini.example
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[settings]
|
||||||
|
streamlink_location = ""
|
||||||
|
download_location = ""
|
||||||
|
skip_ads =
|
||||||
|
|
||||||
|
[streams]
|
||||||
|
|
20
main.py
20
main.py
@ -40,6 +40,12 @@ def load_config() -> None:
|
|||||||
skip_ads = bool(config["settings"]["skip_ads"])
|
skip_ads = bool(config["settings"]["skip_ads"])
|
||||||
print(f"Skip ads: {skip_ads}")
|
print(f"Skip ads: {skip_ads}")
|
||||||
|
|
||||||
|
if len(config["streams"]) < 1:
|
||||||
|
sys.exit("ERROR: No streams found in config.ini! See README.md for more info.")
|
||||||
|
else:
|
||||||
|
for index in range(1, len(config["streams"]) + 1):
|
||||||
|
channel_list.append(config["streams"][str(index)])
|
||||||
|
|
||||||
print("Config file loaded")
|
print("Config file loaded")
|
||||||
|
|
||||||
|
|
||||||
@ -82,14 +88,6 @@ def check_system() -> None:
|
|||||||
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!")
|
||||||
|
|
||||||
# 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!")
|
|
||||||
with open("channel_list.txt", "w"):
|
|
||||||
pass # Creates empty file
|
|
||||||
sys.exit("Please populate the channel_list.txt with one channel per line!")
|
|
||||||
|
|
||||||
# Make sure the download location exists
|
# Make sure the download location exists
|
||||||
if not os.path.exists(download_location):
|
if not os.path.exists(download_location):
|
||||||
print(
|
print(
|
||||||
@ -108,12 +106,6 @@ def stop_downloads() -> None:
|
|||||||
|
|
||||||
def main() -> None:
|
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
|
|
||||||
with open("channel_list.txt", "r") as file:
|
|
||||||
# channel_list = file.readlines()
|
|
||||||
channel_list = [
|
|
||||||
line for line in file if line.strip()
|
|
||||||
] # Removes all white spaces per line
|
|
||||||
|
|
||||||
# Run untill progam is killed
|
# Run untill progam is killed
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user