Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: do not re hash already downloaded items (#142)
NTFSvolume15517aa09762
diff --git a/cyberdrop_dl/hasher.py b/cyberdrop_dl/hasher.pyindex a3908d179..844d9b9a0 100644--- a/cyberdrop_dl/hasher.py+++ b/cyberdrop_dl/hasher.py@@ -61,6 +61,7 @@ class Hasher:)_sem: asyncio.BoundedSemaphore = dataclasses.field(init=False, default_factory=lambda: asyncio.BoundedSemaphore(20))_cwd: Path = dataclasses.field(init=False, default_factory=Path.cwd)+ _hashed_items: set[tuple[str, ...]] = dataclasses.field(default_factory=set)@propertydef config(self) -> DupeCleanup:@@ -126,6 +127,7 @@ class Hasher:if not await aio.get_size(file):return+ logger.info("Computing hashes of '%s'", file)hash = await self._update_db_and_retrive_hash(file, original_filename, referer, hash_type="xxh128")if self.config.add_md5_hash:await self._update_db_and_retrive_hash(file, original_filename, referer, hash_type="md5")@@ -180,6 +182,7 @@ class Hasher:if hash:media_item.hash = hashself.hashes_dict[hash][size].add(absolute_path)+ self._hashed_items.add(media_item.id)async def cleanup_dupes_after_download(self) -> None:if self.config.hashing == Hashing.OFF:@@ -232,13 +235,14 @@ class Hasher:self._sem.release()async def get_file_hashes_dict(self) -> dict[str, dict[int, set[Path]]]:- downloads = self.manager.completed_downloadsasync def exists(item: MediaItem) -> MediaItem | None:if await aio.is_file(item.path):return item- results = await asyncio.gather(*(exists(item) for item in downloads))+ results = await asyncio.gather(+ *(exists(item) for item in self.manager.completed_downloads if item.id not in self._hashed_items)+ )for media_item in results:if media_item is None:continuediff --git a/cyberdrop_dl/managers/manager.py b/cyberdrop_dl/managers/manager.pyindex c767e5249..a3378c798 100644--- a/cyberdrop_dl/managers/manager.py+++ b/cyberdrop_dl/managers/manager.py@@ -129,11 +129,11 @@ class AppData:@classmethoddef default(cls) -> Self:- return cls.from_path(Path("AppData"))+ return cls.from_path(Path.cwd())@classmethoddef from_path(cls, path: Path) -> Self:- path = path.expanduser().resolve().absolute()+ path = path.expanduser().resolve().absolute() / "AppData"cache = path / "Cache"configs = path / "Configs"return cls(