Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Use proper extractor key for download archive #840

Merged
merged 4 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/ytdl_sub/entries/base_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

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
Expand Down Expand Up @@ -100,12 +99,12 @@ def extractor(self: "BaseEntry") -> str:
Returns
-------
str
The ytdl extractor name
The ytdl extractor name used in the download archive
"""
# 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)
return str(self.kwargs_get("extractor_key") or self.kwargs(IE_KEY)).lower()

@property
def epoch(self: "BaseEntry") -> int:
Expand Down
18 changes: 18 additions & 0 deletions tests/e2e/soundcloud/test_soundcloud_discography.py
Original file line number Diff line number Diff line change
@@ -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

from ytdl_sub.downloaders.ytdlp import YTDLP
from ytdl_sub.subscriptions.subscription import Subscription


Expand Down Expand Up @@ -48,3 +50,19 @@ def test_discography_download(
dry_run=dry_run,
expected_download_summary_file_name="soundcloud/test_soundcloud_discography.json",
)

# Ensure another invocation will hit ExistingVideoReached
if not dry_run:
with assert_logs(
logger=YTDLP.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="soundcloud/test_soundcloud_discography.json",
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
".ytdl-sub-Sithu Aye-download-archive.json": "0c58919b660f699f6aea2ec523c812c5",
".ytdl-sub-Sithu Aye-download-archive.json": "ca37a404a860a2a6b6b0f38b659c9f17",
"Sithu Aye/[2021] 10 Years: Remixes and Reimaginings/01 - Double Helix Reimagined.mp3": "56f7ee579031f4795230e68b63b15f6b",
"Sithu Aye/[2021] 10 Years: Remixes and Reimaginings/02 - Skye Reimagined.mp3": "dfb24e0ef03e203d471bb81f854f5cd3",
"Sithu Aye/[2021] 10 Years: Remixes and Reimaginings/03 - Baryofusion.mp3": "95bd9ab2238e5372f445c59daafd0138",
Expand Down
1 change: 1 addition & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def _mock_entry_dict_factory(
PLAYLIST_INDEX: playlist_index,
PLAYLIST_COUNT: playlist_count,
EXTRACTOR: "mock-entry-dict",
"extractor_key": "mock-entry-dict",
TITLE: f"Mock Entry {uid}",
EXT: "mp4",
UPLOAD_DATE: upload_date,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/entries/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def mock_entry_kwargs(
"id": uid,
"epoch": 1596878400,
"extractor": extractor,
"extractor_key": extractor,
"title": title,
"ext": ext,
"upload_date": upload_date,
Expand Down
Loading