Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Use local count variables (#444)
Arkadiy Illarionova0797b936931
diff --git a/cyberdrop_dl/base_functions/sorting_functions.py b/cyberdrop_dl/base_functions/sorting_functions.pyindex 012a38b3a..f616a488d 100644--- a/cyberdrop_dl/base_functions/sorting_functions.py+++ b/cyberdrop_dl/base_functions/sorting_functions.py@@ -16,11 +16,6 @@ class Sorter:self.video_dir = video_dirself.other_dir = other_dir- self.audio = 0- self.images = 0- self.videos = 0- self.other = 0-async def find_files_in_dir(self, directory: Path):file_list = []for x in directory.iterdir():@@ -31,6 +26,11 @@ class Sorter:return file_listasync def sort(self):+ audio_count = 0+ image_count = 0+ video_count = 0+ other_count = 0+for folder in self.download_dir.iterdir():if not folder.is_dir():continue@@ -45,28 +45,28 @@ class Sorter:ext = file.suffix.lower()if '.part' in ext:continue- elif ext in FILE_FORMATS['Audio']:+ if ext in FILE_FORMATS['Audio']:audio_destination.mkdir(parents=True, exist_ok=True)await self.move_cd(file, audio_destination)- self.audio += 1+ audio_count += 1elif ext in FILE_FORMATS['Images']:image_destination.mkdir(parents=True, exist_ok=True)await self.move_cd(file, image_destination)- self.images += 1+ image_count += 1elif ext in FILE_FORMATS['Videos']:video_destination.mkdir(parents=True, exist_ok=True)await self.move_cd(file, video_destination)- self.videos += 1+ video_count += 1else:other_destination.mkdir(parents=True, exist_ok=True)await self.move_cd(file, other_destination)- self.other += 1+ other_count += 1await asyncio.sleep(5)await purge_dir(self.download_dir)- await log(f"Organized: {self.audio} Audio Files", style="green")- await log(f"Organized: {self.images} Image Files", style="green")- await log(f"Organized: {self.videos} Video Files", style="green")- await log(f"Organized: {self.other} Other Files", style="green")+ await log(f"Organized: {audio_count} Audio Files", style="green")+ await log(f"Organized: {image_count} Image Files", style="green")+ await log(f"Organized: {video_count} Video Files", style="green")+ await log(f"Organized: {other_count} Other Files", style="green")async def move_cd(self, file: Path, dest: Path):try: