[DOCS] document file __preset__
This commit is contained in:
parent
da22c9a608
commit
b30a8e3e17
2 changed files with 31 additions and 10 deletions
|
|
@ -22,7 +22,7 @@ configuration
|
||||||
The ``configuration`` section contains app-wide configs applied to all presets
|
The ``configuration`` section contains app-wide configs applied to all presets
|
||||||
and subscriptions.
|
and subscriptions.
|
||||||
|
|
||||||
.. autoclass:: ytdl_sub.config.config_file.ConfigOptions()
|
.. autoclass:: ytdl_sub.config.config_validator.ConfigOptions()
|
||||||
:members:
|
:members:
|
||||||
:member-order: bysource
|
:member-order: bysource
|
||||||
|
|
||||||
|
|
@ -264,15 +264,16 @@ channel or playlist.
|
||||||
The only difference between a ``subscription`` and ``preset`` is that the subscription
|
The only difference between a ``subscription`` and ``preset`` is that the subscription
|
||||||
must have all required fields and ``{variables}`` defined so it can perform a download.
|
must have all required fields and ``{variables}`` defined so it can perform a download.
|
||||||
|
|
||||||
Below is an example that downloads YouTube videos:
|
Below is an example that downloads a YouTube playlist:
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
:caption: config.yaml
|
:caption: config.yaml
|
||||||
|
|
||||||
presets:
|
presets:
|
||||||
playlist_preset_ex:
|
playlist_preset_ex:
|
||||||
youtube:
|
download:
|
||||||
download_strategy: "playlist"
|
download_strategy: "url"
|
||||||
|
url: "{url}"
|
||||||
output_options:
|
output_options:
|
||||||
output_directory: "{output_directory}/{playlist_name}"
|
output_directory: "{output_directory}/{playlist_name}"
|
||||||
file_name: "{playlist_name}.{title}.{ext}"
|
file_name: "{playlist_name}.{title}.{ext}"
|
||||||
|
|
@ -284,15 +285,33 @@ Below is an example that downloads YouTube videos:
|
||||||
|
|
||||||
my_subscription_name:
|
my_subscription_name:
|
||||||
preset: "playlist_preset_ex"
|
preset: "playlist_preset_ex"
|
||||||
youtube:
|
|
||||||
playlist_url: "https://youtube.com/playlist?list=UCsvn_Po0SmunchJYtttWpOxMg"
|
|
||||||
overrides:
|
overrides:
|
||||||
playlist_name: "diy-playlist"
|
playlist_name: "diy-playlist"
|
||||||
|
url: "https://youtube.com/playlist?list=UCsvn_Po0SmunchJYtttWpOxMg"
|
||||||
|
|
||||||
Our preset ``playlist_preset_ex`` uses the `YouTube Playlist`_ download strategy, and defines two
|
Our preset ``playlist_preset_ex`` defines three
|
||||||
custom variables: ``{output_directory}`` and ``{playlist_name}``. The subscription sets
|
custom variables: ``{output_directory}``, ``{playlist_name}``, and ``{url}``. The subscription sets
|
||||||
the `parent preset`_ to ``playlist_preset_ex``, and must define the ``playlist_url`` field and
|
the `parent preset`_ to ``playlist_preset_ex``, and must define the variables ``{playlist_name}``
|
||||||
the ``{playlist_name}`` variable since the preset did not.
|
and ``{url}`` since the preset did not.
|
||||||
|
|
||||||
|
File Preset
|
||||||
|
^^^^^^^^^^^
|
||||||
|
You can apply a preset to all subscriptions in the ``subscription.yaml`` file
|
||||||
|
by using the file-wide ``__preset__``:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
:caption: subscription.yaml
|
||||||
|
|
||||||
|
__preset__:
|
||||||
|
preset: "playlist_preset_ex"
|
||||||
|
|
||||||
|
my_subscription_name:
|
||||||
|
overrides:
|
||||||
|
url: "https://youtube.com/playlist?list=UCsvn_Po0SmunchJYtttWpOxMg"
|
||||||
|
playlist_name: "diy-playlist"
|
||||||
|
|
||||||
|
This ``subscription.yaml`` is equivalent to the one above it because all
|
||||||
|
subscriptions automatically set ``__preset__`` as a `parent preset`_.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,8 @@ class Subscription(SubscriptionDownload):
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_file_path(cls, config: ConfigFile, subscription_path: str) -> List["Subscription"]:
|
def from_file_path(cls, config: ConfigFile, subscription_path: str) -> List["Subscription"]:
|
||||||
"""
|
"""
|
||||||
|
Loads subscriptions from a file and applies __preset__ to all of them if present.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
config:
|
config:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue