From ec61eb895f6aa80d6f868b812771797aeba51a81 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Tue, 13 Dec 2022 00:09:16 -0800 Subject: [PATCH] [BACKEND] Bandcamp e2e test, update music example --- examples/music_audio_from_videos.yaml | 88 +++--- tests/e2e/bandcamp/__init__.py | 0 tests/e2e/bandcamp/test_bandcamp.py | 62 +++++ .../bandcamp/test_artist_url.json | 29 ++ .../bandcamp/test_artist_url.txt | 256 ++++++++++++++++++ 5 files changed, 404 insertions(+), 31 deletions(-) create mode 100644 tests/e2e/bandcamp/__init__.py create mode 100644 tests/e2e/bandcamp/test_bandcamp.py create mode 100644 tests/resources/expected_downloads_summaries/bandcamp/test_artist_url.json create mode 100644 tests/resources/transaction_log_summaries/bandcamp/test_artist_url.txt diff --git a/examples/music_audio_from_videos.yaml b/examples/music_audio_from_videos.yaml index 153a9034..b3befe9b 100644 --- a/examples/music_audio_from_videos.yaml +++ b/examples/music_audio_from_videos.yaml @@ -1,60 +1,86 @@ # Extracts audio from YouTube videos, converts it to mp3, and adds audio tags to it. configuration: working_directory: '.ytdl-sub-downloads' + umask: "002" presets: - song: + single: download: download_strategy: "url" url: "{url}" output_options: output_directory: "{music_directory}" - file_name: "{custom_track_name_sanitized}.{ext}" + file_name: "{track_full_path}" + thumbnail_name: "{album_cover_path}" + + ytdl_options: + break_on_existing: True audio_extract: codec: "mp3" - quality: 128 + quality: 320 music_tags: - embed_thumbnail: False # Set to True to embed album art tags: - artist: "{custom_artist_name}" - artists: "{custom_artist_name}" - albumartist: "{custom_artist_name}" - albumartists: "{custom_artist_name}" - title: "{custom_track_name}" - album: "{custom_album_name}" - track: "{custom_track_number}" - year: "{upload_year}" - genre: "Unset" + artist: "{track_artist}" + artists: "{track_artist}" + albumartist: "{track_artist}" + albumartists: "{track_artist}" + title: "{track_title}" + album: "{track_album}" + track: "{track_number}" + tracktotal: "{track_total}" + year: "{track_year}" + genre: "{track_genre}" overrides: - music_directory: "/path/to/music" - custom_track_name: "{title}" - custom_album_name: "Singles" - custom_artist_name: "{channel}" - custom_track_number: "1" + # Track Overrides + track_title: "{title}" + track_album: "Singles" + track_artist: "{channel}" + track_number: "1" + track_number_padded: "01" + track_total: "1" + track_year: "{upload_year}" + track_genre: "Unset" + # Directory Overrides + music_directory: "/music/tagged_manual" + artist_dir: "{track_artist_sanitized}" + album_dir: "[{track_year}] {track_album_sanitized}" + track_file_name: "{track_number_padded} - {track_title_sanitized}.{ext}" + track_full_path: "{artist_dir}/{album_dir}/{track_file_name}" + album_cover_path: "{artist_dir}/{album_dir}/folder.{thumbnail_ext}" - # TODO: make a playlist of individual songs into an album. Need playlist_title - song_playlist: - preset: "song" - overrides: - custom_track_number: "{playlist_index}" - album_from_chapters: - preset: "song" + albums_from_playlists: + preset: "single" + output_options: - file_name: "{custom_album_name_sanitized}/{chapter_index_padded} - {custom_track_name_sanitized}.{ext}" - thumbnail_name: "{custom_album_name_sanitized}/folder.{thumbnail_ext}" + maintain_download_archive: True + + overrides: + track_album: "{playlist_title}" + track_number: "{playlist_index}" + track_number_padded: "{playlist_index_padded}" + track_total: "{playlist_count}" + track_year: "{playlist_max_upload_year}" + + + albums_from_chapters: + preset: "single" + + output_options: + maintain_download_archive: True chapters: embed_chapters: True - split_by_chapters: when_no_chapters: "pass" overrides: - custom_track_name: "{chapter_title}" - custom_album_name: "{title}" # Have the video name be the album - custom_track_number: "{chapter_index}" + track_title: "{chapter_title}" # Chapter title is the track title + track_album: "{title}" # Video's title is the album title + track_number: "{chapter_index}" + track_number_padded: "{chapter_index_padded}" + track_total: "{chapter_count}" \ No newline at end of file diff --git a/tests/e2e/bandcamp/__init__.py b/tests/e2e/bandcamp/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/e2e/bandcamp/test_bandcamp.py b/tests/e2e/bandcamp/test_bandcamp.py new file mode 100644 index 00000000..9235f7be --- /dev/null +++ b/tests/e2e/bandcamp/test_bandcamp.py @@ -0,0 +1,62 @@ +import pytest +from expected_download import assert_expected_downloads +from expected_transaction_log import assert_transaction_log_matches + +from ytdl_sub.subscriptions.subscription import Subscription + + +@pytest.fixture +def subscription_dict(output_directory): + return { + "preset": "albums_from_playlists", + "ytdl_options": { + "max_downloads": 20, + }, + "regex": { + "skip_if_match_fails": False, # Error if regex match fails + "from": { + "title": { + "match": ["^(.*) - (.*)"], # Captures 'title' from 'Emily Hopkins - title' + "capture_group_names": [ + "captured_track_artist", + "captured_track_title", + ], + } + }, + }, + "overrides": { + "url": "https://funkypselicave.bandcamp.com/", + "track_title": "{captured_track_title}", + "track_artist": "{captured_track_artist}", + "music_directory": output_directory, + }, + } + + +class TestBandcamp: + @pytest.mark.parametrize("dry_run", [True, False]) + def test_download_artist_url( + self, + subscription_dict, + youtube_audio_config, + output_directory, + dry_run, + ): + discography_subscription = Subscription.from_dict( + preset_dict=subscription_dict, + preset_name="jb", + config=youtube_audio_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="bandcamp/test_artist_url.txt", + regenerate_transaction_log=True, + ) + assert_expected_downloads( + output_directory=output_directory, + dry_run=dry_run, + expected_download_summary_file_name="bandcamp/test_artist_url.json", + regenerate_expected_download_summary=True, + ) diff --git a/tests/resources/expected_downloads_summaries/bandcamp/test_artist_url.json b/tests/resources/expected_downloads_summaries/bandcamp/test_artist_url.json new file mode 100644 index 00000000..b4dcbc9b --- /dev/null +++ b/tests/resources/expected_downloads_summaries/bandcamp/test_artist_url.json @@ -0,0 +1,29 @@ +{ + ".ytdl-sub-jb-download-archive.json": "bf8e8d45a64b100a02bb6b7a3589ae5a", + "El Jazzy Chavo/[2022] S950 Funk/01 - Spark it.mp3": "6f21b6f977609382fa9b9fa9817b28cc", + "El Jazzy Chavo/[2022] S950 Funk/02 - Astronomikal Funk.mp3": "870199f5e75ea170051122f7220e2f42", + "El Jazzy Chavo/[2022] S950 Funk/03 - Impulse.mp3": "3a14e5e034016ad131186caf94be00da", + "El Jazzy Chavo/[2022] S950 Funk/04 - September.mp3": "c58520ef3f7f8944151ee0fb95fb0ac5", + "El Jazzy Chavo/[2022] S950 Funk/05 - Interlune.mp3": "5a7365a253ac4a5af54e550508a40b66", + "El Jazzy Chavo/[2022] S950 Funk/06 - Ninjutsu Techniques.mp3": "07b3f74ef78cb0c869c86dded054b1e9", + "El Jazzy Chavo/[2022] S950 Funk/07 - Space Funk Flow.mp3": "fef74e222258c4845e8b51e05acd240f", + "El Jazzy Chavo/[2022] S950 Funk/08 - Cellar Groove.mp3": "743927c47df60e811d367f5ef969faaf", + "El Jazzy Chavo/[2022] S950 Funk/09 - Solar Wind.mp3": "dd97643e3dc5decefb543da3a6e31356", + "El Jazzy Chavo/[2022] S950 Funk/10 - Interlune II.mp3": "37717cbd8f837657047616743937595b", + "El Jazzy Chavo/[2022] S950 Funk/11 - Ghetto Anthem.mp3": "54089f39836d469f391f6850926a392d", + "El Jazzy Chavo/[2022] S950 Funk/12 - Street Degree.mp3": "ddd3dc74d9bc07b988e4e4da363624dd", + "El Jazzy Chavo/[2022] S950 Funk/13 - Trouble World.mp3": "90dacf561b52852312f9e3f06084bfca", + "El Jazzy Chavo/[2022] S950 Funk/14 - Relaxation.mp3": "12dc503e0f758ae0b962e941727f272b", + "El Jazzy Chavo/[2022] S950 Funk/15 - Journey From Within.mp3": "c593e610ac6853b3795781b6650fc59e", + "El Jazzy Chavo/[2022] S950 Funk/folder.jpg": "62e51365dd309e76a6323f927f6fcc94", + "Various Artists - Dooku/[2021] Jingles From The Slums/05 - Paradise Nebula.mp3": "c3fa57885d90a7de974f310f2bcf8e9d", + "Various Artists - Dooku/[2021] Jingles From The Slums/folder.jpg": "82dace520cccdbca4bc52b9ebfef918c", + "Various Artists - El Jazzy Chavo/[2021] Jingles From The Slums/03 - Map of your Hands.mp3": "912fc0a9465f4080e7d021a2badec07a", + "Various Artists - El Jazzy Chavo/[2021] Jingles From The Slums/folder.jpg": "cd5f8ba637098122c9ef5fe3852acd05", + "Various Artists - Flux The Cynic/[2021] Jingles From The Slums/04 - Seasons Change.mp3": "bb2e7f44a2b5295a4609b2d060ef0a5f", + "Various Artists - Flux The Cynic/[2021] Jingles From The Slums/folder.jpg": "c815d21326fe31c79494c2cafb1ec611", + "Various Artists - Junk33/[2021] Jingles From The Slums/01 - Brown Sugar.mp3": "bdd0be92dd3cfe5b7aae96943b19c3a8", + "Various Artists - Junk33/[2021] Jingles From The Slums/folder.jpg": "d8c7f323c415b134c183b8f8b1def9f1", + "Various Artists - Nigma/[2021] Jingles From The Slums/02 - Shine.mp3": "d7a9bf6436326ca658909319c4d62fb7", + "Various Artists - Nigma/[2021] Jingles From The Slums/folder.jpg": "303b7b90ade53a00f11f89b442b3207a" +} \ No newline at end of file diff --git a/tests/resources/transaction_log_summaries/bandcamp/test_artist_url.txt b/tests/resources/transaction_log_summaries/bandcamp/test_artist_url.txt new file mode 100644 index 00000000..d9276a02 --- /dev/null +++ b/tests/resources/transaction_log_summaries/bandcamp/test_artist_url.txt @@ -0,0 +1,256 @@ +Files created: +---------------------------------------- +{output_directory} + .ytdl-sub-jb-download-archive.json +{output_directory}/El Jazzy Chavo/[2022] S950 Funk + 01 - Spark it.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Spark it + track: 1 + tracktotal: 15 + year: 2022 + 02 - Astronomikal Funk.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Astronomikal Funk + track: 2 + tracktotal: 15 + year: 2022 + 03 - Impulse.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Impulse + track: 3 + tracktotal: 15 + year: 2022 + 04 - September.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: September + track: 4 + tracktotal: 15 + year: 2022 + 05 - Interlune.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Interlune + track: 5 + tracktotal: 15 + year: 2022 + 06 - Ninjutsu Techniques.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Ninjutsu Techniques + track: 6 + tracktotal: 15 + year: 2022 + 07 - Space Funk Flow.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Space Funk Flow + track: 7 + tracktotal: 15 + year: 2022 + 08 - Cellar Groove.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Cellar Groove + track: 8 + tracktotal: 15 + year: 2022 + 09 - Solar Wind.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Solar Wind + track: 9 + tracktotal: 15 + year: 2022 + 10 - Interlune II.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Interlune II + track: 10 + tracktotal: 15 + year: 2022 + 11 - Ghetto Anthem.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Ghetto Anthem + track: 11 + tracktotal: 15 + year: 2022 + 12 - Street Degree.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Street Degree + track: 12 + tracktotal: 15 + year: 2022 + 13 - Trouble World.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Trouble World + track: 13 + tracktotal: 15 + year: 2022 + 14 - Relaxation.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Relaxation + track: 14 + tracktotal: 15 + year: 2022 + 15 - Journey From Within.mp3 + Music Tags: + album: S950 Funk + albumartist: El Jazzy Chavo + albumartists: El Jazzy Chavo + artist: El Jazzy Chavo + artists: El Jazzy Chavo + genre: Unset + title: Journey From Within + track: 15 + tracktotal: 15 + year: 2022 + folder.jpg +{output_directory}/Various Artists - Dooku/[2021] Jingles From The Slums + 05 - Paradise Nebula.mp3 + Music Tags: + album: Jingles From The Slums + albumartist: Various Artists - Dooku + albumartists: Various Artists - Dooku + artist: Various Artists - Dooku + artists: Various Artists - Dooku + genre: Unset + title: Paradise Nebula + track: 5 + tracktotal: 14 + year: 2021 + folder.jpg +{output_directory}/Various Artists - El Jazzy Chavo/[2021] Jingles From The Slums + 03 - Map of your Hands.mp3 + Music Tags: + album: Jingles From The Slums + albumartist: Various Artists - El Jazzy Chavo + albumartists: Various Artists - El Jazzy Chavo + artist: Various Artists - El Jazzy Chavo + artists: Various Artists - El Jazzy Chavo + genre: Unset + title: Map of your Hands + track: 3 + tracktotal: 14 + year: 2021 + folder.jpg +{output_directory}/Various Artists - Flux The Cynic/[2021] Jingles From The Slums + 04 - Seasons Change.mp3 + Music Tags: + album: Jingles From The Slums + albumartist: Various Artists - Flux The Cynic + albumartists: Various Artists - Flux The Cynic + artist: Various Artists - Flux The Cynic + artists: Various Artists - Flux The Cynic + genre: Unset + title: Seasons Change + track: 4 + tracktotal: 14 + year: 2021 + folder.jpg +{output_directory}/Various Artists - Junk33/[2021] Jingles From The Slums + 01 - Brown Sugar.mp3 + Music Tags: + album: Jingles From The Slums + albumartist: Various Artists - Junk33 + albumartists: Various Artists - Junk33 + artist: Various Artists - Junk33 + artists: Various Artists - Junk33 + genre: Unset + title: Brown Sugar + track: 1 + tracktotal: 14 + year: 2021 + folder.jpg +{output_directory}/Various Artists - Nigma/[2021] Jingles From The Slums + 02 - Shine.mp3 + Music Tags: + album: Jingles From The Slums + albumartist: Various Artists - Nigma + albumartists: Various Artists - Nigma + artist: Various Artists - Nigma + artists: Various Artists - Nigma + genre: Unset + title: Shine + track: 2 + tracktotal: 14 + year: 2021 + folder.jpg \ No newline at end of file