[BUGFIX] Fix split_by_chapter download archive not working (#344)
This commit is contained in:
parent
5705a28842
commit
20bec0c664
12 changed files with 44 additions and 7 deletions
|
|
@ -43,7 +43,9 @@ PLAYLIST_UPLOADER_URL = _("playlist_uploader_url")
|
|||
DOWNLOAD_INDEX = _("download_index", backend=True)
|
||||
UPLOAD_DATE_INDEX = _("upload_date_index", backend=True)
|
||||
REQUESTED_SUBTITLES = _("requested_subtitles", backend=True)
|
||||
CHAPTERS = _("chapters", backend=True)
|
||||
SPONSORBLOCK_CHAPTERS = _("sponsorblock_chapters", backend=True)
|
||||
SPLIT_BY_CHAPTERS_PARENT_ENTRY = _("split_by_chapters_parent_entry", backend=True)
|
||||
UID = _("id")
|
||||
EXTRACTOR = _("extractor")
|
||||
EPOCH = _("epoch")
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ from typing import Tuple
|
|||
from yt_dlp.utils import sanitize_filename
|
||||
|
||||
from ytdl_sub.entries.entry import Entry
|
||||
from ytdl_sub.entries.variables.kwargs import CHAPTERS
|
||||
from ytdl_sub.entries.variables.kwargs import SPLIT_BY_CHAPTERS_PARENT_ENTRY
|
||||
from ytdl_sub.entries.variables.kwargs import SPONSORBLOCK_CHAPTERS
|
||||
from ytdl_sub.entries.variables.kwargs import UID
|
||||
from ytdl_sub.plugins.plugin import Plugin
|
||||
from ytdl_sub.plugins.plugin import PluginOptions
|
||||
|
|
@ -121,11 +124,17 @@ class SplitByChaptersPlugin(Plugin[SplitByChaptersOptions]):
|
|||
)
|
||||
|
||||
# pylint: disable=protected-access
|
||||
entry._kwargs[UID] = _split_video_uid(source_uid=entry.uid, idx=idx)
|
||||
if "chapters" in entry._kwargs:
|
||||
del entry._kwargs["chapters"]
|
||||
if "sponsorblock_chapters" in entry._kwargs:
|
||||
del entry._kwargs["sponsorblock_chapters"]
|
||||
entry.add_kwargs(
|
||||
{
|
||||
UID: _split_video_uid(source_uid=entry.uid, idx=idx),
|
||||
SPLIT_BY_CHAPTERS_PARENT_ENTRY: source_entry._kwargs,
|
||||
}
|
||||
)
|
||||
|
||||
if entry.kwargs_contains(CHAPTERS):
|
||||
del entry._kwargs[CHAPTERS]
|
||||
if entry.kwargs_contains(SPONSORBLOCK_CHAPTERS):
|
||||
del entry._kwargs[SPONSORBLOCK_CHAPTERS]
|
||||
# pylint: enable=protected-access
|
||||
|
||||
timestamp_begin = chapters.timestamps[idx].readable_str
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from typing import Set
|
|||
from yt_dlp import DateRange
|
||||
|
||||
from ytdl_sub.entries.entry import Entry
|
||||
from ytdl_sub.entries.variables.kwargs import SPLIT_BY_CHAPTERS_PARENT_ENTRY
|
||||
from ytdl_sub.utils.file_handler import FileHandler
|
||||
from ytdl_sub.utils.file_handler import FileHandlerTransactionLog
|
||||
from ytdl_sub.utils.file_handler import FileMetadata
|
||||
|
|
@ -587,7 +588,15 @@ class EnhancedDownloadArchive:
|
|||
if output_file_name is None:
|
||||
output_file_name = file_name
|
||||
|
||||
if entry:
|
||||
# If the entry is created from splitting via chapters, store it to the mapping
|
||||
# using its parent entry
|
||||
if entry and entry.kwargs_contains(SPLIT_BY_CHAPTERS_PARENT_ENTRY):
|
||||
parent_entry = Entry(
|
||||
entry_dict=entry.kwargs(SPLIT_BY_CHAPTERS_PARENT_ENTRY),
|
||||
working_directory=entry.working_directory(),
|
||||
)
|
||||
self.mapping.add_entry(parent_entry, entry_file_path=output_file_name)
|
||||
elif entry:
|
||||
self.mapping.add_entry(entry=entry, entry_file_path=output_file_name)
|
||||
|
||||
self._file_handler.move_file_to_output_directory(
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ def yt_album_as_chapters_preset_dict(output_directory):
|
|||
"preset": "album_from_chapters",
|
||||
"download": {"url": "https://www.youtube.com/watch?v=zeR2_YjlXWA"},
|
||||
# override the output directory with our fixture-generated dir
|
||||
"output_options": {"output_directory": output_directory},
|
||||
"output_options": {"output_directory": output_directory, "maintain_download_archive": True},
|
||||
# download the worst format so it is fast
|
||||
"ytdl_options": {
|
||||
"format": "worst[ext=mp4]",
|
||||
|
|
@ -89,6 +89,10 @@ class TestSplitByChapters:
|
|||
expected_download_summary_file_name="plugins/split_by_chapters_video.json",
|
||||
)
|
||||
|
||||
if not dry_run:
|
||||
transaction_log = subscription.download()
|
||||
assert transaction_log.is_empty
|
||||
|
||||
@pytest.mark.parametrize("dry_run", [True, False])
|
||||
def test_video_with_chapters_and_regex(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
".ytdl-sub-split_by_chapters_video-download-archive.json": "7001417f7a398959f3296ece81575a77",
|
||||
"Alfa Mist - Nocturne [Full Album]/01 - 01. Intro (Feat. Racheal Ofori & Barney Artist).mp3": "1ede8775719b99d05c89d6d0a2a74df5",
|
||||
"Alfa Mist - Nocturne [Full Album]/02 - 02. Answers (Feat. Rick David & Kaya Thomas - Dyke).mp3": "2430b44a6c15050f7e2ee09274c26600",
|
||||
"Alfa Mist - Nocturne [Full Album]/03 - 03. Blaze (Feat. Kaya Thomas - Dyke).mp3": "8dbb8d15109955c4540dfe3c015157b8",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
".ytdl-sub-split_by_chapters_with_regex_video-download-archive.json": "11367ac13068646e35a53d25deeba834",
|
||||
"Oblivion Mod "Falcor" p.1/01 - Oblivion Mod "Falcor" p.1.mp3": "6d570f225f6c3a14de0ba4c912995641",
|
||||
"Oblivion Mod "Falcor" p.1/folder.jpg": "fb95b510681676e81c321171fc23143e"
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
".ytdl-sub-split_by_chapters_with_regex_video-download-archive.json": "5f281991d441f406b0d721b250e74b79",
|
||||
"Nocturne/01 - Intro (Feat. Racheal Ofori & Barney Artist).mp3": "b2e2a9834f03d1928e0c8a0602899d4d",
|
||||
"Nocturne/02 - Answers (Feat. Rick David & Kaya Thomas - Dyke).mp3": "8fe76edcc77c5d8db0f7b5b8577a4cf6",
|
||||
"Nocturne/03 - Blaze (Feat. Kaya Thomas - Dyke).mp3": "fd45453753a783ec4f26ef399a8ecece",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
Files created:
|
||||
----------------------------------------
|
||||
{output_directory}
|
||||
.ytdl-sub-split_by_chapters_video-download-archive.json
|
||||
{output_directory}/Alfa Mist - Nocturne [Full Album]
|
||||
01 - 01. Intro (Feat. Racheal Ofori & Barney Artist).mp3
|
||||
From Chapter Split:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
Files created:
|
||||
----------------------------------------
|
||||
{output_directory}
|
||||
.ytdl-sub-split_by_chapters_video-download-archive.json
|
||||
{output_directory}/Alfa Mist - Nocturne [Full Album]
|
||||
01 - 01. Intro (Feat. Racheal Ofori & Barney Artist).mp3
|
||||
From Chapter Split:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
Files created:
|
||||
----------------------------------------
|
||||
{output_directory}
|
||||
.ytdl-sub-split_by_chapters_with_regex_video-download-archive.json
|
||||
{output_directory}/Oblivion Mod "Falcor" p.1
|
||||
01 - Oblivion Mod "Falcor" p.1.mp3
|
||||
Music Tags:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
Files created:
|
||||
----------------------------------------
|
||||
{output_directory}
|
||||
.ytdl-sub-split_by_chapters_with_regex_video-download-archive.json
|
||||
{output_directory}/Nocturne
|
||||
01 - Intro (Feat. Racheal Ofori & Barney Artist).mp3
|
||||
From Chapter Split:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
Files created:
|
||||
----------------------------------------
|
||||
{output_directory}
|
||||
.ytdl-sub-split_by_chapters_with_regex_video-download-archive.json
|
||||
{output_directory}/Nocturne
|
||||
01 - Intro (Feat. Racheal Ofori & Barney Artist).mp3
|
||||
From Chapter Split:
|
||||
|
|
|
|||
Loading…
Reference in a new issue