docs, update test
This commit is contained in:
parent
1146fd9659
commit
7afe889f19
5 changed files with 39 additions and 25 deletions
|
|
@ -177,6 +177,14 @@ audio_extract
|
|||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
chapters
|
||||
''''''''
|
||||
.. autoclass:: ytdl_sub.plugins.chapters.ChaptersOptions()
|
||||
:members:
|
||||
:member-order: bysource
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
music_tags
|
||||
''''''''''
|
||||
.. autoclass:: ytdl_sub.plugins.music_tags.MusicTagsOptions()
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class ChaptersOptions(PluginOptions):
|
|||
presets:
|
||||
my_example_preset:
|
||||
chapters:
|
||||
embed_chapters: True
|
||||
sponsorblock_categories:
|
||||
- "outro"
|
||||
- "selfpromo"
|
||||
|
|
@ -78,17 +79,10 @@ class ChaptersOptions(PluginOptions):
|
|||
- "Intro"
|
||||
- "Outro"
|
||||
force_key_frames: False
|
||||
|
||||
To simply embed chapters from the entry file and nothing more, specify the following:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
presets:
|
||||
my_example_preset:
|
||||
chapters:
|
||||
"""
|
||||
|
||||
_optional_keys = {
|
||||
"embed_chapters",
|
||||
"sponsorblock_categories",
|
||||
"remove_sponsorblock_categories",
|
||||
"remove_chapters_regex",
|
||||
|
|
@ -97,6 +91,9 @@ class ChaptersOptions(PluginOptions):
|
|||
|
||||
def __init__(self, name, value):
|
||||
super().__init__(name, value)
|
||||
self._embed_chapters = self._validate_key_if_present(
|
||||
key="embed_chapters", validator=BoolValidator, default=True
|
||||
).value
|
||||
self._sponsorblock_categories = self._validate_key_if_present(
|
||||
key="sponsorblock_categories", validator=SponsorBlockCategoryListValidator
|
||||
)
|
||||
|
|
@ -115,6 +112,13 @@ class ChaptersOptions(PluginOptions):
|
|||
"Must specify sponsorblock_categories if you are going to remove any of them"
|
||||
)
|
||||
|
||||
@property
|
||||
def embed_chapters(self) -> Optional[bool]:
|
||||
"""
|
||||
Optional. Embed chapters into the file. Defaults to True.
|
||||
"""
|
||||
return self._embed_chapters
|
||||
|
||||
@property
|
||||
def sponsorblock_categories(self) -> Optional[List[str]]:
|
||||
"""
|
||||
|
|
@ -196,8 +200,14 @@ class ChaptersPlugin(Plugin[ChaptersOptions]):
|
|||
}
|
||||
)
|
||||
|
||||
# Always add chapters
|
||||
builder.add({"postprocessors": [{"key": "FFmpegMetadata", "add_chapters": True}]})
|
||||
if self.plugin_options.embed_chapters:
|
||||
builder.add(
|
||||
{
|
||||
"postprocessors": [
|
||||
{"key": "FFmpegMetadata", "add_chapters": True, "add_metadata": False}
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
if self._is_removing_chapters:
|
||||
remove_chapters_post_processor = {
|
||||
|
|
@ -213,14 +223,16 @@ class ChaptersPlugin(Plugin[ChaptersOptions]):
|
|||
"remove_chapters_patterns"
|
||||
] = self.plugin_options.remove_chapters_regex
|
||||
|
||||
builder.add(
|
||||
{
|
||||
"postprocessors": [
|
||||
remove_chapters_post_processor,
|
||||
{"key": "FFmpegMetadata", "add_chapters": True}, # re-add chapters
|
||||
]
|
||||
}
|
||||
)
|
||||
if self.plugin_options.embed_chapters:
|
||||
builder.add(
|
||||
{
|
||||
# re-add chapters
|
||||
"postprocessors": [
|
||||
remove_chapters_post_processor,
|
||||
{"key": "FFmpegMetadata", "add_chapters": True, "add_metadata": False},
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
return builder.to_dict()
|
||||
|
||||
|
|
|
|||
|
|
@ -55,13 +55,11 @@ class TestAudioExtract:
|
|||
output_directory=output_directory,
|
||||
transaction_log=transaction_log,
|
||||
transaction_log_summary_file_name="plugins/test_audio_extract_single.txt",
|
||||
regenerate_transaction_log=True,
|
||||
)
|
||||
assert_expected_downloads(
|
||||
output_directory=output_directory,
|
||||
dry_run=dry_run,
|
||||
expected_download_summary_file_name="plugins/test_audio_extract_single.json",
|
||||
regenerate_expected_download_summary=True,
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize("dry_run", [True, False])
|
||||
|
|
@ -83,11 +81,9 @@ class TestAudioExtract:
|
|||
output_directory=output_directory,
|
||||
transaction_log=transaction_log,
|
||||
transaction_log_summary_file_name="plugins/test_audio_extract_playlist.txt",
|
||||
regenerate_transaction_log=True,
|
||||
)
|
||||
assert_expected_downloads(
|
||||
output_directory=output_directory,
|
||||
dry_run=dry_run,
|
||||
expected_download_summary_file_name="plugins/test_audio_extract_playlist.json",
|
||||
regenerate_expected_download_summary=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -61,11 +61,9 @@ class TestChapters:
|
|||
output_directory=output_directory,
|
||||
transaction_log=transaction_log,
|
||||
transaction_log_summary_file_name="plugins/test_chapters_sb_and_embedded_subs.txt",
|
||||
regenerate_transaction_log=True,
|
||||
)
|
||||
assert_expected_downloads(
|
||||
output_directory=output_directory,
|
||||
dry_run=dry_run,
|
||||
expected_download_summary_file_name="plugins/test_chapters_sb_and_embedded_subs.json",
|
||||
regenerate_expected_download_summary=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"JMC - This GPU SLIDES into this Case! - Silverstone SUGO 16 ITX Case-thumb.jpg": "a81457393418b5abed785a82122f3352",
|
||||
"JMC - This GPU SLIDES into this Case! - Silverstone SUGO 16 ITX Case.mp4": "ff829c47452173eac92e09507feb64a0",
|
||||
"JMC - This GPU SLIDES into this Case! - Silverstone SUGO 16 ITX Case.mp4": "68f674e6d4028f0e5fbc582fadd5d205",
|
||||
"JMC - This GPU SLIDES into this Case! - Silverstone SUGO 16 ITX Case.nfo": "0c06fe6874588209fccbd9276a446750"
|
||||
}
|
||||
Loading…
Reference in a new issue