unit working, e2e broken titles
This commit is contained in:
parent
a7f556b58f
commit
4ad78fcdf2
6 changed files with 39 additions and 22 deletions
|
|
@ -250,7 +250,7 @@ class Preset(StrictDictValidator):
|
|||
validator=OutputOptions,
|
||||
)
|
||||
|
||||
self.subtitle_options = self._validate_key(
|
||||
self.subtitle_options = self._validate_key_if_present(
|
||||
key="subtitle_options", validator=SubtitleOptions, default={}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -233,6 +233,26 @@ class SubtitlesTypeValidator(StringSelectValidator):
|
|||
|
||||
|
||||
class SubtitleOptions(StrictDictValidator):
|
||||
"""
|
||||
Defines how to download and store subtitles.
|
||||
|
||||
Usage:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
presets:
|
||||
my_example_preset:
|
||||
subtitle_options:
|
||||
# required
|
||||
output_directory: "/path/to/videos_or_music"
|
||||
file_name: "{title_sanitized}.{ext}"
|
||||
# optional
|
||||
thumbnail_name: "{title_sanitized}.{thumbnail_ext}"
|
||||
maintain_download_archive: True
|
||||
keep_files_before: now
|
||||
keep_files_after: 19000101
|
||||
"""
|
||||
|
||||
_optional_keys = {
|
||||
"subtitles_name",
|
||||
"subtitles_type",
|
||||
|
|
|
|||
|
|
@ -204,19 +204,19 @@ class Subscription:
|
|||
entry=entry,
|
||||
)
|
||||
|
||||
# TODO: see if entry even has subtitles
|
||||
if self.output_options.subtitles_name and (
|
||||
entry.kwargs_contains("subtitles") or entry.kwargs_contains("automatic_captions")
|
||||
):
|
||||
output_subtitles_name = self.overrides.apply_formatter(
|
||||
formatter=self.output_options.subtitles_name, entry=entry
|
||||
)
|
||||
|
||||
self._enhanced_download_archive.save_file_to_output_directory(
|
||||
file_name=entry.get_download_subtitles_name(),
|
||||
output_file_name=output_subtitles_name,
|
||||
entry=entry,
|
||||
)
|
||||
# # TODO: see if entry even has subtitles
|
||||
# if self.output_options.subtitles_name and (
|
||||
# entry.kwargs_contains("subtitles") or entry.kwargs_contains("automatic_captions")
|
||||
# ):
|
||||
# output_subtitles_name = self.overrides.apply_formatter(
|
||||
# formatter=self.output_options.subtitles_name, entry=entry
|
||||
# )
|
||||
#
|
||||
# self._enhanced_download_archive.save_file_to_output_directory(
|
||||
# file_name=entry.get_download_subtitles_name(),
|
||||
# output_file_name=output_subtitles_name,
|
||||
# entry=entry,
|
||||
# )
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _prepare_working_directory(self):
|
||||
|
|
|
|||
|
|
@ -27,13 +27,6 @@ class StrictDictValidator(DictValidator):
|
|||
if required_key not in self._dict:
|
||||
raise self._validation_exception(f"missing the required field '{required_key}'")
|
||||
|
||||
# Ensure an empty dict was not passed as the value
|
||||
if not self._dict:
|
||||
raise self._validation_exception(
|
||||
f"at least one of the following fields must be defined: "
|
||||
f"{', '.join(self._optional_keys)}'"
|
||||
)
|
||||
|
||||
# Ensure all keys are either required or optional keys if no extra field are allowed
|
||||
if not self._allow_extra_keys:
|
||||
for object_key in self._keys:
|
||||
|
|
|
|||
|
|
@ -44,5 +44,4 @@ class TestNfoTagsPlugins:
|
|||
output_directory=output_directory,
|
||||
transaction_log=transaction_log,
|
||||
transaction_log_summary_file_name="plugins/test_kodi_safe_xml.txt",
|
||||
regenerate_transaction_log=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -54,6 +54,9 @@ def ext():
|
|||
def thumbnail_ext():
|
||||
return "jpg"
|
||||
|
||||
@pytest.fixture
|
||||
def subtitles_ext():
|
||||
return "srt"
|
||||
|
||||
@pytest.fixture
|
||||
def download_thumbnail_name(uid, thumbnail_ext):
|
||||
|
|
@ -74,6 +77,7 @@ def mock_entry_to_dict(
|
|||
upload_date,
|
||||
upload_year,
|
||||
thumbnail_ext,
|
||||
subtitles_ext,
|
||||
upload_month,
|
||||
upload_day,
|
||||
):
|
||||
|
|
@ -92,6 +96,7 @@ def mock_entry_to_dict(
|
|||
"upload_day": upload_day,
|
||||
"upload_day_padded": _pad(upload_day),
|
||||
"thumbnail_ext": thumbnail_ext,
|
||||
"subtitles_ext": subtitles_ext,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue