Dockerfile and docker-compose.yml (#36)

This commit is contained in:
Jesse Bannon 2022-05-20 12:52:58 -07:00 committed by GitHub
parent 7f79323e1f
commit 5b72ca51c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 180 additions and 19 deletions

3
.gitignore vendored
View file

@ -138,3 +138,6 @@ dmypy.json
*.DS_Store
.idea/
docker/*.whl
docker/root/*.whl

8
Makefile Normal file
View 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
View 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
View 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

View 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

View file

@ -0,0 +1,7 @@
rammstein_music_videos:
preset: "yt_music_video_playlist"
youtube:
playlist_id: "PLVTLbc6i-h_iuhdwUfuPDLFLXG2QQnz-x"
overrides:
artist: "Rammstein"

View 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

View file

@ -16,12 +16,12 @@ configuration:
working_directory: '.ytdl-sub-downloads'
presets:
yt_music_video_playlist:
# Youtube playlists are our source/download strategy. However, this
# can be overwritten to download music videos from a 'channel' or a
# single 'video'
yt_music_video:
# A single YouTube video is our source/download strategy. However, this
# can be overwritten to download music videos from a "playlist", as we
# will see in a preset below
youtube:
download_strategy: "playlist"
download_strategy: "video"
# For advanced YTDL users only.
# 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.
# We set both with {music_video_name}, which is a variable we define in
# 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_directory: "{music_video_directory}"
output_directory: "{music_video_directory}/{sanitized_artist}"
file_name: "{music_video_name}.{ext}"
thumbnail_name: "{music_video_name}.jpg"
maintain_download_archive: True
# Always convert the video thumbnail to jpg
# 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.
# Maybe you only like one song of theirs. We can reuse our preset above
# to download a single video instead.
yt_music_video:
preset: "yt_music_video_playlist"
yt_music_video_playlist:
preset: "yt_music_video"
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

View file

@ -21,6 +21,8 @@ console_scripts =
[options]
package_dir =
= src
packages=find:
install_requires =
argparse==1.4.0
dicttoxml==1.7.4
@ -30,6 +32,9 @@ install_requires =
PyYAML==6.0
yt-dlp==2022.4.8
[options.packages.find]
where=src
[options.extras_require]
test =
coverage[toml]==6.3.2
@ -42,3 +47,7 @@ lint =
docs =
sphinx==4.5.0
sphinx-rtd-theme==1.0.0
build =
setuptools
wheel

4
setup.py Normal file
View file

@ -0,0 +1,4 @@
from setuptools import setup
if __name__ == "__main__":
setup()

View file

@ -3,7 +3,7 @@ import argparse
###################################################################################################
# GLOBAL PARSER
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(
"-c",
@ -21,8 +21,8 @@ subscription_parser.add_argument(
"subscription_paths",
metavar="SUBPATH",
nargs="*",
help="path to subscription files, uses config.yaml if not provided",
default="config.yaml",
help="path to subscription files, uses subscriptions.yaml if not provided",
default="subscriptions.yaml",
)
###################################################################################################
# DOWNLOAD PARSER

View file

@ -59,7 +59,14 @@ def _download_subscription_from_cli(config: ConfigFile, extra_args: List[str]) -
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()
config: ConfigFile = ConfigFile.from_file_path(args.config)