Add support for season.nfo file creation
This commit is contained in:
parent
57c5d3c800
commit
52a1be3fd6
5 changed files with 110 additions and 2 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
__pypi_version__ = "2023.10.22.post3"
|
__pypi_version__ = "2025.01.09"
|
||||||
__local_version__ = "2023.10.22+bfba4f0"
|
__local_version__ = "2025.01.09+57c5d3c"
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ from ytdl_sub.plugins.match_filters import MatchFiltersPlugin
|
||||||
from ytdl_sub.plugins.music_tags import MusicTagsPlugin
|
from ytdl_sub.plugins.music_tags import MusicTagsPlugin
|
||||||
from ytdl_sub.plugins.nfo_tags import NfoTagsPlugin
|
from ytdl_sub.plugins.nfo_tags import NfoTagsPlugin
|
||||||
from ytdl_sub.plugins.output_directory_nfo_tags import OutputDirectoryNfoTagsPlugin
|
from ytdl_sub.plugins.output_directory_nfo_tags import OutputDirectoryNfoTagsPlugin
|
||||||
|
from ytdl_sub.plugins.season_nfo_tags import SeasonNfoTagsPlugin
|
||||||
from ytdl_sub.plugins.split_by_chapters import SplitByChaptersPlugin
|
from ytdl_sub.plugins.split_by_chapters import SplitByChaptersPlugin
|
||||||
from ytdl_sub.plugins.subtitles import SubtitlesPlugin
|
from ytdl_sub.plugins.subtitles import SubtitlesPlugin
|
||||||
from ytdl_sub.plugins.throttle_protection import ThrottleProtectionPlugin
|
from ytdl_sub.plugins.throttle_protection import ThrottleProtectionPlugin
|
||||||
|
|
@ -46,6 +47,7 @@ class PluginMapping:
|
||||||
"video_tags": VideoTagsPlugin,
|
"video_tags": VideoTagsPlugin,
|
||||||
"nfo_tags": NfoTagsPlugin,
|
"nfo_tags": NfoTagsPlugin,
|
||||||
"output_directory_nfo_tags": OutputDirectoryNfoTagsPlugin,
|
"output_directory_nfo_tags": OutputDirectoryNfoTagsPlugin,
|
||||||
|
"season_nfo_tags": SeasonNfoTagsPlugin,
|
||||||
"subtitles": SubtitlesPlugin,
|
"subtitles": SubtitlesPlugin,
|
||||||
"chapters": ChaptersPlugin,
|
"chapters": ChaptersPlugin,
|
||||||
"split_by_chapters": SplitByChaptersPlugin,
|
"split_by_chapters": SplitByChaptersPlugin,
|
||||||
|
|
@ -83,6 +85,7 @@ class PluginMapping:
|
||||||
MusicTagsPlugin,
|
MusicTagsPlugin,
|
||||||
VideoTagsPlugin,
|
VideoTagsPlugin,
|
||||||
NfoTagsPlugin,
|
NfoTagsPlugin,
|
||||||
|
SeasonNfoTagsPlugin,
|
||||||
EmbedThumbnailPlugin,
|
EmbedThumbnailPlugin,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
90
src/ytdl_sub/plugins/season_nfo_tags.py
Normal file
90
src/ytdl_sub/plugins/season_nfo_tags.py
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
from ytdl_sub.config.overrides import Overrides
|
||||||
|
from ytdl_sub.entries.entry import Entry
|
||||||
|
from ytdl_sub.plugins.nfo_tags import NfoTagsValidator
|
||||||
|
from ytdl_sub.plugins.nfo_tags import SharedNfoTagsOptions
|
||||||
|
from ytdl_sub.plugins.nfo_tags import SharedNfoTagsPlugin
|
||||||
|
from ytdl_sub.validators.string_formatter_validators import StringFormatterValidator
|
||||||
|
from ytdl_sub.ytdl_additions.enhanced_download_archive import EnhancedDownloadArchive
|
||||||
|
|
||||||
|
|
||||||
|
class SeasonNfoTagsOptions(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.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
presets:
|
||||||
|
my_example_preset:
|
||||||
|
season_nfo_tags:
|
||||||
|
# required
|
||||||
|
nfo_name: "season.nfo"
|
||||||
|
nfo_root: "season"
|
||||||
|
tags:
|
||||||
|
title: "My custom season name!"
|
||||||
|
# optional
|
||||||
|
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:
|
||||||
|
"""
|
||||||
|
:expected type: EntryFormatter
|
||||||
|
:description:
|
||||||
|
The root tag of the NFO's XML. In the usage above, it would look like
|
||||||
|
|
||||||
|
.. code-block:: xml
|
||||||
|
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<season>
|
||||||
|
</season>
|
||||||
|
"""
|
||||||
|
return self._nfo_root
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tags(self) -> NfoTagsValidator:
|
||||||
|
"""
|
||||||
|
:expected type: NfoTags
|
||||||
|
:description:
|
||||||
|
Tags within the nfo_root tag. In the usage above, it would look like
|
||||||
|
|
||||||
|
.. code-block:: xml
|
||||||
|
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<season>
|
||||||
|
<title>My custom season name!</title>
|
||||||
|
</season>
|
||||||
|
"""
|
||||||
|
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
|
||||||
|
|
||||||
|
def post_process_entry(self, entry: Entry) -> None:
|
||||||
|
"""
|
||||||
|
Creates an season NFO file using values defined by the season collection name
|
||||||
|
"""
|
||||||
|
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
|
||||||
13
src/ytdl_sub/prebuilt_presets/tv_show/season.yaml
Normal file
13
src/ytdl_sub/prebuilt_presets/tv_show/season.yaml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
presets:
|
||||||
|
|
||||||
|
####################################################################################################
|
||||||
|
|
||||||
|
_season_nfo_tags:
|
||||||
|
season_nfo_tags:
|
||||||
|
# required
|
||||||
|
nfo_name: "{season_directory_name_sanitized}/season.nfo"
|
||||||
|
nfo_root: "season"
|
||||||
|
tags:
|
||||||
|
title: "{collection_season_name}"
|
||||||
|
# optional
|
||||||
|
kodi_safe: False
|
||||||
|
|
@ -12,6 +12,8 @@ presets:
|
||||||
preset:
|
preset:
|
||||||
- "jellyfin_tv_show_collection"
|
- "jellyfin_tv_show_collection"
|
||||||
- "season_by_collection__episode_by_year_month_day"
|
- "season_by_collection__episode_by_year_month_day"
|
||||||
|
# Jellyfin/Emby currently do not support reading the namedseason tag from tvshow.nfo and insted rely on a per-folder season.nfo
|
||||||
|
- "_season_nfo_tags"
|
||||||
|
|
||||||
"Plex TV Show Collection":
|
"Plex TV Show Collection":
|
||||||
preset:
|
preset:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue