implement skipping of file

This commit is contained in:
Hellow 2023-06-15 18:30:02 +02:00
parent 9bba470bd1
commit bf9269161d

View File

@ -382,6 +382,7 @@ class Page:
file=DOWNLOAD_FILE.format(**{part[1]: naming_dict[part[1]] for part in file_parts})
)
if song.target_collection.empty:
song.target_collection.append(new_target)
@ -394,16 +395,29 @@ class Page:
file=str(random.randint(0, 999999))
)
found_on_disc = False
target: Target
for target in song.target_collection:
if target.exists:
target.copy_content(temp_target)
found_on_disc = True
break
r = DownloadResult(1)
source = sources[0]
if not found_on_disc:
r = self.download_song_to_target(source=source, target=temp_target, desc=song.title)
else:
self.LOGGER.info(f"{song.option_string} already exists, thus not downloading again.")
if not r.is_fatal_error:
r.merge(self._post_process_targets(song, temp_target, source))
r.merge(self._post_process_targets(song, temp_target, [] if found_on_disc else self.get_skip_intervals(song, source)))
return r
def _post_process_targets(self, song: Song, temp_target: Target, source: Source) -> DownloadResult:
correct_codec(temp_target, interval_list=self.get_skip_intervals(song, source))
def _post_process_targets(self, song: Song, temp_target: Target, interval_list: List) -> DownloadResult:
correct_codec(temp_target, interval_list=interval_list)
self.post_process_hook(song, temp_target)