Skip to content

Commit

Permalink
Finished dockerfile, fixed logging error in threads, Improved readmes…
Browse files Browse the repository at this point in the history
…, Updated dependencies

Update Dockerfile, config.json, and 4 more files...
  • Loading branch information
aziascreations committed Feb 28, 2022
1 parent 294e9db commit 3c55ee3
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 33 deletions.
34 changes: 17 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# This should be the lightest image.
FROM python:alpine

# Installing dependencies
# Reading the build arguments.
# * BUID -> Build UID
# * BGID -> Build GID
ARG BUID=1000
ARG BGID=1000

# Installing dependencies.
# * 'g++', 'make' -> Compiling some dependencies.
# * 'py3-lxml' -> Pre-compiled module, allows you to ignore compilation errors.

# Used to compile lxml for streamlink (Not used for the moment)
# RUN apk add --no-cache libxslt-dev libxml2-dev

# Used for compiling streamlink and its dependencies
RUN apk update && apk upgrade && \
apk add --no-cache g++ make py3-lxml ffmpeg

# Installing required Python packages
RUN pip install --upgrade streamlink==2.3.0 yt-dlp==2021.12.01
# Previously used to compile lxml for streamlink. (Not used for the moment)
# RUN apk add --no-cache libxslt-dev libxml2-dev

# Installing required Python packages.
ADD --chown=BUID:BGID ./requirements.txt /app/requirements.txt
RUN pip install --upgrade -r /app/requirements.txt

# Removing packages that are no longer needed and were used for compiling streamlink and its dependencies
# Removing packages that are no longer needed and were used for compiling streamlink and its dependencies.
# * Some are left however: libgcc, libstdc++, libgomp and gmp
# * Reduces the HDD usage from 198 MiB to 127 MiB for these packages
RUN apk del g++ make

# Reading the build arguments
# * BUID -> Build UID
# * BGID -> Build GID
ARG BUID=1000
ARG BGID=1000

# Copying the app's files to the container
ADD --chown=BUID:BGID . /app

# Running the application
# Running the application.
# * Thanks to jdpus for the "-u" flag, it fixes the output (https://stackoverflow.com/a/29745541/4135541)
WORKDIR /app
USER $BUID:$BGID
CMD ["python", "-u", "/app/app.py"]

# Used for debugging
# Used for debugging.
#CMD ["tail", "-f", "/dev/null"]
13 changes: 6 additions & 7 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"youtube": {
"output_subdir": "./youtube",
"general_prefix": "yt-",
"delay_ms_metadata_download": 30000,
"logging_level_worker": 10,
"logging_level_thread": 10,
Expand All @@ -19,10 +18,10 @@
"channel_id": "RogueInternetMan",
"name": "Rogue, Internet Man",
"output_subdir": "./rogue_internet_man",
"live_subdir": "./uploads",
"upload_subdir": "./livestreams",
"live_subdir": "./livestreams",
"upload_subdir": "./uploads",
"check_live": true,
"check_upload": true,
"check_upload": false,
"interval_ms_live": 90000,
"interval_ms_upload": 3700000,
"quality_live": "best",
Expand All @@ -38,10 +37,10 @@
"channel_id": "propainkey",
"name": "propainkey",
"output_subdir": "./propainkey",
"live_subdir": "./uploads",
"upload_subdir": "./livestreams",
"live_subdir": "./livestreams",
"upload_subdir": "./uploads",
"check_live": false,
"check_upload": false,
"check_upload": true,
"interval_ms_live": 120000,
"interval_ms_upload": 5100000,
"quality_live": "best",
Expand Down
31 changes: 28 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ The application isn't designed to be used by another one as a module.
* Configurable delays, actions, locations per channel.
* Planned for v1.0.0
* Native support for cookies for *yt-dlp* and maybe *streamlink*.
* Better support to prevent command injection. (Will block some features if used)
* Planned for later
* Using TOML for the config file only Python 3.11 is released and stable.

## Requirements
* [Python](https://www.python.org/) v3.9
* [Streamlink](https://streamlink.github.io/) v3.1.1
* [yt-dlp](https://github.com/yt-dlp/yt-dlp) v2021.09.02
* [Python](https://www.python.org/) >= v3.9, < v3.11 <sub><sup>(Preferably)</sup></sub>
* [Streamlink](https://streamlink.github.io/) >= v3.1.1, < v4.\*.\*
* [yt-dlp](https://github.com/yt-dlp/yt-dlp) >= v2022.02.04

The application may work just fine with older or newer versions of these pieces of software, but they will not be supported.<br>
All requirements, except for *Python*, can be installed via *pip* or manually.
Expand Down Expand Up @@ -98,6 +101,28 @@ appropriate [environment variables](#environment-variables) tells the applicatio

Please refer to [config.md](config.md) for more information on the config file and its fields.

## Build Arguments *(Docker)*
<table>
<tr>
<th style="width:25%">Variable</th>
<th style="width:20%">Type</th>
<th style="width:50%">Remark</th>
<th style="width:5%">Default</th>
</tr>
<tr>
<td>BUID</td>
<td>Integer</td>
<td>User ID under which the app runs and who owns the app's directory.<br>May not work on Windows and NTFS volumes !</td>
<td><code>1000</code></td>
</tr>
<tr>
<td>BGID</td>
<td>Integer</td>
<td>Group ID under which the app runs and who owns the app's directory.<br>May not work on Windows and NTFS volumes !</td>
<td><code>1000</code></td>
</tr>
</table>

## Environment Variables
Any environment variable that is not set will have the effect of its default value.

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
streamlink>=3.1.1,<4.0.0
yt-dlp==2021.12.01
yt-dlp>=2022.02.04
5 changes: 3 additions & 2 deletions yaa/workers/youtube/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ def __thread_yt_live(worker: YouTubeWorker, **args):
:param args: Raw arguments passed by workers. (Not used)
:return: Nothing. (See the description for more info)
"""
# Makes non-debug logs possible to debug from a bird's eye view.
worker.logger_thread.info("Running 'YouTube Live' thread for '{}' !".format(worker.channel.channel_config.name))

# Preparing the logger for the 1st time if needed.
if worker.logger_thread is None:
Expand All @@ -50,6 +48,9 @@ def __thread_yt_live(worker: YouTubeWorker, **args):
worker.channel.config.youtube.logging_level_thread
)

# Makes non-debug logs possible to debug from a bird's eye view.
worker.logger_thread.info("Running 'YouTube Live' thread for '{}' !".format(worker.channel.channel_config.name))

# Preparing the base filename with no extension
file_base_name: str = "{}-live-{}".format(
worker.channel.channel_config.internal_id,
Expand Down
7 changes: 4 additions & 3 deletions yaa/workers/youtube/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ def __thread_yt_upload(worker: YouTubeWorker, **args):
:param args: Raw arguments passed by workers. (Not used)
:return: Nothing. (See the description for more info)
"""
# Makes non-debug logs possible to debug from a bird's eye view.
worker.logger_thread.info("Running 'YouTube Uploads' thread for '{}' !".format(worker.channel.channel_config.name))

# Preparing the logger for the 1st time if needed.
if worker.logger_thread is None:
worker.logger_thread = get_logger(
"yt-upload-" + worker.channel.channel_config.internal_id,
worker.channel.config.youtube.logging_level_thread
)

# Makes non-debug logs possible to debug from a bird's eye view.
worker.logger_thread.info("Running 'YouTube Uploads' thread for '{}' !".format(worker.channel.channel_config.name))

# Preparing the command
command: str = "yt-dlp --no-warnings --newline --no-progress --dateafter now-{}days {}{}-f {} {}" \
"https://www.youtube.com/c/{}"
Expand Down Expand Up @@ -91,6 +91,7 @@ def __thread_yt_upload(worker: YouTubeWorker, **args):

worker.last_return_code = process.returncode

# TODO: Figure out a safe way to re-encode these lines for 0.8.0 !
lines = process.stdout.readlines()
process.stdout.flush()
for line in lines:
Expand Down

0 comments on commit 3c55ee3

Please sign in to comment.