diff --git a/src/ytdl_sub/entries/base_entry.py b/src/ytdl_sub/entries/base_entry.py index 37cf6cac..697bb1f6 100644 --- a/src/ytdl_sub/entries/base_entry.py +++ b/src/ytdl_sub/entries/base_entry.py @@ -14,6 +14,7 @@ from yt_dlp.utils import sanitize_filename from ytdl_sub.entries.variables.kwargs import DESCRIPTION from ytdl_sub.entries.variables.kwargs import EPOCH from ytdl_sub.entries.variables.kwargs import EXTRACTOR +from ytdl_sub.entries.variables.kwargs import IE_KEY from ytdl_sub.entries.variables.kwargs import TITLE from ytdl_sub.entries.variables.kwargs import UID from ytdl_sub.entries.variables.kwargs import UPLOADER @@ -101,7 +102,10 @@ class BaseEntryVariables: str The ytdl extractor name """ - return self.kwargs(EXTRACTOR) + # pylint: disable=line-too-long + # Taken from https://github.com/yt-dlp/yt-dlp/blob/e6ab678e36c40ded0aae305bbb866cdab554d417/yt_dlp/YoutubeDL.py#L3514 + # pylint: enable=line-too-long + return self.kwargs_get(EXTRACTOR) or self.kwargs(IE_KEY) @property def epoch(self: "BaseEntry") -> int: diff --git a/src/ytdl_sub/entries/variables/kwargs.py b/src/ytdl_sub/entries/variables/kwargs.py index 715ba43a..75bf944d 100644 --- a/src/ytdl_sub/entries/variables/kwargs.py +++ b/src/ytdl_sub/entries/variables/kwargs.py @@ -50,6 +50,7 @@ SPLIT_BY_CHAPTERS_PARENT_ENTRY = _("split_by_chapters_parent_entry", backend=Tru COMMENTS = _("comments", backend=True) UID = _("id") EXTRACTOR = _("extractor") +IE_KEY = _("ie_key") EPOCH = _("epoch") CHANNEL = _("channel") EXT = _("ext") diff --git a/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py b/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py index 82e047b1..c05cf676 100644 --- a/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py +++ b/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py @@ -11,6 +11,7 @@ from typing import Optional from typing import Set from yt_dlp import DateRange +from yt_dlp.utils import make_archive_id from ytdl_sub.entries.entry import Entry from ytdl_sub.entries.variables.kwargs import SPLIT_BY_CHAPTERS_PARENT_ENTRY @@ -313,7 +314,7 @@ class DownloadMappings: """ lines: List[str] = [] for entry_id, metadata in self._entry_mappings.items(): - lines.append(f"{metadata.extractor} {entry_id}") + lines.append(make_archive_id(ie=metadata.extractor, video_id=entry_id)) return DownloadArchive(download_archive_lines=lines) diff --git a/tests/e2e/bandcamp/test_bandcamp.py b/tests/e2e/bandcamp/test_bandcamp.py index 88cc6b3a..8d0703d0 100644 --- a/tests/e2e/bandcamp/test_bandcamp.py +++ b/tests/e2e/bandcamp/test_bandcamp.py @@ -1,7 +1,9 @@ import pytest +from conftest import assert_logs from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +import ytdl_sub.downloaders.downloader from ytdl_sub.subscriptions.subscription import Subscription @@ -59,3 +61,19 @@ class TestBandcamp: dry_run=dry_run, expected_download_summary_file_name="bandcamp/test_artist_url.json", ) + + # Ensure another invocation will hit ExistingVideoReached + if not dry_run: + with assert_logs( + logger=ytdl_sub.downloaders.downloader.download_logger, + expected_message="ExistingVideoReached, stopping additional downloads", + log_level="debug", + ): + transaction_log = discography_subscription.download() + + assert transaction_log.is_empty + assert_expected_downloads( + output_directory=output_directory, + dry_run=dry_run, + expected_download_summary_file_name="bandcamp/test_artist_url.json", + )