fix override docs

This commit is contained in:
Jesse Bannon 2023-11-02 23:13:51 -07:00
parent d68dd89d88
commit 2ebfb2abfd
7 changed files with 148 additions and 74 deletions

View file

@ -67,8 +67,10 @@ __preset__:
ytdl_options: ytdl_options:
cookiefile: "/config/cookie.txt" 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: # Can choose between:
# - Plex TV Show by Date: # - Plex TV Show by Date:
# - Jellyfin TV Show by Date: # - Jellyfin TV Show by Date:
@ -96,9 +98,9 @@ Plex TV Show by Date:
= News | Only Recent: = News | Only Recent:
"BBC News": "https://www.youtube.com/@BBCNews" "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: YouTube Releases:
= Jazz: # Sets genre tag to "Jazz" = Jazz: # Sets genre tag to "Jazz"
"Thelonious Monk": "https://www.youtube.com/@theloniousmonk3870/releases" "Thelonious Monk": "https://www.youtube.com/@theloniousmonk3870/releases"
@ -118,7 +120,7 @@ Bandcamp:
= Lofi: = Lofi:
"Emily Hopkins": "https://emilyharpist.bandcamp.com/" "Emily Hopkins": "https://emilyharpist.bandcamp.com/"
############################################################################### ###################################################################
# Can choose between: # Can choose between:
# - Plex Music Videos: # - Plex Music Videos:
# - Jellyfin 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. `ytdl-sub` can be installed on the following platforms.
- [Docker Compose](https://ytdl-sub.readthedocs.io/en/latest/install.html#docker-compose_) - [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) - [Docker CLI](https://ytdl-sub.readthedocs.io/en/latest/install.html#docker)
- [Windows](https://ytdl-sub.readthedocs.io/en/latest/install.html#windows) - [Windows](https://ytdl-sub.readthedocs.io/en/latest/install.html#windows)
- [Unraid](https://ytdl-sub.readthedocs.io/en/latest/install.html#unraid) - [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 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) - [Local Docker Build](https://ytdl-sub.readthedocs.io/en/latest/install.html#local-docker-build)
### Docker Installs ### Docker Installation
Docker installs can be either headless or use the GUI image, which is the Docker installs can be either headless or use the GUI image, which comprises
[LSIO](https://www.linuxserver.io/) [LSIO's](https://www.linuxserver.io/)
[code-server image](https://hub.docker.com/r/linuxserver/code-server) [code-server](https://hub.docker.com/r/linuxserver/code-server)
with `ytdl-sub` preinstalled. It is highly recommended to use this to manage Docker image with `ytdl-sub` preinstalled. This is the recommended way to use ``ytdl-sub``.
`ytdl-sub` from browser.
![image](https://github.com/jmbannon/ytdl-sub/assets/10107080/c2aac8a1-5443-4345-b438-be4b17187c80) ![image](https://github.com/jmbannon/ytdl-sub/assets/10107080/c2aac8a1-5443-4345-b438-be4b17187c80)

View file

@ -423,8 +423,9 @@ Source Variables
Override Variables Override Variables
------------------ ------------------
.. autoclass:: ytdl_sub.config.preset_options.OverridesVariables() .. autoclass:: ytdl_sub.entries.variables.override_variables.OverrideVariables()
:members: :members:
:member-order: bysource
------------------------------------------------------------------------------- -------------------------------------------------------------------------------

View file

@ -3,22 +3,62 @@ Install
``ytdl-sub`` can be installed on the following platforms. ``ytdl-sub`` can be installed on the following platforms.
.. contents:: .. contents::
:depth: 2 :depth: 3
All installations require a 64-bit CPU. 32-bit is not supported. All installations require a 64-bit CPU. 32-bit is not supported.
Docker Compose Docker Compose
-------------- --------------
The ytdl-sub docker image uses The ytdl-sub Docker images use
`Linux Server's <https://www.linuxserver.io/>`_ `LSIO-based images <https://www.linuxserver.io/>`_
`base alpine image <https://github.com/linuxserver/docker-baseimage-alpine/>`_ and installs ytdl-sub on top. There are a few flavors to choose from.
It looks, feels, and operates like other LinuxServer images. This is the
recommended way to use ytdl-sub.
The docker image is intended to be used as a console. For automating For automating ``subscriptions.yaml`` downloads to pull new media, see
``subscriptions.yaml`` downloads to pull new media, see
`this guide <https://github.com/jmbannon/ytdl-sub/wiki/7.-Automate-Downloading-New-Content-Using-Your-Configs/>`_ `this guide <https://github.com/jmbannon/ytdl-sub/wiki/7.-Automate-Downloading-New-Content-Using-Your-Configs/>`_
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 <https://hub.docker.com/r/linuxserver/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:
- <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
ports:
- 8443:8443
restart: unless-stopped
Headless
^^^^^^^^^^
The headless image uses LSIO's
`baseimage-alpine <https://github.com/linuxserver/docker-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 .. code-block:: yaml
@ -39,46 +79,51 @@ on how set up a cron job in the docker container.
- <path/to/music>:/music # optional - <path/to/music>:/music # optional
restart: unless-stopped restart: unless-stopped
CPU Passthrough Passthrough
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^
For CPU passthrough, you must use the ``ytdl-sub`` Ubuntu version with the following additions: 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 .. code-block:: yaml
services: services:
ytdl-sub: ytdl-sub:
image: ghcr.io/jmbannon/ytdl-sub:ubuntu-latest image: ghcr.io/jmbannon/ytdl-sub-gui:latest
container_name: ytdl-sub container_name: ytdl-sub
environment: environment:
- PUID=1000 - PUID=1000
- PGID=1000 - PGID=1000
- TZ=America/Los_Angeles - TZ=America/Los_Angeles
- DOCKER_MODS=linuxserver/mods:universal-cron
volumes: volumes:
- <path/to/ytdl-sub/config>:/config - <path/to/ytdl-sub/config>:/config
- <path/to/tv_shows>:/tv_shows # optional - <path/to/tv_shows>:/tv_shows # optional
- <path/to/movies>:/movies # optional - <path/to/movies>:/movies # optional
- <path/to/music_videos>:/music_videos # optional - <path/to/music_videos>:/music_videos # optional
- <path/to/music>:/music # optional - <path/to/music>:/music # optional
ports:
- 8443:8443
devices: devices:
- /dev/dri:/dev/dri # CPU passthrough - /dev/dri:/dev/dri # CPU passthrough
restart: unless-stopped restart: unless-stopped
Nvidia GPU Passthrough GPU
^^^^^^^^^^^^^^^^^^^^^^ ____
For GPU passthrough, you must use the ``ytdl-sub`` Ubuntu version with the following additions:
.. code-block:: yaml .. code-block:: yaml
services: services:
ytdl-sub: ytdl-sub:
image: ghcr.io/jmbannon/ytdl-sub:ubuntu-latest image: ghcr.io/jmbannon/ytdl-sub-gui:latest
container_name: ytdl-sub container_name: ytdl-sub
environment: environment:
- PUID=1000 - PUID=1000
- PGID=1000 - PGID=1000
- TZ=America/Los_Angeles - TZ=America/Los_Angeles
- DOCKER_MODS=linuxserver/mods:universal-cron
- NVIDIA_DRIVER_CAPABILITIES=all # Nvidia ENV args - NVIDIA_DRIVER_CAPABILITIES=all # Nvidia ENV args
- NVIDIA_VISIBLE_DEVICES=all - NVIDIA_VISIBLE_DEVICES=all
volumes: volumes:
@ -87,6 +132,8 @@ For GPU passthrough, you must use the ``ytdl-sub`` Ubuntu version with the follo
- <path/to/movies>:/movies # optional - <path/to/movies>:/movies # optional
- <path/to/music_videos>:/music_videos # optional - <path/to/music_videos>:/music_videos # optional
- <path/to/music>:/music # optional - <path/to/music>:/music # optional
ports:
- 8443:8443
deploy: deploy:
resources: resources:
reservations: reservations:
@ -103,14 +150,14 @@ Docker
-e PUID=1000 \ -e PUID=1000 \
-e PGID=1000 \ -e PGID=1000 \
-e TZ=America/Los_Angeles \ -e TZ=America/Los_Angeles \
-e DOCKER_MODS=linuxserver/mods:universal-cron \ -p 8443:8443 \
-v <path/to/ytdl-sub/config>:/config \ -v <path/to/ytdl-sub/config>:/config \
-v <OPTIONAL/path/to/tv_shows>:/tv_shows \ -v <OPTIONAL/path/to/tv_shows>:/tv_shows \
-v <OPTIONAL/path/to/movies>:/movies \ -v <OPTIONAL/path/to/movies>:/movies \
-v <OPTIONAL/path/to/music_videos>:/music_videos \ -v <OPTIONAL/path/to/music_videos>:/music_videos \
-v <OPTIONAL/path/to/music>:/music \ -v <OPTIONAL/path/to/music>:/music \
--restart unless-stopped \ --restart unless-stopped \
ghcr.io/jmbannon/ytdl-sub:latest ghcr.io/jmbannon/ytdl-sub-gui:latest
Windows Windows
-------------- --------------

View file

@ -9,7 +9,7 @@ from yt_dlp.utils import sanitize_filename
from ytdl_sub.config.defaults import DEFAULT_DOWNLOAD_ARCHIVE_NAME from ytdl_sub.config.defaults import DEFAULT_DOWNLOAD_ARCHIVE_NAME
from ytdl_sub.entries.entry import Entry 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.utils.exceptions import ValidationException
from ytdl_sub.validators.file_path_validators import OverridesStringFormatterFilePathValidator from ytdl_sub.validators.file_path_validators import OverridesStringFormatterFilePathValidator
from ytdl_sub.validators.file_path_validators import StringFormatterFileNameValidator from ytdl_sub.validators.file_path_validators import StringFormatterFileNameValidator

View file

@ -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}"

View file

@ -9,10 +9,9 @@ from typing import final
from ytdl_sub.config.config_file import ConfigFile from ytdl_sub.config.config_file import ConfigFile
from ytdl_sub.config.preset_options import Overrides from ytdl_sub.config.preset_options import Overrides
from ytdl_sub.subscriptions.utils import SUBSCRIPTION_NAME from ytdl_sub.entries.variables.override_variables import SUBSCRIPTION_NAME
from ytdl_sub.subscriptions.utils import SUBSCRIPTION_VALUE from ytdl_sub.entries.variables.override_variables import SUBSCRIPTION_VALUE
from ytdl_sub.subscriptions.utils import subscription_indent_variable_name from ytdl_sub.entries.variables.override_variables import OverrideVariables
from ytdl_sub.subscriptions.utils import subscription_list_variable_name
from ytdl_sub.validators.string_formatter_validators import DictFormatterValidator from ytdl_sub.validators.string_formatter_validators import DictFormatterValidator
from ytdl_sub.validators.validators import DictValidator from ytdl_sub.validators.validators import DictValidator
from ytdl_sub.validators.validators import StringListValidator 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 indent overrides to merge with the preset dict's overrides
""" """
return { 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)) for i in range(len(self._indent_overrides))
} }
@ -159,7 +158,9 @@ class SubscriptionListValuesValidator(SubscriptionLeafValidator, StringListValid
if idx == 0: if idx == 0:
self._overrides_to_add[SUBSCRIPTION_VALUE] = list_value.value 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): class SubscriptionWithOverridesValidator(SubscriptionLeafValidator, DictFormatterValidator):

View file

@ -1,33 +1,2 @@
SUBSCRIPTION_NAME = "subscription_name"
SUBSCRIPTION_VALUE = "subscription_value"
# Key used in configs, should delete at some point # Key used in configs, should delete at some point
SUBSCRIPTION_VALUE_CONFIG_KEY = "subscription_value" 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}"