From dd1e6d4dd627f0375c625f3864f6344679fde66e Mon Sep 17 00:00:00 2001 From: jbannon Date: Thu, 30 Jun 2022 23:34:04 +0000 Subject: [PATCH] dry-run actually dry running --- src/ytdl_sub/subscriptions/subscription.py | 2 ++ .../enhanced_download_archive.py | 22 +++++++++++++++++++ .../test_playlist_as_kodi_music_videos.py | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/ytdl_sub/subscriptions/subscription.py b/src/ytdl_sub/subscriptions/subscription.py index a7d5d01d..8284f912 100644 --- a/src/ytdl_sub/subscriptions/subscription.py +++ b/src/ytdl_sub/subscriptions/subscription.py @@ -236,6 +236,8 @@ class Subscription: If true, do not download any video/audio files or move anything to the output directory. """ + self._enhanced_download_archive.reinitialize(dry_run=dry_run) + # TODO: Move this logic to separate function # TODO: set id here as well ytdl_options = copy.deepcopy(self.ytdl_options.dict) diff --git a/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py b/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py index 3a4a4e43..36b6e490 100644 --- a/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py +++ b/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py @@ -350,6 +350,28 @@ class EnhancedDownloadArchive: self._logger = Logger.get(name=subscription_name) + def reinitialize(self, dry_run: bool) -> "EnhancedDownloadArchive": + """ + Re-initialize the enhanced download archive for successive downloads w/the same + subscription. + + Parameters + ---------- + dry_run + Whether to actually move files to the output directory + + Returns + ------- + self + """ + self._file_handler = FileHandler( + working_directory=self.working_directory, + output_directory=self.output_directory, + dry_run=dry_run, + ) + self._download_mapping = DownloadMappings() + return self + @property def archive_file_name(self) -> str: """ diff --git a/tests/e2e/youtube/test_playlist_as_kodi_music_videos.py b/tests/e2e/youtube/test_playlist_as_kodi_music_videos.py index 39e64400..f4aa5a71 100644 --- a/tests/e2e/youtube/test_playlist_as_kodi_music_videos.py +++ b/tests/e2e/youtube/test_playlist_as_kodi_music_videos.py @@ -151,5 +151,5 @@ class TestPlaylistAsKodiMusicVideo: def test_single_video_download( self, single_video_subscription, expected_single_video_download, output_directory ): - single_video_subscription.download() + single_video_subscription.download(dry_run=True) expected_single_video_download.assert_files_exist(relative_directory=output_directory)