diff --git a/README.md b/README.md index 302b0d57..4658f182 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,10 @@ __preset__: ytdl_options: cookiefile: "/config/cookie.txt" -############################################################################### -# Subscriptions nested under this will use the `Plex TV Show by Date` preset. +################################################################### +# Subscriptions nested under this will use the +# `Plex TV Show by Date` preset. +# # Can choose between: # - Plex TV Show by Date: # - Jellyfin TV Show by Date: @@ -96,9 +98,9 @@ Plex TV Show by Date: = News | Only Recent: "BBC News": "https://www.youtube.com/@BBCNews" -############################################################################### -# Subscriptions nested under these will use the various prebuilt music presets - +################################################################### +# Subscriptions nested under these will use the various prebuilt +# music presets YouTube Releases: = Jazz: # Sets genre tag to "Jazz" "Thelonious Monk": "https://www.youtube.com/@theloniousmonk3870/releases" @@ -118,7 +120,7 @@ Bandcamp: = Lofi: "Emily Hopkins": "https://emilyharpist.bandcamp.com/" -############################################################################### +################################################################### # Can choose between: # - Plex Music Videos: # - Jellyfin Music Videos: @@ -188,8 +190,6 @@ for detailed information on all config fields. `ytdl-sub` can be installed on the following platforms. - [Docker Compose](https://ytdl-sub.readthedocs.io/en/latest/install.html#docker-compose_) - - [with CPU passthrough](https://ytdl-sub.readthedocs.io/en/latest/install.html#cpu-passthrough) - - [with GPU passthrough](https://ytdl-sub.readthedocs.io/en/latest/install.html#nvidia-gpu-passthrough) - [Docker CLI](https://ytdl-sub.readthedocs.io/en/latest/install.html#docker) - [Windows](https://ytdl-sub.readthedocs.io/en/latest/install.html#windows) - [Unraid](https://ytdl-sub.readthedocs.io/en/latest/install.html#unraid) @@ -199,12 +199,11 @@ for detailed information on all config fields. - [Local Install](https://ytdl-sub.readthedocs.io/en/latest/install.html#local-install) - [Local Docker Build](https://ytdl-sub.readthedocs.io/en/latest/install.html#local-docker-build) -### Docker Installs -Docker installs can be either headless or use the GUI image, which is the -[LSIO](https://www.linuxserver.io/) -[code-server image](https://hub.docker.com/r/linuxserver/code-server) -with `ytdl-sub` preinstalled. It is highly recommended to use this to manage -`ytdl-sub` from browser. +### Docker Installation +Docker installs can be either headless or use the GUI image, which comprises +[LSIO's](https://www.linuxserver.io/) +[code-server](https://hub.docker.com/r/linuxserver/code-server) +Docker image with `ytdl-sub` preinstalled. This is the recommended way to use ``ytdl-sub``. ![image](https://github.com/jmbannon/ytdl-sub/assets/10107080/c2aac8a1-5443-4345-b438-be4b17187c80) diff --git a/docs/config.rst b/docs/config.rst index da379040..ca8aa980 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -423,8 +423,9 @@ Source Variables Override Variables ------------------ -.. autoclass:: ytdl_sub.config.preset_options.OverridesVariables() +.. autoclass:: ytdl_sub.entries.variables.override_variables.OverrideVariables() :members: + :member-order: bysource ------------------------------------------------------------------------------- diff --git a/docs/install.rst b/docs/install.rst index 9b2fbc28..bea0667b 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -3,22 +3,62 @@ Install ``ytdl-sub`` can be installed on the following platforms. .. contents:: - :depth: 2 + :depth: 3 All installations require a 64-bit CPU. 32-bit is not supported. Docker Compose -------------- -The ytdl-sub docker image uses -`Linux Server's `_ -`base alpine image `_ -It looks, feels, and operates like other LinuxServer images. This is the -recommended way to use ytdl-sub. +The ytdl-sub Docker images use +`LSIO-based images `_ +and installs ytdl-sub on top. There are a few flavors to choose from. -The docker image is intended to be used as a console. For automating -``subscriptions.yaml`` downloads to pull new media, see +For automating ``subscriptions.yaml`` downloads to pull new media, see `this guide `_ -on how set up a cron job in the docker container. +on how set up a cron job in any of the docker containers. + +GUI +^^^^ + +The GUI image uses LSIO's +`code-server `_ +for its base image. More info on other code-server environment variables +can be found within its documentation. This is the recommended way to use ``ytdl-sub``. + +After starting, code-server will be running at http://localhost:8443/ + +.. code-block:: yaml + + services: + ytdl-sub: + image: ghcr.io/jmbannon/ytdl-sub-gui:latest + container_name: ytdl-sub + environment: + - PUID=1000 + - PGID=1000 + - TZ=America/Los_Angeles + volumes: + - :/config + - :/tv_shows # optional + - :/movies # optional + - :/music_videos # optional + - :/music # optional + ports: + - 8443:8443 + restart: unless-stopped + +Headless +^^^^^^^^^^ + +The headless image uses LSIO's +`baseimage-alpine `_ +for its base image. With this image, ``ytdl-sub`` is meant to be ran from console +via exec'ing into the image using the command: + +.. code-block:: bash + + docker exec -u abc -it ytdl-sub /bin/bash + .. code-block:: yaml @@ -39,46 +79,51 @@ on how set up a cron job in the docker container. - :/music # optional restart: unless-stopped -CPU Passthrough -^^^^^^^^^^^^^^^^^^^^^^ -For CPU passthrough, you must use the ``ytdl-sub`` Ubuntu version with the following additions: +Passthrough +^^^^^^^^^^^ +For CPU or GPU passthrough, you must use either the GUI image or the headless Ubuntu image +``ghcr.io/jmbannon/ytdl-sub:ubuntu-latest``. + +The docker-compose examples use the GUI image. + +CPU +____ .. code-block:: yaml services: ytdl-sub: - image: ghcr.io/jmbannon/ytdl-sub:ubuntu-latest + image: ghcr.io/jmbannon/ytdl-sub-gui:latest container_name: ytdl-sub environment: - PUID=1000 - PGID=1000 - TZ=America/Los_Angeles - - DOCKER_MODS=linuxserver/mods:universal-cron volumes: - :/config - :/tv_shows # optional - :/movies # optional - :/music_videos # optional - :/music # optional + ports: + - 8443:8443 devices: - /dev/dri:/dev/dri # CPU passthrough restart: unless-stopped -Nvidia GPU Passthrough -^^^^^^^^^^^^^^^^^^^^^^ -For GPU passthrough, you must use the ``ytdl-sub`` Ubuntu version with the following additions: +GPU +____ .. code-block:: yaml services: ytdl-sub: - image: ghcr.io/jmbannon/ytdl-sub:ubuntu-latest + image: ghcr.io/jmbannon/ytdl-sub-gui:latest container_name: ytdl-sub environment: - PUID=1000 - PGID=1000 - TZ=America/Los_Angeles - - DOCKER_MODS=linuxserver/mods:universal-cron - NVIDIA_DRIVER_CAPABILITIES=all # Nvidia ENV args - NVIDIA_VISIBLE_DEVICES=all volumes: @@ -87,6 +132,8 @@ For GPU passthrough, you must use the ``ytdl-sub`` Ubuntu version with the follo - :/movies # optional - :/music_videos # optional - :/music # optional + ports: + - 8443:8443 deploy: resources: reservations: @@ -103,14 +150,14 @@ Docker -e PUID=1000 \ -e PGID=1000 \ -e TZ=America/Los_Angeles \ - -e DOCKER_MODS=linuxserver/mods:universal-cron \ + -p 8443:8443 \ -v :/config \ -v :/tv_shows \ -v :/movies \ -v :/music_videos \ -v :/music \ --restart unless-stopped \ - ghcr.io/jmbannon/ytdl-sub:latest + ghcr.io/jmbannon/ytdl-sub-gui:latest Windows -------------- diff --git a/src/ytdl_sub/config/preset_options.py b/src/ytdl_sub/config/preset_options.py index c159fa4d..ff07ce92 100644 --- a/src/ytdl_sub/config/preset_options.py +++ b/src/ytdl_sub/config/preset_options.py @@ -9,7 +9,7 @@ from yt_dlp.utils import sanitize_filename from ytdl_sub.config.defaults import DEFAULT_DOWNLOAD_ARCHIVE_NAME from ytdl_sub.entries.entry import Entry -from ytdl_sub.subscriptions.utils import SUBSCRIPTION_NAME +from ytdl_sub.entries.variables.override_variables import SUBSCRIPTION_NAME from ytdl_sub.utils.exceptions import ValidationException from ytdl_sub.validators.file_path_validators import OverridesStringFormatterFilePathValidator from ytdl_sub.validators.file_path_validators import StringFormatterFileNameValidator diff --git a/src/ytdl_sub/entries/variables/override_variables.py b/src/ytdl_sub/entries/variables/override_variables.py new file mode 100644 index 00000000..8a885f83 --- /dev/null +++ b/src/ytdl_sub/entries/variables/override_variables.py @@ -0,0 +1,57 @@ +SUBSCRIPTION_NAME = "subscription_name" +SUBSCRIPTION_VALUE = "subscription_value" + + +class OverrideVariables: + @classmethod + def subscription_name(cls) -> str: + """ + Name of the subscription + """ + return SUBSCRIPTION_NAME + + @classmethod + def subscription_value(cls) -> str: + """ + For subscriptions in the form of + + .. code-block:: yaml + + "Subscription Name": "https://..." + + ``subscription_value`` gets set to ``https://...``. + """ + return SUBSCRIPTION_VALUE + + @classmethod + def subscription_indent_i(cls, index: int) -> str: + """ + For subscriptions in the form of + + .. code-block:: yaml + + Preset | = Indent Value 1: + = Indent Value 2: + "Subscription Name": "https://..." + + ``subscription_indent_1`` and ``subscription_indent_2`` get set to + ``Indent Value 1`` and ``Indent Value 2``. + """ + return f"subscription_indent_{index + 1}" + + @classmethod + def subscription_value_i(cls, index: int) -> str: + """ + For subscriptions in the form of + + .. code-block:: yaml + + "Subscription Name": + - "https://url1.com/..." + - "https://url2.com/..." + + ``subscription_value_1`` and ``subscription_value_2`` get set to ``https://url1.com/...`` + and ``https://url2.com/...``. Note that ``subscription_value_1`` also gets set to + ``subscription_value``. + """ + return f"subscription_value_{index + 1}" diff --git a/src/ytdl_sub/subscriptions/subscription_validators.py b/src/ytdl_sub/subscriptions/subscription_validators.py index 007b2b9a..678a9758 100644 --- a/src/ytdl_sub/subscriptions/subscription_validators.py +++ b/src/ytdl_sub/subscriptions/subscription_validators.py @@ -9,10 +9,9 @@ from typing import final from ytdl_sub.config.config_file import ConfigFile from ytdl_sub.config.preset_options import Overrides -from ytdl_sub.subscriptions.utils import SUBSCRIPTION_NAME -from ytdl_sub.subscriptions.utils import SUBSCRIPTION_VALUE -from ytdl_sub.subscriptions.utils import subscription_indent_variable_name -from ytdl_sub.subscriptions.utils import subscription_list_variable_name +from ytdl_sub.entries.variables.override_variables import SUBSCRIPTION_NAME +from ytdl_sub.entries.variables.override_variables import SUBSCRIPTION_VALUE +from ytdl_sub.entries.variables.override_variables import OverrideVariables from ytdl_sub.validators.string_formatter_validators import DictFormatterValidator from ytdl_sub.validators.validators import DictValidator from ytdl_sub.validators.validators import StringListValidator @@ -33,7 +32,7 @@ class SubscriptionOutput(Validator, ABC): indent overrides to merge with the preset dict's overrides """ return { - subscription_indent_variable_name(i): self._indent_overrides[i] + OverrideVariables.subscription_indent_i(i): self._indent_overrides[i] for i in range(len(self._indent_overrides)) } @@ -159,7 +158,9 @@ class SubscriptionListValuesValidator(SubscriptionLeafValidator, StringListValid if idx == 0: self._overrides_to_add[SUBSCRIPTION_VALUE] = list_value.value - self._overrides_to_add[subscription_list_variable_name(index=idx)] = list_value.value + self._overrides_to_add[ + OverrideVariables.subscription_value_i(index=idx) + ] = list_value.value class SubscriptionWithOverridesValidator(SubscriptionLeafValidator, DictFormatterValidator): diff --git a/src/ytdl_sub/subscriptions/utils.py b/src/ytdl_sub/subscriptions/utils.py index 3e2c9a00..b82620a0 100644 --- a/src/ytdl_sub/subscriptions/utils.py +++ b/src/ytdl_sub/subscriptions/utils.py @@ -1,33 +1,2 @@ -SUBSCRIPTION_NAME = "subscription_name" -SUBSCRIPTION_VALUE = "subscription_value" - # Key used in configs, should delete at some point SUBSCRIPTION_VALUE_CONFIG_KEY = "subscription_value" - - -def subscription_indent_variable_name(index: int) -> str: - """ - Parameters - ---------- - index - 0th-based index - - Returns - ------- - subscription_index_i, where i is 1-based index - """ - return f"subscription_indent_{index + 1}" - - -def subscription_list_variable_name(index: int) -> str: - """ - Parameters - ---------- - index - 0th-based index - - Returns - ------- - subscription_value_i, where i is 1-based index - """ - return f"subscription_value_{index + 1}"