Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Update readme, fix bugs.
Jules-WinnfieldXc6e5a9800a3f
diff --git a/README.md b/README.mdindex 65bef79bd..4378d6426 100644--- a/README.md+++ b/README.md@@ -12,7 +12,8 @@| Bunkr | Albums: bunkr.is/a/... <br> Direct Videos: stream.bunkr.is/v/... <br> Direct Videos: cdn.bunkr.is/... <br> Direct Images: i.bunkr.is/... <br> Also works with Bunkr.to || GoFile | Albums: gofile.io/d/... || Erome | Albums: erome.com/a/... |-| PixelDrain | Albums: Pixeldrain.com/l/... <br> Single Files: Pixeldrain.com/u/... |+| PixelDrain | Albums: Pixeldrain.com/l/... <br> Single Files: Pixeldrain.com/u/... |+| ThotsBay | Thread: Thotsbay.com/threads/... |Reminder to leave the link full (include the https://)@@ -64,20 +65,21 @@ positional arguments:link link to content to download (passing multiple links is supported)optional arguments:- -h, --help show this help message and exit- -V, --version show program's version number and exit- -i INPUT_FILE, --input-file INPUT_FILE- file containing links to download- -o OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER- folder to download files to- --log-file LOG_FILE log file to write to- --threads THREADS number of threads to use (0 = max)- --attempts ATTEMPTS number of attempts to download each file- --include-id include the ID in the download folder name- --exclude-videos exclude video files from downloading- --exclude-images exclude image files from downloading- --exclude-audio exclude audio files from downloading- --exclude-other exclude other files from downloading+ -h, --help show this help message and exit+ -V, --version show program's version number and exit+ -i INPUT_FILE, --input-file INPUT_FILE file containing links to download+ -o OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER folder to download files to+ --log-file LOG_FILE log file to write to+ --threads THREADS number of threads to use (0 = max)+ --attempts ATTEMPTS number of attempts to download each file+ --disable-attempt-limit disables stopping the program based on attempt limits+ --include-id include the ID in the download folder name+ --exclude-videos exclude video files from downloading+ --exclude-images exclude image files from downloading+ --exclude-audio exclude audio files from downloading+ --exclude-other exclude other files from downloading+ --thotsbay-username username to login to thotsbay (only required if the thread requires it)+ --thotsbay-password password to login to thotsbay (only required if the thread requires it)```# Creditdiff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex 63504d5dc..2080d6c2a 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -16,6 +16,7 @@ def parse_args():parser.add_argument("--log-file", help="log file to write to", default="downloader.log")parser.add_argument("--threads", type=int, help="number of threads to use (0 = max)", default=0)parser.add_argument("--attempts", type=int, help="number of attempts to download each file", default=10)+ parser.add_argument("--disable-attempt-limit", help="disables the attempt limitation", action="store_true")parser.add_argument("--include-id", help="include the ID in the download folder name", action="store_true")parser.add_argument("--exclude-videos", help="skip downloading of video files", action="store_true")parser.add_argument("--exclude-images", help="skip downloading of image files", action="store_true")@@ -50,6 +51,7 @@ async def download_all(args: argparse.Namespace):exit(0)clear()downloaders = get_downloaders(content_object, folder=Path(args.output_folder), attempts=args.attempts,+ disable_attempt_limit=args.disable_attempt_limit,threads=args.threads, exclude_videos=args.exclude_videos,exclude_images=args.exclude_images, exclude_audio=args.exclude_audio,exclude_other=args.exclude_other)diff --git a/cyberdrop_dl/utils/downloaders.py b/cyberdrop_dl/utils/downloaders.pyindex 96ea4b0e8..3601f8ed4 100644--- a/cyberdrop_dl/utils/downloaders.py+++ b/cyberdrop_dl/utils/downloaders.py@@ -22,12 +22,13 @@ class FailureException(Exception):def retry(f):@wraps(f)async def wrapper(self, *args, **kwargs):- for i in range(self.attempts):+ while True:try:return await f(self, *args, **kwargs)except FailureException:- if i >= self.attempts - 1:- raise+ if not self.disable_attempt_limit:+ if self.current_attempt >= self.attempts - 1:+ raiselogger.debug('Retrying...')time.sleep(2)return wrapper@@ -61,13 +62,15 @@ async def throttle(self, url: URL) -> None:class Downloader:- def __init__(self, album_obj: AlbumItem, cookie_jar, folder: Path, title: str, attempts: int, max_workers: int,+ def __init__(self, album_obj: AlbumItem, cookie_jar, folder: Path, title: str, attempts: int, disable_attempt_limit: bool, max_workers: int,exclude_videos: bool, exclude_images: bool, exclude_audio: bool, exclude_other: bool):self.album_obj = album_objself.cookie_jar = cookie_jarself.folder = folderself.title = titleself.attempts = attempts+ self.current_attempt = 0+ self.disable_attempt_limit = disable_attempt_limitself.max_workers = max_workersself.exclude_videos = exclude_videosself.exclude_images = exclude_images@@ -216,7 +219,7 @@ class Downloader:await self.download_all(self.album_obj, session, show_progress=show_progress)-def get_downloaders(Cascade: CascadeItem, folder: Path, attempts: int, threads: int, exclude_videos: bool,+def get_downloaders(Cascade: CascadeItem, folder: Path, attempts: int, disable_attempt_limit: bool, threads: int, exclude_videos: bool,exclude_images: bool, exclude_audio: bool, exclude_other: bool) -> List[Downloader]:"""Get a list of downloaders for each supported type of URLs.We shouldn't just assume that each URL will have the same netloc as@@ -235,7 +238,8 @@ def get_downloaders(Cascade: CascadeItem, folder: Path, attempts: int, threads:max_workers = 2 if (max_workers > 2) else max_workersfor title, album_obj in domain_obj.albums.items():downloader = Downloader(album_obj, cookie_jar=cookie_jar, title=title, folder=folder,- attempts=attempts, max_workers=max_workers, exclude_videos=exclude_videos,+ attempts=attempts, disable_attempt_limit=disable_attempt_limit,+ max_workers=max_workers, exclude_videos=exclude_videos,exclude_images=exclude_images, exclude_audio=exclude_audio,exclude_other=exclude_other)downloaders.append(downloader)diff --git a/cyberdrop_dl/utils/scraper.py b/cyberdrop_dl/utils/scraper.pyindex 42bac1bbd..3717ee671 100644--- a/cyberdrop_dl/utils/scraper.py+++ b/cyberdrop_dl/utils/scraper.py@@ -44,13 +44,14 @@ async def scrape(urls, include_id: bool, thotsbay_username: str, thotsbay_passwoCascade.add_albums(domain_item)# Returns a Cascade item+ tasks2 = []async with aiohttp.ClientSession(headers=headers, raise_for_status=True, cookie_jar=jar) as session:for url in Thotsbay_urls:- tasks.append(thotsbay_crawler.fetch(session, url))- results = await asyncio.gather(*tasks)+ tasks2.append(thotsbay_crawler.fetch(session, url))+ results = await asyncio.gather(*tasks2)- for result in results:- Cascade.extend(result)+ for result in results:+ Cascade.extend(result)Cascade.cookies = jar