Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
add file writers
Jules-WinnfieldX6a05bb677a8c
diff --git a/cyberdrop_dl/managers/file_manager.py b/cyberdrop_dl/managers/file_manager.pyindex 41ecf99cd..f79d6c8c5 100644--- a/cyberdrop_dl/managers/file_manager.py+++ b/cyberdrop_dl/managers/file_manager.py@@ -1,8 +1,11 @@from dataclasses import fieldfrom typing import TYPE_CHECKING+import aiofiles+if TYPE_CHECKING:from pathlib import Path+ from yarl import URLclass FileManager:@@ -20,8 +23,33 @@ class FileManager:"""Startup process for the file manager"""self.input_file.touch(exist_ok=True)+ self.main_log.unlink(missing_ok=True)self.main_log.touch(exist_ok=True)+ self.last_post_log.unlink(missing_ok=True)self.last_post_log.touch(exist_ok=True)+ self.unsupported_urls_log.unlink(missing_ok=True)self.unsupported_urls_log.touch(exist_ok=True)+ self.download_error_log.unlink(missing_ok=True)self.download_error_log.touch(exist_ok=True)+ self.scrape_error_log.unlink(missing_ok=True)self.scrape_error_log.touch(exist_ok=True)++ async def write_last_post_log(self, url: 'URL') -> None:+ """Writes to the last post log"""+ async with aiofiles.open(self.last_post_log, 'a') as f:+ await f.write(f"{url}\n")++ async def write_unsupported_urls_log(self, url: 'URL') -> None:+ """Writes to the unsupported urls log"""+ async with aiofiles.open(self.unsupported_urls_log, 'a') as f:+ await f.write(f"{url}\n")++ async def write_download_error_log(self, url: 'URL', error_message: str) -> None:+ """Writes to the download error log"""+ async with aiofiles.open(self.download_error_log, 'a') as f:+ await f.write(f"{url},{error_message}\n")++ async def write_scrape_error_log(self, url: 'URL', error_message: str) -> None:+ """Writes to the scrape error log"""+ async with aiofiles.open(self.scrape_error_log, 'a') as f:+ await f.write(f"{url},{error_message}\n")