ytdl-sub/tests/e2e/soundcloud/test_soundcloud_discography.py
Jesse Bannon 4d9a30779c
[BUGFIX] Use proper extractor key for download archive (#840)
For less popular sites, ytdl-sub's custom download archive was not working. This was because we weren't using the right extraction key (though it still worked for YouTube, Bandcamp, Soundcloud, and others). This bugfix should now exactly match yt-dlp's and never be a problem again.

Huge thanks to @Svagtlys for root-causing this 🤝
2023-12-14 17:04:03 -08:00

68 lines
2.3 KiB
Python

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
@pytest.fixture
def subscription_dict(output_directory):
return {
"preset": "SoundCloud Discography",
"audio_extract": {"codec": "mp3", "quality": 320},
"overrides": {
"subscription_value": "https://soundcloud.com/jessebannon",
"subscription_indent_1": "Acoustic",
"music_directory": output_directory,
},
}
class TestSoundcloudDiscography:
"""
Downloads my (bad) SC recordings I made. Ensure the above files exist and have the
expected md5 file hashes.
"""
@pytest.mark.parametrize("dry_run", [True, False])
def test_discography_download(
self,
subscription_dict,
default_config,
output_directory,
dry_run,
):
discography_subscription = Subscription.from_dict(
preset_dict=subscription_dict,
preset_name="j_b",
config=default_config,
)
transaction_log = discography_subscription.download(dry_run=dry_run)
assert_transaction_log_matches(
output_directory=output_directory,
transaction_log=transaction_log,
transaction_log_summary_file_name="soundcloud/test_soundcloud_discography.txt",
)
assert_expected_downloads(
output_directory=output_directory,
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",
)