playlists working, need to fix retry
This commit is contained in:
parent
3708fde3ef
commit
3098a96f31
6 changed files with 94 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
|||
# TODO: add comments explaining stuff
|
||||
configuration:
|
||||
working_directory: '.ytdl-sub-downloads'
|
||||
|
||||
|
|
@ -26,3 +27,12 @@ presets:
|
|||
|
||||
overrides:
|
||||
music_directory: "/path/to/music"
|
||||
|
||||
yt_song_playlist:
|
||||
preset: yt_song
|
||||
youtube:
|
||||
download_strategy: "playlist"
|
||||
|
||||
music_tags:
|
||||
tags:
|
||||
track: "{playlist_index}"
|
||||
|
|
@ -132,7 +132,7 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT]
|
|||
|
||||
def extract_info_with_retry(
|
||||
self,
|
||||
is_downloaded_fn: Optional[Callable[[], bool]],
|
||||
is_downloaded_fn: Optional[Callable[[], bool]] = None,
|
||||
ytdl_options_overrides: Optional[Dict] = None,
|
||||
**kwargs,
|
||||
) -> Dict:
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ class YoutubePlaylistDownloader(
|
|||
# Re-download the contents even if it's a dry-run as a single video. At this time,
|
||||
# playlists do not download subtitles or subtitle metadata
|
||||
as_single_video_dict = self.extract_info_with_retry(
|
||||
is_downloaded_fn=None if self.is_dry_run else video.is_downloaded,
|
||||
ytdl_options_overrides={"writeinfojson": False, "skip_download": self.is_dry_run},
|
||||
url=video.kwargs("webpage_url"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,26 @@ def single_song_preset_dict(output_directory):
|
|||
"preset": "yt_song",
|
||||
"youtube": {"video_url": "https://www.youtube.com/watch?v=2lAe1cqCOXo"},
|
||||
"output_options": {"output_directory": output_directory},
|
||||
# download the worst format so it is fast
|
||||
"ytdl_options": {
|
||||
"format": "worst[ext=mp4]",
|
||||
},
|
||||
}
|
||||
|
||||
@pytest.fixture
|
||||
def multiple_songs_preset_dict(output_directory):
|
||||
return {
|
||||
"preset": "yt_song_playlist",
|
||||
"youtube": {"playlist_url": "https://youtube.com/playlist?list=PL5BC0FC26BECA5A35"},
|
||||
"output_options": {"output_directory": output_directory},
|
||||
"audio_extract": {
|
||||
"codec": "vorbis",
|
||||
"quality": 140
|
||||
},
|
||||
# download the worst format so it is fast
|
||||
"ytdl_options": {
|
||||
"format": "worst[ext=mp4]",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -43,3 +63,31 @@ class TestAudioExtract:
|
|||
expected_download_summary_file_name="plugins/test_audio_extract_single.json",
|
||||
regenerate_expected_download_summary=True,
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize("dry_run", [True, False])
|
||||
def test_audio_extract_multiple_songs(
|
||||
self,
|
||||
youtube_audio_config,
|
||||
multiple_songs_preset_dict,
|
||||
output_directory,
|
||||
dry_run,
|
||||
):
|
||||
subscription = Subscription.from_dict(
|
||||
config=youtube_audio_config,
|
||||
preset_name="multiple_songs_test",
|
||||
preset_dict=multiple_songs_preset_dict,
|
||||
)
|
||||
|
||||
transaction_log = subscription.download(dry_run=dry_run)
|
||||
assert_transaction_log_matches(
|
||||
output_directory=output_directory,
|
||||
transaction_log=transaction_log,
|
||||
transaction_log_summary_file_name="plugins/test_audio_extract_playlist.txt",
|
||||
regenerate_transaction_log=True,
|
||||
)
|
||||
assert_expected_downloads(
|
||||
output_directory=output_directory,
|
||||
dry_run=dry_run,
|
||||
expected_download_summary_file_name="plugins/test_audio_extract_playlist.json",
|
||||
regenerate_expected_download_summary=True,
|
||||
)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"Jesse's Minecraft Server [Trailer - Feb.1].ogg": "3f701a4b2437704bc443cf07c9832dae",
|
||||
"Jesse's Minecraft Server [Trailer - Feb.27].ogg": "430d1c8ec20573a73e2149c10c9c741f",
|
||||
"Jesse's Minecraft Server [Trailer - Mar.21].ogg": "11742c96e9ea3a520b2411d8b3516472"
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
Files created in '{output_directory}'
|
||||
----------------------------------------
|
||||
Jesse's Minecraft Server [Trailer - Feb.1].ogg
|
||||
Music Tags:
|
||||
album: Singles
|
||||
albumartist: Project Zombie
|
||||
artist: Project Zombie
|
||||
genre: Unset
|
||||
title: Jesse's Minecraft Server [Trailer - Feb.1]
|
||||
track: 3
|
||||
year: 2011
|
||||
Jesse's Minecraft Server [Trailer - Feb.27].ogg
|
||||
Music Tags:
|
||||
album: Singles
|
||||
albumartist: Project Zombie
|
||||
artist: Project Zombie
|
||||
genre: Unset
|
||||
title: Jesse's Minecraft Server [Trailer - Feb.27]
|
||||
track: 2
|
||||
year: 2011
|
||||
Jesse's Minecraft Server [Trailer - Mar.21].ogg
|
||||
Music Tags:
|
||||
album: Singles
|
||||
albumartist: Project Zombie
|
||||
artist: Project Zombie
|
||||
genre: Unset
|
||||
title: Jesse's Minecraft Server [Trailer - Mar.21]
|
||||
track: 1
|
||||
year: 2011
|
||||
Loading…
Reference in a new issue