From ed27c8485368247a134ac7adec595799becc22bd Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Thu, 26 Oct 2023 23:54:59 -0700 Subject: [PATCH] music video test, need to update no config --- examples/music_subscriptions.yaml | 2 +- examples/music_video_subscriptions.yaml | 25 +++++++ examples/music_videos_config.yaml | 65 ------------------- examples/music_videos_subscriptions.yaml | 24 ------- .../music_videos/music_videos.yaml | 4 ++ tests/conftest.py | 14 +--- tests/e2e/bandcamp/test_bandcamp.py | 4 +- tests/e2e/plugins/test_audio_extract.py | 16 ++--- tests/e2e/plugins/test_music_tags.py | 4 +- tests/e2e/plugins/test_split_by_chapters.py | 12 ++-- .../soundcloud/test_soundcloud_discography.py | 4 +- tests/unit/config/test_subscription.py | 21 +++++- 12 files changed, 71 insertions(+), 124 deletions(-) create mode 100644 examples/music_video_subscriptions.yaml delete mode 100644 examples/music_videos_config.yaml delete mode 100644 examples/music_videos_subscriptions.yaml diff --git a/examples/music_subscriptions.yaml b/examples/music_subscriptions.yaml index d0c1a184..4f6f0729 100644 --- a/examples/music_subscriptions.yaml +++ b/examples/music_subscriptions.yaml @@ -10,7 +10,7 @@ # 02 - Another Track.mp3 # folder.jpg -# Overrides to the prebuilt presets +# Override variables globally for all subscriptions __preset__: overrides: music_directory: "/music" diff --git a/examples/music_video_subscriptions.yaml b/examples/music_video_subscriptions.yaml new file mode 100644 index 00000000..330d1ef9 --- /dev/null +++ b/examples/music_video_subscriptions.yaml @@ -0,0 +1,25 @@ +# Files will be stored in the form of: +# +# music_videos/ +# Elton John/ +# Elton John - Rocketman.jpg +# Elton John - Rocketman.mp4 +# System of a Down/ +# System of a Down - Chop Suey.jpg +# System of a Down - Chop Suey.mp4 +# ... + +# Override variables globally for all subscriptions +__preset__: + overrides: + music_video_directory: "/music_videos" + +# Choose between Jellyfin/Kodi/Plex Music Videos +# "Jellyfin Music Videos": +# "Kodi Music Videos": +"Plex Music Videos": + = Pop: # Sets genre tag to "Pop" + "Rick Astley": "https://www.youtube.com/playlist?list=PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc" + "Michael Jackson": "https://www.youtube.com/playlist?list=OLAK5uy_mnY03zP6abNWH929q2XhGzWD_2uKJ_n8E" + = Blues: + "Eric Clapton": "https://www.youtube.com/playlist?list=PLABGggHhsbEeaRtdzqnxYoEINsJE_4GF4" diff --git a/examples/music_videos_config.yaml b/examples/music_videos_config.yaml deleted file mode 100644 index cdcf8b32..00000000 --- a/examples/music_videos_config.yaml +++ /dev/null @@ -1,65 +0,0 @@ -# This example shows how to download and format a music video OR playlist -# of music videos to display in Kodi as a music video. The format will -# look like: -# -# /path/to/Music Videos -# Elton John/ -# Elton John - Rocketman-thumb.jpg -# Elton John - Rocketman.mp4 -# Elton John - Rocketman.nfo -# System of a Down/ -# System of a Down - Chop Suey-thumb.jpg -# System of a Down - Chop Suey.mp4 -# System of a Down - Chop Suey.nfo -# ... -# -configuration: - working_directory: '.ytdl-sub-downloads' - -presets: - music_video: - # We will only use a single URL to download music video(s). - # Make {url} an override variable to set later. - download: - - "{url}" - - # For advanced YTDL users only; any YTDL parameter can be set here. - # To download age-restricted videos, you will need to set your cookie - # file here as a ytdl parameter. For more info, see - # https://ytdl-sub.readthedocs.io/en/latest/faq.html#download-age-restricted-youtube-videos - ytdl_options: - # cookiefile: "path/to/cookie_file.txt - break_on_existing: True # Stop downloads if it already exists - - # For each video downloaded, set the file and thumbnail name here. - # We set both with {music_video_name}, which is a variable we define in - # the overrides section further below to represent consistent naming format. - output_options: - output_directory: "{music_video_directory}" - file_name: "{music_video_name}.{ext}" - thumbnail_name: "{music_video_name}-thumb.jpg" - info_json_name: "{music_video_name}.{info_json_ext}" - maintain_download_archive: True - - # For each video downloaded, add a music video NFO file for it. Populate it - # with tags that Kodi will read and use to display it in the music or music - # videos section. - nfo_tags: - nfo_name: "{music_video_name}.nfo" - nfo_root: "musicvideo" - tags: - artist: "{artist}" - title: "{title}" - album: "Music Videos" - year: "{upload_year}" - - # Overrides is a section where we can define our own variables, and use them in - # any other section. We define our music video directory and episode file name - # here, which gets reused above for the video, thumbnail, and NFO file. - # Recommended to override the artist variable since {channel} is not always - # the artist's exact name. - overrides: - music_video_directory: "path/to/Music Videos" - music_video_name: "{artist_sanitized}/{artist_sanitized} - {title_sanitized}" - artist: "{channel}" - diff --git a/examples/music_videos_subscriptions.yaml b/examples/music_videos_subscriptions.yaml deleted file mode 100644 index f147b487..00000000 --- a/examples/music_videos_subscriptions.yaml +++ /dev/null @@ -1,24 +0,0 @@ -############################################################################### -# DOWNLOAD MUSIC VIDEO PLAYLIST -john_smith: - preset: "music_video" - overrides: - url: "https://youtube.com/playlist?list=UCsvn_Po0SmunchJYtttWpOxMg" - artist: "John Smith and the Instrument Players" - -############################################################################### -# DOWNLOAD SINGLE MUSIC VIDEO VIA CLI - -# It is not always ideal to download all of an artist's music videos. -# Maybe you only like one song of theirs. We can reuse our preset -# to download a single video instead. -# -# Of course, defining yaml configuration to download a single video once -# and never again seems weird. Instead, we can perform this download via -# command-line: -# -# ytdl-sub dl \ -# --preset "music_video" \ -# --overrides.url "https://youtube.com/watch?v=QhY6r6oAErg" \ -# --overrides.artist "John Smith and the Instrument Players" -# diff --git a/src/ytdl_sub/prebuilt_presets/music_videos/music_videos.yaml b/src/ytdl_sub/prebuilt_presets/music_videos/music_videos.yaml index 84f780bd..47c97996 100644 --- a/src/ytdl_sub/prebuilt_presets/music_videos/music_videos.yaml +++ b/src/ytdl_sub/prebuilt_presets/music_videos/music_videos.yaml @@ -7,6 +7,10 @@ presets: output_directory: "{music_video_directory}" file_name: "{music_video_file_name}.{ext}" thumbnail_name: "{music_video_file_name}.jpg" + maintain_download_archive: True + + ytdl_options: + break_on_existing: True overrides: # MUST DEFINE: diff --git a/tests/conftest.py b/tests/conftest.py index 5e2c4af7..a413747c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -157,19 +157,9 @@ def _load_config(config_path: Path, working_directory: str) -> ConfigFile: return ConfigFile.from_dict(config_dict) -@pytest.fixture() -def music_video_config_path() -> Path: - return Path("examples/music_videos_config.yaml") - - -@pytest.fixture() -def music_video_config(music_video_config_path, working_directory) -> ConfigFile: - return _load_config(music_video_config_path, working_directory) - - @pytest.fixture() def music_video_subscription_path() -> Path: - return Path("examples/music_videos_subscriptions.yaml") + return Path("examples/music_video_subscriptions.yaml") @pytest.fixture() @@ -185,7 +175,7 @@ def tv_show_subscriptions_path() -> Path: @pytest.fixture() -def music_audio_config(working_directory) -> ConfigFile: +def default_config(working_directory) -> ConfigFile: return ConfigFile.from_dict({"configuration": {"working_directory": working_directory}}) diff --git a/tests/e2e/bandcamp/test_bandcamp.py b/tests/e2e/bandcamp/test_bandcamp.py index b3eeb37e..ee90e065 100644 --- a/tests/e2e/bandcamp/test_bandcamp.py +++ b/tests/e2e/bandcamp/test_bandcamp.py @@ -29,14 +29,14 @@ class TestBandcamp: def test_prebuilt_preset_download( self, subscription_dict, - music_audio_config, + default_config, output_directory, dry_run, ): discography_subscription = Subscription.from_dict( preset_dict=subscription_dict, preset_name="Sithu Aye", - config=music_audio_config, + config=default_config, ) transaction_log = discography_subscription.download(dry_run=dry_run) assert_transaction_log_matches( diff --git a/tests/e2e/plugins/test_audio_extract.py b/tests/e2e/plugins/test_audio_extract.py index c2dc271b..08315486 100644 --- a/tests/e2e/plugins/test_audio_extract.py +++ b/tests/e2e/plugins/test_audio_extract.py @@ -71,13 +71,13 @@ class TestAudioExtract: @pytest.mark.parametrize("dry_run", [True, False]) def test_audio_extract_single_song_old_format( self, - music_audio_config, + default_config, single_preset_dict_old_format, output_directory, dry_run, ): subscription = Subscription.from_dict( - config=music_audio_config, + config=default_config, preset_name="single_song_test", preset_dict=single_preset_dict_old_format, ) @@ -97,13 +97,13 @@ class TestAudioExtract: @pytest.mark.parametrize("dry_run", [False]) def test_audio_extract_single_song( self, - music_audio_config, + default_config, single_preset_dict, output_directory, dry_run, ): subscription = Subscription.from_dict( - config=music_audio_config, + config=default_config, preset_name="single_song_test", preset_dict=single_preset_dict, ) @@ -123,13 +123,13 @@ class TestAudioExtract: @pytest.mark.parametrize("dry_run", [True, False]) def test_audio_extract_single_song_best_format( self, - music_audio_config, + default_config, single_best_format_preset_dict, output_directory, dry_run, ): subscription = Subscription.from_dict( - config=music_audio_config, + config=default_config, preset_name="single_song_best_test", preset_dict=single_best_format_preset_dict, ) @@ -149,13 +149,13 @@ class TestAudioExtract: @pytest.mark.parametrize("dry_run", [True, False]) def test_audio_extract_multiple_songs( self, - music_audio_config, + default_config, youtube_release_preset_dict, output_directory, dry_run, ): subscription = Subscription.from_dict( - config=music_audio_config, + config=default_config, preset_name="multiple_songs_test", preset_dict=youtube_release_preset_dict, ) diff --git a/tests/e2e/plugins/test_music_tags.py b/tests/e2e/plugins/test_music_tags.py index 82d08956..a5b13b68 100644 --- a/tests/e2e/plugins/test_music_tags.py +++ b/tests/e2e/plugins/test_music_tags.py @@ -23,12 +23,12 @@ def single_song_video_dict(output_directory): class TestMusicTags: def test_music_tags_errors_on_video( self, - music_audio_config, + default_config, single_song_video_dict, output_directory, ): subscription = Subscription.from_dict( - config=music_audio_config, + config=default_config, preset_name="single_song_test", preset_dict=single_song_video_dict, ) diff --git a/tests/e2e/plugins/test_split_by_chapters.py b/tests/e2e/plugins/test_split_by_chapters.py index b718a134..597a1fe4 100644 --- a/tests/e2e/plugins/test_split_by_chapters.py +++ b/tests/e2e/plugins/test_split_by_chapters.py @@ -70,13 +70,13 @@ class TestSplitByChapters: @pytest.mark.parametrize("dry_run", [True, False]) def test_video_with_chapters( self, - music_audio_config, + default_config, yt_album_as_chapters_preset_dict, output_directory, dry_run, ): subscription = Subscription.from_dict( - config=music_audio_config, + config=default_config, preset_name="Proved Records", preset_dict=yt_album_as_chapters_preset_dict, ) @@ -100,13 +100,13 @@ class TestSplitByChapters: @pytest.mark.parametrize("dry_run", [True, False]) def test_video_with_chapters_and_regex( self, - music_audio_config, + default_config, yt_album_as_chapters_with_regex_preset_dict, output_directory, dry_run, ): subscription = Subscription.from_dict( - config=music_audio_config, + config=default_config, preset_name="split_by_chapters_with_regex_video_preset", preset_dict=yt_album_as_chapters_with_regex_preset_dict, ) @@ -127,7 +127,7 @@ class TestSplitByChapters: @pytest.mark.parametrize("when_no_chapters", ["pass", "drop", "error"]) def test_video_with_no_chapters_and_regex( self, - music_audio_config, + default_config, yt_album_as_chapters_with_regex_preset_dict, output_directory, dry_run, @@ -142,7 +142,7 @@ class TestSplitByChapters: ) subscription = Subscription.from_dict( - config=music_audio_config, + config=default_config, preset_name="split_by_chapters_with_regex_video_no_chapters", preset_dict=yt_album_as_chapters_with_regex_preset_dict, ) diff --git a/tests/e2e/soundcloud/test_soundcloud_discography.py b/tests/e2e/soundcloud/test_soundcloud_discography.py index 0d003f2b..de1f4a4f 100644 --- a/tests/e2e/soundcloud/test_soundcloud_discography.py +++ b/tests/e2e/soundcloud/test_soundcloud_discography.py @@ -28,14 +28,14 @@ class TestSoundcloudDiscography: def test_discography_download( self, subscription_dict, - music_audio_config, + default_config, output_directory, dry_run, ): discography_subscription = Subscription.from_dict( preset_dict=subscription_dict, preset_name="j_b", - config=music_audio_config, + config=default_config, ) transaction_log = discography_subscription.download(dry_run=dry_run) assert_transaction_log_matches( diff --git a/tests/unit/config/test_subscription.py b/tests/unit/config/test_subscription.py index b64272f0..097e738c 100644 --- a/tests/unit/config/test_subscription.py +++ b/tests/unit/config/test_subscription.py @@ -368,9 +368,9 @@ def test_tv_show_subscriptions( assert jake_train_overrides["subscription_indent_2"] == "TV-Y" -def test_music_subscriptions(music_audio_config: ConfigFile, music_subscriptions_path: Path): +def test_music_subscriptions(default_config: ConfigFile, music_subscriptions_path: Path): subs = Subscription.from_file_path( - config=music_audio_config, subscription_path=music_subscriptions_path + config=default_config, subscription_path=music_subscriptions_path ) assert len(subs) == 14 @@ -380,3 +380,20 @@ def test_music_subscriptions(music_audio_config: ConfigFile, music_subscriptions assert monk["subscription_name"] == "Stan Getz" assert monk["subscription_value"] == "https://www.youtube.com/@stangetzofficial/releases" assert monk["subscription_indent_1"] == "Jazz" + + +def test_music_video_subscriptions(default_config: ConfigFile, music_video_subscription_path: Path): + subs = Subscription.from_file_path( + config=default_config, subscription_path=music_video_subscription_path + ) + + assert len(subs) == 3 + assert subs[1].name == "Michael Jackson" + monk = subs[1].overrides.dict_with_format_strings + + assert monk["subscription_name"] == "Michael Jackson" + assert ( + monk["subscription_value"] + == "https://www.youtube.com/playlist?list=OLAK5uy_mnY03zP6abNWH929q2XhGzWD_2uKJ_n8E" + ) + assert monk["subscription_indent_1"] == "Pop"