static nfo tags

This commit is contained in:
Jesse Bannon 2025-06-01 09:12:57 -07:00
parent 0e901cab96
commit ccc57dcc16
4 changed files with 57 additions and 73 deletions

View file

@ -784,11 +784,48 @@ sanitization on the value when used.
----------------------------------------------------------------------------------------------------
season_nfo_tags
split_by_chapters
-----------------
Splits a file by chapters into multiple files. Each file becomes its own entry with the
new variables
- ``chapter_title``
- ``chapter_index``
- ``chapter_index_padded``
- ``chapter_count``
Note that when using this plugin and performing dry-run, it assumes embedded chapters are being
used with no modifications.
:Usage:
.. code-block:: yaml
split_by_chapters:
when_no_chapters: "pass"
``when_no_chapters``
:expected type: String
:description:
Behavior to perform when no chapters are present. Supports
- "pass" (continue processing),
- "drop" (exclude it from output)
- "error" (stop processing for everything).
If a file has no chapters and is set to "pass", then ``chapter_title`` is
set to the entry's title and ``chapter_index``, ``chapter_count`` are both set to 1.
----------------------------------------------------------------------------------------------------
static_nfo_tags
---------------
Adds a single NFO file in the season directory. An NFO file is simply an XML file with a
``.nfo`` extension. It uses the last entry's source variables which can change per download
invocation. Be cautious of which variables you use.
Adds an NFO file for every entry, but does not link it to an entry in the download archive.
This is intended to produce ``season.nfo``s in each season directory. Each entry within a
season will overwrite this file with its season name. If the entry gets deleted from ytdl-sub,
this file will remain since it's not linked.
Usage:
@ -796,7 +833,7 @@ Usage:
presets:
my_example_preset:
season_nfo_tags:
static_nfo_tags:
# required
nfo_name: "season.nfo"
nfo_root: "season"
@ -816,7 +853,7 @@ Usage:
``kodi_safe``
:expected type: Optional[Boolean]
:expected type: OverridesBooleanFormatterValidator
:description:
Defaults to False. Kodi does not support > 3-byte unicode characters, which include
emojis and some foreign language characters. Setting this to True will replace those
@ -857,42 +894,6 @@ Usage:
</season>
----------------------------------------------------------------------------------------------------
split_by_chapters
-----------------
Splits a file by chapters into multiple files. Each file becomes its own entry with the
new variables
- ``chapter_title``
- ``chapter_index``
- ``chapter_index_padded``
- ``chapter_count``
Note that when using this plugin and performing dry-run, it assumes embedded chapters are being
used with no modifications.
:Usage:
.. code-block:: yaml
split_by_chapters:
when_no_chapters: "pass"
``when_no_chapters``
:expected type: String
:description:
Behavior to perform when no chapters are present. Supports
- "pass" (continue processing),
- "drop" (exclude it from output)
- "error" (stop processing for everything).
If a file has no chapters and is set to "pass", then ``chapter_title`` is
set to the entry's title and ``chapter_index``, ``chapter_count`` are both set to 1.
----------------------------------------------------------------------------------------------------
subtitles

View file

@ -23,7 +23,7 @@ from ytdl_sub.plugins.match_filters import MatchFiltersPlugin
from ytdl_sub.plugins.music_tags import MusicTagsPlugin
from ytdl_sub.plugins.nfo_tags import NfoTagsPlugin
from ytdl_sub.plugins.output_directory_nfo_tags import OutputDirectoryNfoTagsPlugin
from ytdl_sub.plugins.season_nfo_tags import SeasonNfoTagsPlugin
from ytdl_sub.plugins.static_nfo_tags import StaticNfoTagsPlugin
from ytdl_sub.plugins.split_by_chapters import SplitByChaptersPlugin
from ytdl_sub.plugins.subtitles import SubtitlesPlugin
from ytdl_sub.plugins.throttle_protection import ThrottleProtectionPlugin
@ -47,7 +47,7 @@ class PluginMapping:
"video_tags": VideoTagsPlugin,
"nfo_tags": NfoTagsPlugin,
"output_directory_nfo_tags": OutputDirectoryNfoTagsPlugin,
"season_nfo_tags": SeasonNfoTagsPlugin,
"static_nfo_tags": StaticNfoTagsPlugin,
"subtitles": SubtitlesPlugin,
"chapters": ChaptersPlugin,
"split_by_chapters": SplitByChaptersPlugin,
@ -85,7 +85,7 @@ class PluginMapping:
MusicTagsPlugin,
VideoTagsPlugin,
NfoTagsPlugin,
SeasonNfoTagsPlugin,
StaticNfoTagsPlugin,
EmbedThumbnailPlugin,
]

View file

@ -7,11 +7,12 @@ from ytdl_sub.validators.string_formatter_validators import StringFormatterValid
from ytdl_sub.ytdl_additions.enhanced_download_archive import EnhancedDownloadArchive
class SeasonNfoTagsOptions(SharedNfoTagsOptions):
class StaticNfoTagsOptions(SharedNfoTagsOptions):
"""
Adds a single NFO file in the season directory. An NFO file is simply an XML file with a
``.nfo`` extension. It uses the last entry's source variables which can change per download
invocation. Be cautious of which variables you use.
Adds an NFO file for every entry, but does not link it to an entry in the download archive.
This is intended to produce ``season.nfo``s in each season directory. Each entry within a
season will overwrite this file with its season name. If the entry gets deleted from ytdl-sub,
this file will remain since it's not linked.
Usage:
@ -19,7 +20,7 @@ class SeasonNfoTagsOptions(SharedNfoTagsOptions):
presets:
my_example_preset:
season_nfo_tags:
static_nfo_tags:
# required
nfo_name: "season.nfo"
nfo_root: "season"
@ -29,10 +30,6 @@ class SeasonNfoTagsOptions(SharedNfoTagsOptions):
kodi_safe: False
"""
# Hack to make it so collection named seasons do not error
# when adding output_directory_nfo info for plex
_required_keys = set()
_optional_keys = {"enable", "kodi_safe", "nfo_name", "nfo_root", "tags"}
@property
def nfo_root(self) -> StringFormatterValidator:
@ -66,25 +63,11 @@ class SeasonNfoTagsOptions(SharedNfoTagsOptions):
return self._tags
class SeasonNfoTagsPlugin(SharedNfoTagsPlugin):
plugin_options_type = SeasonNfoTagsOptions
def __init__(
self,
options: SeasonNfoTagsOptions,
overrides: Overrides,
enhanced_download_archive: EnhancedDownloadArchive,
):
super().__init__(options, overrides, enhanced_download_archive)
self._created_output_nfo = False
class StaticNfoTagsPlugin(SharedNfoTagsPlugin):
plugin_options_type = StaticNfoTagsOptions
def post_process_entry(self, entry: Entry) -> None:
"""
Creates an season NFO file using values defined by the season collection name
Creates the NFO from each entry, but does not link/save it to the entry.
"""
if (
self.plugin_options.nfo_name is not None
and self.plugin_options.nfo_root is not None
):
self._create_nfo(entry=entry, save_to_entry=False)
self._created_output_nfo = True
self._create_nfo(entry=entry, save_to_entry=False)

View file

@ -23,7 +23,7 @@ presets:
# Emby cannot read seasons from tv_show.nfo
# Create explicit season NFOs in each season dir
season_nfo_tags:
static_nfo_tags:
nfo_name: "{season_directory_name_sanitized}/season.nfo"
nfo_root: "season"
tags: