From 538851e847c3289ce6f4502e2f80e2fb120f1803 Mon Sep 17 00:00:00 2001 From: Jules-WinnfieldX Date: Sun, 28 Jan 2024 09:31:43 -0700 Subject: [PATCH] Fix skip by download size marking as previous download --- cyberdrop_dl/__init__.py | 2 +- cyberdrop_dl/downloader/downloader.py | 14 ++++++++++---- pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py index b20843111..531ea29b0 100644 --- a/cyberdrop_dl/__init__.py +++ b/cyberdrop_dl/__init__.py @@ -1 +1 @@ -__version__ = "5.1.54" \ No newline at end of file +__version__ = "5.1.55" \ No newline at end of file diff --git a/cyberdrop_dl/downloader/downloader.py b/cyberdrop_dl/downloader/downloader.py index cfa11302f..0bb5db822 100644 --- a/cyberdrop_dl/downloader/downloader.py +++ b/cyberdrop_dl/downloader/downloader.py @@ -215,17 +215,19 @@ async def set_additional_headers(self) -> None: self._additional_headers["Authorization"] = await self.manager.download_manager.basic_auth("Cyberdrop-DL", self.manager.config_manager.authentication_data['PixelDrain']['pixeldrain_api_key']) async def get_final_file_info(self, complete_file: Path, partial_file: Path, - media_item: MediaItem) -> tuple[Path, Path, bool]: + media_item: MediaItem) -> tuple[Path, Path, bool, bool]: """Complicated checker for if a file already exists, and was already downloaded""" expected_size = media_item.filesize if isinstance(media_item.filesize, int) else None proceed = True + skip = False while True: if not expected_size: media_item.filesize = await self.client.get_filesize(media_item) file_size_check = await self.check_filesize_limits(media_item) if not file_size_check: proceed = False - return complete_file, partial_file, proceed + skip = True + return complete_file, partial_file, proceed, skip if not complete_file.exists() and not partial_file.exists(): break @@ -266,7 +268,7 @@ async def get_final_file_info(self, complete_file: Path, partial_file: Path, partial_file = complete_file.with_suffix(complete_file.suffix + '.part') media_item.download_filename = complete_file.name - return complete_file, partial_file, proceed + return complete_file, partial_file, proceed, skip async def iterate_filename(self, complete_file: Path, media_item: MediaItem) -> Tuple[Path, Path]: """Iterates the filename until it is unique""" @@ -317,9 +319,13 @@ async def download(self, media_item: MediaItem) -> None: complete_file = download_dir / media_item.filename partial_file = complete_file.with_suffix(complete_file.suffix + '.part') - complete_file, partial_file, proceed = await self.get_final_file_info(complete_file, partial_file, media_item) + complete_file, partial_file, proceed, skip_by_config = await self.get_final_file_info(complete_file, partial_file, media_item) await self.mark_incomplete(media_item) + if skip_by_config: + await self.manager.progress_manager.download_progress.add_skipped() + return + if not proceed: await log(f"Skipping {media_item.url} as it has already been downloaded", 10) await self.manager.progress_manager.download_progress.add_previously_completed(False) diff --git a/pyproject.toml b/pyproject.toml index 5c6dc61a1..7dd4ea3ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cyberdrop-dl" -version = "5.1.54" +version = "5.1.55" description = "Bulk downloader for multiple file hosts" authors = ["Jules Winnfield "] readme = "README.md"