plugins WIP

This commit is contained in:
Jesse Bannon 2023-12-28 13:09:43 -08:00
parent 76703f7e7c
commit 724faaac9e
6 changed files with 305 additions and 204 deletions

View file

@ -6,25 +6,29 @@ audio_extract
------------- -------------
Extracts audio from a video file. Extracts audio from a video file.
Usage: :Usage:
.. code-block:: yaml .. code-block:: yaml
presets: audio_extract:
my_example_preset: codec: "mp3"
audio_extract: quality: 128
codec: "mp3"
quality: 128
codec ``codec``
~~~~~
The codec to output after extracting the audio. Supported codecs are aac, flac, mp3, m4a, :expected type: String
opus, vorbis, wav, and best to grab the best possible format at runtime. :description:
The codec to output after extracting the audio. Supported codecs are aac, flac, mp3, m4a,
opus, vorbis, wav, and best to grab the best possible format at runtime.
``quality``
:expected type: Float
:description:
Optional. Specify ffmpeg audio quality. Insert a value between ``0`` (better) and ``9``
(worse) for variable bitrate, or a specific bitrate like ``128`` for 128k.
quality
~~~~~~~
Optional. Specify ffmpeg audio quality. Insert a value between ``0`` (better) and ``9``
(worse) for variable bitrate, or a specific bitrate like ``128`` for 128k.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
@ -33,87 +37,116 @@ chapters
Embeds chapters to video files if they are present. Additional options to add SponsorBlock Embeds chapters to video files if they are present. Additional options to add SponsorBlock
chapters and remove specific ones. Can also remove chapters using regex. chapters and remove specific ones. Can also remove chapters using regex.
Usage: :usage:
.. code-block:: yaml .. code-block:: yaml
presets: chapters:
my_example_preset: # Embedded Chapter Fields
chapters: embed_chapters: True
# Embedded Chapter Fields allow_chapters_from_comments: False
embed_chapters: True remove_chapters_regex:
allow_chapters_from_comments: False - "Intro"
remove_chapters_regex: - "Outro"
- "Intro"
- "Outro"
# Sponsorblock Fields # Sponsorblock Fields
sponsorblock_categories: sponsorblock_categories:
- "outro" - "outro"
- "selfpromo" - "selfpromo"
- "preview" - "preview"
- "interaction" - "interaction"
- "sponsor" - "sponsor"
- "music_offtopic" - "music_offtopic"
- "intro" - "intro"
remove_sponsorblock_categories: "all" remove_sponsorblock_categories: "all"
force_key_frames: False force_key_frames: False
allow_chapters_from_comments ``allow_chapters_from_comments``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Optional. If chapters do not exist in the video/description itself, attempt to scrape
comments to find the chapters. Defaults to False.
embed_chapters :expected type: Optional[Boolean]
~~~~~~~~~~~~~~ :description:
Optional. Embed chapters into the file. Defaults to True. Defaults to False. If chapters do not exist in the video/description itself, attempt to
scrape comments to find the chapters.
force_key_frames
~~~~~~~~~~~~~~~~
Optional. Force keyframes at cuts when removing sections. This is slow due to needing a
re-encode, but the resulting video may have fewer artifacts around the cuts. Defaults to
False.
remove_chapters_regex ``embed_chapters``
~~~~~~~~~~~~~~~~~~~~~
Optional. List of regex patterns to match chapter titles against and remove them from the
entry.
remove_sponsorblock_categories :expected type: Optional[Boolean]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :description:
Optional. List of SponsorBlock categories to remove from the output file. Can only remove Defaults to True. Embed chapters into the file.
categories that are specified in ``sponsorblock_categories`` or "all", which removes
everything specified in ``sponsorblock_categories``.
``force_key_frames``
:expected type: Optional[Boolean]
:description:
Defaults to False. Force keyframes at cuts when removing sections. This is slow due to
needing a re-encode, but the resulting video may have fewer artifacts around the cuts.
``remove_chapters_regex``
:expected type: Optional[List[RegexString]
:description:
List of regex patterns to match chapter titles against and remove them from the
entry.
``remove_sponsorblock_categories``
:expected type: Optional[List[String]]
:description:
List of SponsorBlock categories to remove from the output file. Can only remove
categories that are specified in ``sponsorblock_categories`` or "all", which removes
everything specified in ``sponsorblock_categories``.
``sponsorblock_categories``
:expected type: Optional[List[String]]
:description:
List of SponsorBlock categories to embed as chapters. Supports "sponsor",
"intro", "outro", "selfpromo", "preview", "filler", "interaction", "music_offtopic",
"poi_highlight", or "all" to include all categories.
sponsorblock_categories
~~~~~~~~~~~~~~~~~~~~~~~
Optional. List of SponsorBlock categories to embed as chapters. Supports "sponsor",
"intro", "outro", "selfpromo", "preview", "filler", "interaction", "music_offtopic",
"poi_highlight", or "all" to include all categories.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
date_range date_range
---------- ----------
Only download files uploaded within the specified date range. Only download files uploaded within the specified date range.
Dates must adhere to a yt-dlp datetime. From their docs:
Usage: .. code-block:: Markdown
A string in the format YYYYMMDD or
(now|today|yesterday|date)[+-][0-9](microsecond|second|minute|hour|day|week|month|year)(s)
Valid examples are ``now-2weeks`` or ``20200101``. Can use override variables in this.
Note that yt-dlp will round times to the closest day, meaning that `day` is the lowest
granularity possible.
:usage:
.. code-block:: yaml .. code-block:: yaml
presets: date_range:
my_example_preset: before: "now"
date_range: after: "today-2weeks"
before: "now"
after: "today-2weeks"
after ``after``
~~~~~
Optional. Only download videos after this datetime. :expected type: Optional[OverridesFormatter]
:description:
Only download videos before this datetime.
``before``
:expected type: Optional[OverridesFormatter]
:description:
Only download videos before this datetime.
before
~~~~~~
Optional. Only download videos before this datetime.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
@ -159,21 +192,23 @@ Supports custom ffmpeg conversions:
-acodec copy -acodec copy
-scodec mov_text -scodec mov_text
convert_to ``convert_to``
~~~~~~~~~~
Convert to a desired file type. Supports: Convert to a desired file type. Supports:
* Video: avi, flv, mkv, mov, mp4, webm * Video: avi, flv, mkv, mov, mp4, webm
* Audio: aac, flac, mp3, m4a, opus, vorbis, wav * Audio: aac, flac, mp3, m4a, opus, vorbis, wav
convert_with
~~~~~~~~~~~~ ``convert_with``
Optional. Supports ``yt-dlp`` and ``ffmpeg``. ``yt-dlp`` will convert files within Optional. Supports ``yt-dlp`` and ``ffmpeg``. ``yt-dlp`` will convert files within
yt-dlp whereas ``ffmpeg`` specifies it will be converted using a custom command specified yt-dlp whereas ``ffmpeg`` specifies it will be converted using a custom command specified
with ``ffmpeg_post_process_args``. Defaults to ``yt-dlp``. with ``ffmpeg_post_process_args``. Defaults to ``yt-dlp``.
ffmpeg_post_process_args
~~~~~~~~~~~~~~~~~~~~~~~~ ``ffmpeg_post_process_args``
Optional. ffmpeg args to post-process an entry file with. The args will be inserted in the Optional. ffmpeg args to post-process an entry file with. The args will be inserted in the
form of: form of:
@ -184,6 +219,7 @@ form of:
The output file will use the extension specified in ``convert_to``. Post-processing args The output file will use the extension specified in ``convert_to``. Post-processing args
can still be set with ``convert_with`` set to ``yt-dlp``. can still be set with ``convert_with`` set to ``yt-dlp``.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
filter_exclude filter_exclude
@ -245,10 +281,11 @@ Usage:
my_example_preset: my_example_preset:
format: "(bv*[height<=1080]+bestaudio/best[height<=1080])" format: "(bv*[height<=1080]+bestaudio/best[height<=1080])"
format ``format``
~~~~~~
yt-dlp format, uses same syntax as yt-dlp. yt-dlp format, uses same syntax as yt-dlp.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
match_filters match_filters
@ -280,12 +317,13 @@ Supports one or multiple filters:
# - "age_limit<?18" # - "age_limit<?18"
# - "availability=?public" # - "availability=?public"
filters ``filters``
~~~~~~~
The filters themselves. If used multiple times, the filter matches if at least one of the The filters themselves. If used multiple times, the filter matches if at least one of the
conditions are met. For logical AND's between match filters, use the ``&`` operator in conditions are met. For logical AND's between match filters, use the ``&`` operator in
a single match filter. These are applied when gathering metadata. a single match filter. These are applied when gathering metadata.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
music_tags music_tags
@ -316,15 +354,17 @@ Usage:
- "{artist}" - "{artist}"
- "ytdl-sub" - "ytdl-sub"
embed_thumbnail ``embed_thumbnail``
~~~~~~~~~~~~~~~
Optional. Whether to embed the thumbnail into the audio file. Optional. Whether to embed the thumbnail into the audio file.
tags
~~~~ ``tags``
Key, values of tag names, tag values. Supports source and override variables. Key, values of tag names, tag values. Supports source and override variables.
Supports lists which will get written to MP3s as id3v2.4 multi-tags. Supports lists which will get written to MP3s as id3v2.4 multi-tags.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
nfo_tags nfo_tags
@ -349,18 +389,20 @@ Usage:
# optional # optional
kodi_safe: False kodi_safe: False
kodi_safe ``kodi_safe``
~~~~~~~~~
Optional. Kodi does not support > 3-byte unicode characters, which include emojis and some Optional. Kodi does not support > 3-byte unicode characters, which include emojis and some
foreign language characters. Setting this to True will replace those characters with '□'. foreign language characters. Setting this to True will replace those characters with '□'.
Defaults to False. Defaults to False.
nfo_name
~~~~~~~~ ``nfo_name``
The NFO file name. The NFO file name.
nfo_root
~~~~~~~~ ``nfo_root``
The root tag of the NFO's XML. In the usage above, it would look like The root tag of the NFO's XML. In the usage above, it would look like
.. code-block:: xml .. code-block:: xml
@ -369,8 +411,9 @@ The root tag of the NFO's XML. In the usage above, it would look like
<episodedetails> <episodedetails>
</episodedetails> </episodedetails>
tags
~~~~ ``tags``
Tags within the nfo_root tag. In the usage above, it would look like Tags within the nfo_root tag. In the usage above, it would look like
.. code-block:: xml .. code-block:: xml
@ -403,6 +446,7 @@ Which translates to
<genre>Comedy</genre> <genre>Comedy</genre>
<genre>Drama</genre> <genre>Drama</genre>
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
output_directory_nfo_tags output_directory_nfo_tags
@ -426,18 +470,20 @@ Usage:
# optional # optional
kodi_safe: False kodi_safe: False
kodi_safe ``kodi_safe``
~~~~~~~~~
Optional. Kodi does not support > 3-byte unicode characters, which include emojis and some Optional. Kodi does not support > 3-byte unicode characters, which include emojis and some
foreign language characters. Setting this to True will replace those characters with '□'. foreign language characters. Setting this to True will replace those characters with '□'.
Defaults to False. Defaults to False.
nfo_name
~~~~~~~~ ``nfo_name``
The NFO file name. The NFO file name.
nfo_root
~~~~~~~~ ``nfo_root``
The root tag of the NFO's XML. In the usage above, it would look like The root tag of the NFO's XML. In the usage above, it would look like
.. code-block:: xml .. code-block:: xml
@ -446,8 +492,9 @@ The root tag of the NFO's XML. In the usage above, it would look like
<tvshow> <tvshow>
</tvshow> </tvshow>
tags
~~~~ ``tags``
Tags within the nfo_root tag. In the usage above, it would look like Tags within the nfo_root tag. In the usage above, it would look like
.. code-block:: xml .. code-block:: xml
@ -478,6 +525,7 @@ Which translates to
<genre>Comedy</genre> <genre>Comedy</genre>
<genre>Drama</genre> <genre>Drama</genre>
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
output_options output_options
@ -503,47 +551,53 @@ Usage:
keep_files_before: now keep_files_before: now
keep_files_after: 19000101 keep_files_after: 19000101
download_archive_name ``download_archive_name``
~~~~~~~~~~~~~~~~~~~~~
Optional. The file name to store a subscriptions download archive placed relative to Optional. The file name to store a subscriptions download archive placed relative to
the output directory. Defaults to ``.ytdl-sub-{subscription_name}-download-archive.json`` the output directory. Defaults to ``.ytdl-sub-{subscription_name}-download-archive.json``
file_name
~~~~~~~~~ ``file_name``
Required. The file name for the media file. This can include directories such as Required. The file name for the media file. This can include directories such as
``"Season {upload_year}/{title}.{ext}"``, and will be placed in the output directory. ``"Season {upload_year}/{title}.{ext}"``, and will be placed in the output directory.
info_json_name
~~~~~~~~~~~~~~ ``info_json_name``
Optional. The file name for the media's info json file. This can include directories such Optional. The file name for the media's info json file. This can include directories such
as ``"Season {upload_year}/{title}.{info_json_ext}"``, and will be placed in the output as ``"Season {upload_year}/{title}.{info_json_ext}"``, and will be placed in the output
directory. Can be set to empty string or `null` to disable info json writes. directory. Can be set to empty string or `null` to disable info json writes.
keep_files_after
~~~~~~~~~~~~~~~~ ``keep_files_after``
Optional. Requires ``maintain_download_archive`` set to True. Optional. Requires ``maintain_download_archive`` set to True.
Only keeps files that are uploaded after this datetime. By default, ytdl-sub will keep Only keeps files that are uploaded after this datetime. By default, ytdl-sub will keep
files after ``19000101``, which implies all files. Can be used in conjunction with files after ``19000101``, which implies all files. Can be used in conjunction with
``keep_max_files``. ``keep_max_files``.
keep_files_before
~~~~~~~~~~~~~~~~~ ``keep_files_before``
Optional. Requires ``maintain_download_archive`` set to True. Optional. Requires ``maintain_download_archive`` set to True.
Only keeps files that are uploaded before this datetime. By default, ytdl-sub will keep Only keeps files that are uploaded before this datetime. By default, ytdl-sub will keep
files before ``now``, which implies all files. Can be used in conjunction with files before ``now``, which implies all files. Can be used in conjunction with
``keep_max_files``. ``keep_max_files``.
keep_max_files
~~~~~~~~~~~~~~ ``keep_max_files``
Optional. Requires ``maintain_download_archive`` set to True. Optional. Requires ``maintain_download_archive`` set to True.
Only keeps N most recently uploaded videos. If set to <= 0, ``keep_max_files`` will not be Only keeps N most recently uploaded videos. If set to <= 0, ``keep_max_files`` will not be
applied. Can be used in conjunction with ``keep_files_before`` and ``keep_files_after``. applied. Can be used in conjunction with ``keep_files_before`` and ``keep_files_after``.
maintain_download_archive
~~~~~~~~~~~~~~~~~~~~~~~~~ ``maintain_download_archive``
Optional. Maintains a download archive file in the output directory for a subscription. Optional. Maintains a download archive file in the output directory for a subscription.
It is named ``.ytdl-sub-{subscription_name}-download-archive.json``, stored in the It is named ``.ytdl-sub-{subscription_name}-download-archive.json``, stored in the
output directory. output directory.
@ -554,23 +608,27 @@ prevent ytdl from redownloading media already downloaded.
Defaults to False. Defaults to False.
migrated_download_archive_name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``migrated_download_archive_name``
Optional. Intended to be used if you are migrating a subscription with either a new Optional. Intended to be used if you are migrating a subscription with either a new
subscription name or output directory. It will try to load the archive file using this name subscription name or output directory. It will try to load the archive file using this name
first, and fallback to ``download_archive_name``. It will always save to this file first, and fallback to ``download_archive_name``. It will always save to this file
and remove the original ``download_archive_name``. and remove the original ``download_archive_name``.
output_directory
~~~~~~~~~~~~~~~~ ``output_directory``
Required. The output directory to store all media files downloaded. Required. The output directory to store all media files downloaded.
thumbnail_name
~~~~~~~~~~~~~~ ``thumbnail_name``
Optional. The file name for the media's thumbnail image. This can include directories such Optional. The file name for the media's thumbnail image. This can include directories such
as ``"Season {upload_year}/{title}.{thumbnail_ext}"``, and will be placed in the output as ``"Season {upload_year}/{title}.{thumbnail_ext}"``, and will be placed in the output
directory. Can be set to empty string or `null` to disable thumbnail writes. directory. Can be set to empty string or `null` to disable thumbnail writes.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
overrides overrides
@ -665,11 +723,12 @@ Usage:
- "{upload_month}" - "{upload_month}"
- "{upload_day}" - "{upload_day}"
skip_if_match_fails ``skip_if_match_fails``
~~~~~~~~~~~~~~~~~~~
Defaults to True. If True, when any match fails and has no defaults, the entry will be Defaults to True. If True, when any match fails and has no defaults, the entry will be
skipped. If False, ytdl-sub will error and all downloads will not proceed. skipped. If False, ytdl-sub will error and all downloads will not proceed.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
split_by_chapters split_by_chapters
@ -693,11 +752,12 @@ Usage:
split_by_chapters: split_by_chapters:
when_no_chapters: "pass" when_no_chapters: "pass"
when_no_chapters ``when_no_chapters``
~~~~~~~~~~~~~~~~
Behavior to perform when no chapters are present. Supports "pass" (continue processing), Behavior to perform when no chapters are present. Supports "pass" (continue processing),
"drop" (exclude it from output), and "error" (stop processing for everything). "drop" (exclude it from output), and "error" (stop processing for everything).
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
subtitles subtitles
@ -719,31 +779,36 @@ Usage:
languages: "en" # supports list of multiple languages languages: "en" # supports list of multiple languages
allow_auto_generated_subtitles: False allow_auto_generated_subtitles: False
allow_auto_generated_subtitles ``allow_auto_generated_subtitles``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Optional. Whether to allow auto generated subtitles. Defaults to False. Optional. Whether to allow auto generated subtitles. Defaults to False.
embed_subtitles
~~~~~~~~~~~~~~~ ``embed_subtitles``
Optional. Whether to embed the subtitles into the video file. Defaults to False. Optional. Whether to embed the subtitles into the video file. Defaults to False.
NOTE: webm files can only embed "vtt" subtitle types. NOTE: webm files can only embed "vtt" subtitle types.
languages
~~~~~~~~~ ``languages``
Optional. Language code(s) to download for subtitles. Supports a single or list of multiple Optional. Language code(s) to download for subtitles. Supports a single or list of multiple
language codes. Defaults to "en". language codes. Defaults to "en".
subtitles_name
~~~~~~~~~~~~~~ ``subtitles_name``
Optional. The file name for the media's subtitles if they are present. This can include Optional. The file name for the media's subtitles if they are present. This can include
directories such as ``"Season {upload_year}/{title_sanitized}.{lang}.{subtitles_ext}"``, and directories such as ``"Season {upload_year}/{title_sanitized}.{lang}.{subtitles_ext}"``, and
will be placed in the output directory. ``lang`` is dynamic since you can download multiple will be placed in the output directory. ``lang`` is dynamic since you can download multiple
subtitles. It will set the respective language to the correct subtitle file. subtitles. It will set the respective language to the correct subtitle file.
subtitles_type
~~~~~~~~~~~~~~ ``subtitles_type``
Optional. One of the subtitle file types "srt", "vtt", "ass", "lrc". Defaults to "srt" Optional. One of the subtitle file types "srt", "vtt", "ass", "lrc". Defaults to "srt"
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
throttle_protection throttle_protection
@ -770,25 +835,29 @@ Usage:
max: 36 max: 36
subscription_download_probability: 1.0 subscription_download_probability: 1.0
max_downloads_per_subscription ``max_downloads_per_subscription``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Number of downloads to perform per subscription. Number of downloads to perform per subscription.
sleep_per_download_s
~~~~~~~~~~~~~~~~~~~~ ``sleep_per_download_s``
Number in seconds to sleep between each download. Does not include time it takes for Number in seconds to sleep between each download. Does not include time it takes for
ytdl-sub to perform post-processing. ytdl-sub to perform post-processing.
sleep_per_subscription_s
~~~~~~~~~~~~~~~~~~~~~~~~ ``sleep_per_subscription_s``
Number in seconds to sleep between each subscription. Number in seconds to sleep between each subscription.
subscription_download_probability
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``subscription_download_probability``
Probability to perform any downloads, recomputed for each subscription. This is only Probability to perform any downloads, recomputed for each subscription. This is only
recommended to set if you run ytdl-sub in a cron-job, that way you are statistically recommended to set if you run ytdl-sub in a cron-job, that way you are statistically
guaranteed over time to eventually download the subscription. guaranteed over time to eventually download the subscription.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
video_tags video_tags
@ -806,10 +875,11 @@ Usage:
date: "{upload_date}" date: "{upload_date}"
description: "{description}" description: "{description}"
tags ``tags``
~~~~
Key/values of tag names/values. Supports source and override variables. Key/values of tag names/values. Supports source and override variables.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
ytdl_options ytdl_options

View file

@ -18,7 +18,7 @@ Jellyfin
Kodi Kodi
~~~~ ~~~~
* Everything that the Jellyfin version does * Everything that the Jellyfin version does
* Turns on :ref:`config_reference/plugins:kodi_safe`, replacing characters that would break kodi with safer characters * Enables ``kodi_safe`` NFOs, replacing 4-byte unicode characters that break kodi with ````
Plex Plex
~~~~ ~~~~

View file

@ -25,15 +25,13 @@ class AudioExtractOptions(OptionsDictValidator):
""" """
Extracts audio from a video file. Extracts audio from a video file.
Usage: :Usage:
.. code-block:: yaml .. code-block:: yaml
presets: audio_extract:
my_example_preset: codec: "mp3"
audio_extract: quality: 128
codec: "mp3"
quality: 128
""" """
_required_keys = {"codec"} _required_keys = {"codec"}
@ -56,16 +54,20 @@ class AudioExtractOptions(OptionsDictValidator):
@property @property
def codec(self) -> str: def codec(self) -> str:
""" """
The codec to output after extracting the audio. Supported codecs are aac, flac, mp3, m4a, :expected type: String
opus, vorbis, wav, and best to grab the best possible format at runtime. :description:
The codec to output after extracting the audio. Supported codecs are aac, flac, mp3, m4a,
opus, vorbis, wav, and best to grab the best possible format at runtime.
""" """
return self._codec return self._codec
@property @property
def quality(self) -> Optional[float]: def quality(self) -> Optional[float]:
""" """
Optional. Specify ffmpeg audio quality. Insert a value between ``0`` (better) and ``9`` :expected type: Float
(worse) for variable bitrate, or a specific bitrate like ``128`` for 128k. :description:
Optional. Specify ffmpeg audio quality. Insert a value between ``0`` (better) and ``9``
(worse) for variable bitrate, or a specific bitrate like ``128`` for 128k.
""" """
if self._quality is not None: if self._quality is not None:
return self._quality.value return self._quality.value

View file

@ -64,32 +64,29 @@ class ChaptersOptions(OptionsDictValidator):
Embeds chapters to video files if they are present. Additional options to add SponsorBlock Embeds chapters to video files if they are present. Additional options to add SponsorBlock
chapters and remove specific ones. Can also remove chapters using regex. chapters and remove specific ones. Can also remove chapters using regex.
Usage: :usage:
.. code-block:: yaml .. code-block:: yaml
presets: chapters:
my_example_preset: # Embedded Chapter Fields
chapters: embed_chapters: True
# Embedded Chapter Fields allow_chapters_from_comments: False
embed_chapters: True remove_chapters_regex:
allow_chapters_from_comments: False - "Intro"
remove_chapters_regex: - "Outro"
- "Intro"
- "Outro"
# Sponsorblock Fields
sponsorblock_categories:
- "outro"
- "selfpromo"
- "preview"
- "interaction"
- "sponsor"
- "music_offtopic"
- "intro"
remove_sponsorblock_categories: "all"
force_key_frames: False
# Sponsorblock Fields
sponsorblock_categories:
- "outro"
- "selfpromo"
- "preview"
- "interaction"
- "sponsor"
- "music_offtopic"
- "intro"
remove_sponsorblock_categories: "all"
force_key_frames: False
""" """
_optional_keys = { _optional_keys = {
@ -135,23 +132,29 @@ class ChaptersOptions(OptionsDictValidator):
@property @property
def embed_chapters(self) -> Optional[bool]: def embed_chapters(self) -> Optional[bool]:
""" """
Optional. Embed chapters into the file. Defaults to True. :expected type: Optional[Boolean]
:description:
Defaults to True. Embed chapters into the file.
""" """
return self._embed_chapters return self._embed_chapters
@property @property
def allow_chapters_from_comments(self) -> bool: def allow_chapters_from_comments(self) -> bool:
""" """
Optional. If chapters do not exist in the video/description itself, attempt to scrape :expected type: Optional[Boolean]
comments to find the chapters. Defaults to False. :description:
Defaults to False. If chapters do not exist in the video/description itself, attempt to
scrape comments to find the chapters.
""" """
return self._allow_chapters_from_comments return self._allow_chapters_from_comments
@property @property
def remove_chapters_regex(self) -> Optional[List[re.Pattern]]: def remove_chapters_regex(self) -> Optional[List[re.Pattern]]:
""" """
Optional. List of regex patterns to match chapter titles against and remove them from the :expected type: Optional[List[RegexString]
entry. :description:
List of regex patterns to match chapter titles against and remove them from the
entry.
""" """
if self._remove_chapters_regex: if self._remove_chapters_regex:
return [validator.compiled_regex for validator in self._remove_chapters_regex.list] return [validator.compiled_regex for validator in self._remove_chapters_regex.list]
@ -160,9 +163,11 @@ class ChaptersOptions(OptionsDictValidator):
@property @property
def sponsorblock_categories(self) -> Optional[List[str]]: def sponsorblock_categories(self) -> Optional[List[str]]:
""" """
Optional. List of SponsorBlock categories to embed as chapters. Supports "sponsor", :expected type: Optional[List[String]]
"intro", "outro", "selfpromo", "preview", "filler", "interaction", "music_offtopic", :description:
"poi_highlight", or "all" to include all categories. List of SponsorBlock categories to embed as chapters. Supports "sponsor",
"intro", "outro", "selfpromo", "preview", "filler", "interaction", "music_offtopic",
"poi_highlight", or "all" to include all categories.
""" """
if self._sponsorblock_categories: if self._sponsorblock_categories:
category_list = [validator.value for validator in self._sponsorblock_categories.list] category_list = [validator.value for validator in self._sponsorblock_categories.list]
@ -174,9 +179,11 @@ class ChaptersOptions(OptionsDictValidator):
@property @property
def remove_sponsorblock_categories(self) -> Optional[List[str]]: def remove_sponsorblock_categories(self) -> Optional[List[str]]:
""" """
Optional. List of SponsorBlock categories to remove from the output file. Can only remove :expected type: Optional[List[String]]
categories that are specified in ``sponsorblock_categories`` or "all", which removes :description:
everything specified in ``sponsorblock_categories``. List of SponsorBlock categories to remove from the output file. Can only remove
categories that are specified in ``sponsorblock_categories`` or "all", which removes
everything specified in ``sponsorblock_categories``.
""" """
if self._remove_sponsorblock_categories: if self._remove_sponsorblock_categories:
category_list = [ category_list = [
@ -190,9 +197,10 @@ class ChaptersOptions(OptionsDictValidator):
@property @property
def force_key_frames(self) -> bool: def force_key_frames(self) -> bool:
""" """
Optional. Force keyframes at cuts when removing sections. This is slow due to needing a :expected type: Optional[Boolean]
re-encode, but the resulting video may have fewer artifacts around the cuts. Defaults to :description:
False. Defaults to False. Force keyframes at cuts when removing sections. This is slow due to
needing a re-encode, but the resulting video may have fewer artifacts around the cuts.
""" """
return self._force_key_frames return self._force_key_frames

View file

@ -11,16 +11,24 @@ from ytdl_sub.validators.string_datetime import StringDatetimeValidator
class DateRangeOptions(OptionsDictValidator): class DateRangeOptions(OptionsDictValidator):
""" """
Only download files uploaded within the specified date range. Only download files uploaded within the specified date range.
Dates must adhere to a yt-dlp datetime. From their docs:
Usage: .. code-block:: Markdown
A string in the format YYYYMMDD or
(now|today|yesterday|date)[+-][0-9](microsecond|second|minute|hour|day|week|month|year)(s)
Valid examples are ``now-2weeks`` or ``20200101``. Can use override variables in this.
Note that yt-dlp will round times to the closest day, meaning that `day` is the lowest
granularity possible.
:usage:
.. code-block:: yaml .. code-block:: yaml
presets: date_range:
my_example_preset: before: "now"
date_range: after: "today-2weeks"
before: "now"
after: "today-2weeks"
""" """
_optional_keys = {"before", "after"} _optional_keys = {"before", "after"}
@ -33,14 +41,18 @@ class DateRangeOptions(OptionsDictValidator):
@property @property
def before(self) -> Optional[StringDatetimeValidator]: def before(self) -> Optional[StringDatetimeValidator]:
""" """
Optional. Only download videos before this datetime. :expected type: Optional[OverridesFormatter]
:description:
Only download videos before this datetime.
""" """
return self._before return self._before
@property @property
def after(self) -> Optional[StringDatetimeValidator]: def after(self) -> Optional[StringDatetimeValidator]:
""" """
Optional. Only download videos after this datetime. :expected type: Optional[OverridesFormatter]
:description:
Only download videos before this datetime.
""" """
return self._after return self._after

View file

@ -1,10 +1,10 @@
import inspect import inspect
from pathlib import Path from pathlib import Path
from typing import Dict from typing import Dict, Any, Optional
from typing import Type from typing import Type
from tools.docgen.docgen import DocGen from tools.docgen.docgen import DocGen
from tools.docgen.utils import get_function_docs, line_section from tools.docgen.utils import line_section
from tools.docgen.utils import properties from tools.docgen.utils import properties
from tools.docgen.utils import section from tools.docgen.utils import section
from ytdl_sub.config.overrides import Overrides from ytdl_sub.config.overrides import Overrides
@ -26,6 +26,15 @@ def should_filter_property(property_name: str) -> bool:
) )
def get_function_docs(
function_name: str, obj: Any, level: int
) -> str:
docs = f"\n``{function_name}``\n\n"
docs += inspect.cleandoc(getattr(obj, function_name).__doc__)
docs += "\n\n"
return docs
def generate_plugin_docs(name: str, options: Type[OptionsValidator], offset: int) -> str: def generate_plugin_docs(name: str, options: Type[OptionsValidator], offset: int) -> str:
docs = "" docs = ""
docs += section(name, level=offset + 0) docs += section(name, level=offset + 0)