Dockerfile and docker-compose.yml (#36)
This commit is contained in:
parent
7f79323e1f
commit
5b72ca51c6
12 changed files with 180 additions and 19 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -138,3 +138,6 @@ dmypy.json
|
||||||
|
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
docker/*.whl
|
||||||
|
docker/root/*.whl
|
||||||
|
|
|
||||||
8
Makefile
Normal file
8
Makefile
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
wheel:
|
||||||
|
python setup.py bdist_wheel
|
||||||
|
docker: wheel
|
||||||
|
cp dist/*.whl docker/root/
|
||||||
|
sudo docker build --no-cache -t ytdl-sub:0.1 docker/
|
||||||
|
|
||||||
|
.PHONY: wheel docker
|
||||||
37
docker/Dockerfile
Normal file
37
docker/Dockerfile
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
FROM ghcr.io/linuxserver/baseimage-alpine:3.15
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# YTDL-SUB INSTALL
|
||||||
|
|
||||||
|
COPY root/ /
|
||||||
|
RUN apk update && \
|
||||||
|
apk add \
|
||||||
|
vim \
|
||||||
|
gcc \
|
||||||
|
g++ \
|
||||||
|
make \
|
||||||
|
libffi-dev \
|
||||||
|
openssl-dev && \
|
||||||
|
apk del \
|
||||||
|
python3 \
|
||||||
|
py3-pip && \
|
||||||
|
apk add --repository=http://dl-3.alpinelinux.org/alpine/edge/main/ \
|
||||||
|
python3=3.10.4-r0 \
|
||||||
|
py3-setuptools=59.4.0-r0 && \
|
||||||
|
apk add --repository=http://dl-3.alpinelinux.org/alpine/edge/community/ \
|
||||||
|
py3-pip=22.0.4-r0 && \
|
||||||
|
mkdir -p /config && \
|
||||||
|
pip install --no-cache-dir ytdl_sub-*.whl && \
|
||||||
|
rm ytdl_sub-*.whl
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# CONTAINER CONFIGS
|
||||||
|
|
||||||
|
ENV EDITOR="nano" \
|
||||||
|
HOME="/config"
|
||||||
|
|
||||||
|
VOLUME /config
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
16
docker/docker-compose.yml
Normal file
16
docker/docker-compose.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
version: "2.1"
|
||||||
|
services:
|
||||||
|
ytdl-sub:
|
||||||
|
image: ytdl-sub:latest
|
||||||
|
container_name: ytdl-sub
|
||||||
|
environment:
|
||||||
|
- PUID=1000
|
||||||
|
- PGID=1000
|
||||||
|
- TZ=America/Los_Angeles
|
||||||
|
volumes:
|
||||||
|
- <path/to/ytdl-sub/config>:/config
|
||||||
|
- <path/to/tv_shows>:/tv_shows # optional
|
||||||
|
- <path/to/movies>:/movies # optional
|
||||||
|
- <path/to/music_videos>:/music_videos # optional
|
||||||
|
- <path/to/music>:/music # optional
|
||||||
|
restart: unless-stopped
|
||||||
53
docker/root/defaults/config.yaml
Normal file
53
docker/root/defaults/config.yaml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
configuration:
|
||||||
|
working_directory: '/tmp/ytdl-sub-downloads'
|
||||||
|
|
||||||
|
# All example presets are included in this default config.yaml,
|
||||||
|
# feel free to change it as you see fit. For a detailed explanation
|
||||||
|
# of the examples, see https://ytdl-sub.readthedocs.io/en/latest/examples.html
|
||||||
|
presets:
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# Downloads single videos and stores them as Kodi/Jellyfin/Emby music videos,
|
||||||
|
# which all live in a single directory.
|
||||||
|
yt_music_video:
|
||||||
|
youtube:
|
||||||
|
download_strategy: "video"
|
||||||
|
|
||||||
|
ytdl_options:
|
||||||
|
ignoreerrors: True
|
||||||
|
|
||||||
|
output_options:
|
||||||
|
output_directory: "{music_video_directory}"
|
||||||
|
file_name: "{music_video_name}.{ext}"
|
||||||
|
thumbnail_name: "{music_video_name}.jpg"
|
||||||
|
|
||||||
|
convert_thumbnail:
|
||||||
|
to: "jpg"
|
||||||
|
|
||||||
|
nfo_tags:
|
||||||
|
nfo_name: "{music_video_name}.nfo"
|
||||||
|
nfo_root: "musicvideo"
|
||||||
|
tags:
|
||||||
|
artist: "{artist}"
|
||||||
|
title: "{title}"
|
||||||
|
album: "Music Videos"
|
||||||
|
year: "{upload_year}"
|
||||||
|
|
||||||
|
overrides:
|
||||||
|
music_video_directory: "/music_videos"
|
||||||
|
music_video_name: "{sanitized_artist} - {sanitized_title}"
|
||||||
|
# artist: # FILL THIS OUT IN THE SUBSCRIPTION
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# Downloads playlists and stores all videos as Kodi/Jellyfin/Emby music
|
||||||
|
# videos, which all live in a single directory.
|
||||||
|
yt_music_video_playlist:
|
||||||
|
preset: "yt_music_video"
|
||||||
|
youtube:
|
||||||
|
download_strategy: "playlist"
|
||||||
|
|
||||||
|
output_options:
|
||||||
|
maintain_download_archive: True
|
||||||
|
|
||||||
|
ytdl_options:
|
||||||
|
break_on_existing: True
|
||||||
7
docker/root/defaults/subscriptions.yaml
Normal file
7
docker/root/defaults/subscriptions.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
rammstein_music_videos:
|
||||||
|
preset: "yt_music_video_playlist"
|
||||||
|
youtube:
|
||||||
|
playlist_id: "PLVTLbc6i-h_iuhdwUfuPDLFLXG2QQnz-x"
|
||||||
|
overrides:
|
||||||
|
artist: "Rammstein"
|
||||||
|
|
||||||
11
docker/root/etc/cont-init.d/30-config
Normal file
11
docker/root/etc/cont-init.d/30-config
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/with-contenv bash
|
||||||
|
|
||||||
|
# copy config
|
||||||
|
[[ ! -e /config/config.yaml ]] && \
|
||||||
|
cp /defaults/config.yaml /config/config.yaml
|
||||||
|
[[ ! -e /config/subscriptions.yaml ]] && \
|
||||||
|
cp /defaults/subscriptions.yaml /config/subscriptions.yaml
|
||||||
|
|
||||||
|
# permissions
|
||||||
|
chown -R abc:abc \
|
||||||
|
/config
|
||||||
|
|
@ -16,12 +16,12 @@ configuration:
|
||||||
working_directory: '.ytdl-sub-downloads'
|
working_directory: '.ytdl-sub-downloads'
|
||||||
|
|
||||||
presets:
|
presets:
|
||||||
yt_music_video_playlist:
|
yt_music_video:
|
||||||
# Youtube playlists are our source/download strategy. However, this
|
# A single YouTube video is our source/download strategy. However, this
|
||||||
# can be overwritten to download music videos from a 'channel' or a
|
# can be overwritten to download music videos from a "playlist", as we
|
||||||
# single 'video'
|
# will see in a preset below
|
||||||
youtube:
|
youtube:
|
||||||
download_strategy: "playlist"
|
download_strategy: "video"
|
||||||
|
|
||||||
# For advanced YTDL users only.
|
# For advanced YTDL users only.
|
||||||
# It is wise to leave ignoreerrors=True to avoid errors for things
|
# It is wise to leave ignoreerrors=True to avoid errors for things
|
||||||
|
|
@ -32,16 +32,10 @@ presets:
|
||||||
# For each video downloaded, set the file and thumbnail name here.
|
# For each video downloaded, set the file and thumbnail name here.
|
||||||
# We set both with {music_video_name}, which is a variable we define in
|
# We set both with {music_video_name}, which is a variable we define in
|
||||||
# the overrides section further below to represent consistent naming format.
|
# the overrides section further below to represent consistent naming format.
|
||||||
#
|
|
||||||
# Another field worth mentioning is maintain_download_archive=True. This
|
|
||||||
# is generally a good thing to enable with playlists because it will
|
|
||||||
# store previously downloaded video ids to tell YTDL not to re-download
|
|
||||||
# them on a successive invocation.
|
|
||||||
output_options:
|
output_options:
|
||||||
output_directory: "{music_video_directory}"
|
output_directory: "{music_video_directory}/{sanitized_artist}"
|
||||||
file_name: "{music_video_name}.{ext}"
|
file_name: "{music_video_name}.{ext}"
|
||||||
thumbnail_name: "{music_video_name}.jpg"
|
thumbnail_name: "{music_video_name}.jpg"
|
||||||
maintain_download_archive: True
|
|
||||||
|
|
||||||
# Always convert the video thumbnail to jpg
|
# Always convert the video thumbnail to jpg
|
||||||
# TODO: always convert all thumbnails to jpg in code
|
# TODO: always convert all thumbnails to jpg in code
|
||||||
|
|
@ -70,7 +64,19 @@ presets:
|
||||||
# It is not always ideal to download all of an artist's music videos.
|
# It is not always ideal to download all of an artist's music videos.
|
||||||
# Maybe you only like one song of theirs. We can reuse our preset above
|
# Maybe you only like one song of theirs. We can reuse our preset above
|
||||||
# to download a single video instead.
|
# to download a single video instead.
|
||||||
yt_music_video:
|
yt_music_video_playlist:
|
||||||
preset: "yt_music_video_playlist"
|
preset: "yt_music_video"
|
||||||
youtube:
|
youtube:
|
||||||
download_strategy: "video"
|
download_strategy: "playlist"
|
||||||
|
|
||||||
|
# Setting maintain_download_archive=True is generally a good thing to enable
|
||||||
|
# with playlists and channels because it will store previously downloaded
|
||||||
|
# video ids to tell YTDL not to re-download them on a successive invocation.
|
||||||
|
output_options:
|
||||||
|
maintain_download_archive: True
|
||||||
|
|
||||||
|
# Setting break_on_existing=True is also a good thing anytime you are using
|
||||||
|
# a download archive, because it will tell the downloader to stop trying
|
||||||
|
# to download videos that have already been downloaded.
|
||||||
|
ytdl_options:
|
||||||
|
break_on_existing: True
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ console_scripts =
|
||||||
[options]
|
[options]
|
||||||
package_dir =
|
package_dir =
|
||||||
= src
|
= src
|
||||||
|
packages=find:
|
||||||
|
|
||||||
install_requires =
|
install_requires =
|
||||||
argparse==1.4.0
|
argparse==1.4.0
|
||||||
dicttoxml==1.7.4
|
dicttoxml==1.7.4
|
||||||
|
|
@ -30,6 +32,9 @@ install_requires =
|
||||||
PyYAML==6.0
|
PyYAML==6.0
|
||||||
yt-dlp==2022.4.8
|
yt-dlp==2022.4.8
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
where=src
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
test =
|
test =
|
||||||
coverage[toml]==6.3.2
|
coverage[toml]==6.3.2
|
||||||
|
|
@ -42,3 +47,7 @@ lint =
|
||||||
docs =
|
docs =
|
||||||
sphinx==4.5.0
|
sphinx==4.5.0
|
||||||
sphinx-rtd-theme==1.0.0
|
sphinx-rtd-theme==1.0.0
|
||||||
|
build =
|
||||||
|
setuptools
|
||||||
|
wheel
|
||||||
|
|
||||||
|
|
|
||||||
4
setup.py
Normal file
4
setup.py
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
|
|
@ -3,7 +3,7 @@ import argparse
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
# GLOBAL PARSER
|
# GLOBAL PARSER
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="YoutubeDL-Subscribe: Download and organize your favorite media hassle-free."
|
description="ytdl-sub: Automate download and adding metadata with YoutubeDL"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
|
|
@ -21,8 +21,8 @@ subscription_parser.add_argument(
|
||||||
"subscription_paths",
|
"subscription_paths",
|
||||||
metavar="SUBPATH",
|
metavar="SUBPATH",
|
||||||
nargs="*",
|
nargs="*",
|
||||||
help="path to subscription files, uses config.yaml if not provided",
|
help="path to subscription files, uses subscriptions.yaml if not provided",
|
||||||
default="config.yaml",
|
default="subscriptions.yaml",
|
||||||
)
|
)
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
# DOWNLOAD PARSER
|
# DOWNLOAD PARSER
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,14 @@ def _download_subscription_from_cli(config: ConfigFile, extra_args: List[str]) -
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Entrypoint for ytdl-subscribe"""
|
"""
|
||||||
|
Entrypoint for ytdl-subscribe
|
||||||
|
"""
|
||||||
|
# If no args are provided, print help and exit
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
parser.print_help()
|
||||||
|
return
|
||||||
|
|
||||||
args, extra_args = parser.parse_known_args()
|
args, extra_args = parser.parse_known_args()
|
||||||
|
|
||||||
config: ConfigFile = ConfigFile.from_file_path(args.config)
|
config: ConfigFile = ConfigFile.from_file_path(args.config)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue