Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Simplify skip hosts options creation
Arkadiy Illarionov05236bf1e0c6
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex 3380dd6b3..ab31c9a9f 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -35,22 +35,8 @@ def parse_args():parser.add_argument("--separate-posts", help="Separates thotsbay scraping into folders by post number", action="store_true")parser.add_argument("--thotsbay-username", type=str, help="username to login to thotsbay", default=None)parser.add_argument("--thotsbay-password", type=str, help="password to login to thotsbay", default=None)- parser.add_argument("--skip-anonfiles", help="This removes anonfile links from downloads", action="store_true")- parser.add_argument("--skip-bunkr", help="This removes bunkr links from downloads", action="store_true")- parser.add_argument("--skip-coomer", help="This removes coomer links from downloads", action="store_true")- parser.add_argument("--skip-cyberdrop", help="This removes cyberdrop links from downloads", action="store_true")- parser.add_argument("--skip-cyberfile", help="This removes cyberfile links from downloads", action="store_true")- parser.add_argument("--skip-erome", help="This removes erome links from downloads", action="store_true")- parser.add_argument("--skip-gfycat", help="This removes gfycat links from downloads", action="store_true")- parser.add_argument("--skip-gofile", help="This removes gofile links from downloads", action="store_true")- parser.add_argument("--skip-jpgchurch", help="This removes jpg.church links from downloads", action="store_true")- parser.add_argument("--skip-kemono", help="This removes kemono links from downloads", action="store_true")- parser.add_argument("--skip-pixeldrain", help="This removes pixeldrain links from downloads", action="store_true")- parser.add_argument("--skip-pixl", help="This removes pixl links from downloads", action="store_true")- parser.add_argument("--skip-putmega", help="This removes putmega links from downloads", action="store_true")- parser.add_argument("--skip-redgif", help="This removes redgif links from downloads", action="store_true")- parser.add_argument("--skip-saint", help="This removes saint.to links from downloads", action="store_true")- parser.add_argument("links", metavar="link", nargs="*",help="link to content to download (passing multiple links is supported)", default=[])+ parser.add_argument("--skip", dest="skip_hosts", choices=SkipData.supported_hosts, help="This removes host links from downloads", action="append")+ parser.add_argument("links", metavar="link", nargs="*", help="link to content to download (passing multiple links is supported)", default=[])args = parser.parse_args()return args@@ -77,10 +63,7 @@ async def download_all(args: argparse.Namespace):links += await regex_links(f.read())thotsbay_auth = AuthData(args.thotsbay_username, args.thotsbay_password)skip_data = SkipData()- await skip_data.add_skips(args.skip_anonfiles, args.skip_bunkr, args.skip_coomer, args.skip_cyberdrop,- args.skip_cyberfile, args.skip_erome, args.skip_gfycat, args.skip_gofile,- args.skip_jpgchurch, args.skip_kemono, args.skip_pixeldrain, args.skip_pixl,- args.skip_putmega, args.skip_redgif, args.skip_saint)+ await skip_data.add_skips(args.skip_hosts)content_object = await scrape(links, args.include_id, thotsbay_auth, args.separate_posts, skip_data)if await content_object.is_empty():logging.error(f'ValueError No links')@@ -128,7 +111,6 @@ def main(args=None):loop.close()-if __name__ == '__main__':print("""STOP! If you're just trying to download files, check the README.md file for instructions.diff --git a/cyberdrop_dl/utils/data_classes.py b/cyberdrop_dl/utils/data_classes.pyindex 39b5e67a8..cd3ac114f 100644--- a/cyberdrop_dl/utils/data_classes.py+++ b/cyberdrop_dl/utils/data_classes.py@@ -1,6 +1,6 @@import asynciofrom dataclasses import dataclass-from typing import Dict, List, Optional, Tuple+from typing import ClassVar, Dict, List, Optional, Tupleimport aiohttpfrom yarl import URL@@ -142,43 +142,15 @@ class AuthData:@dataclassclass SkipData:- sites = {"anonfiles.com": False, "bunkr": False, "coomer.party": False,- "cyberdrop": False, "cyberfile.is": False, "erome.com": False, "gfycat.com": False,- "gofile.io": False, "jpg.church": False, "kemono.party": False, "pixeldrain.com": False,- "pixl.is": False, "putme.ga": False, "putmega.com": False, "redgifs.com": False,- "saint.to": False, "thotsbay.com": False}-- async def add_skips(self, anonfiles, bunkr, coomer, cyberdrop, cyberfile, erome, gfycat, gofile, jpgchurch,- kemono, pixeldrain, pixl, putmega, redgifs, saint):- if anonfiles:- self.sites['anonfiles.com'] = True- if bunkr:- self.sites['bunkr'] = True- if coomer:- self.sites['coomer.party'] = True- if cyberdrop:- self.sites['cyberdrop'] = True- if cyberfile:- self.sites['cyberfile.is'] = True- if erome:- self.sites['erome.com'] = True- if gfycat:- self.sites['gfycat.com'] = True- if gofile:- self.sites['gofile.io'] = True- if jpgchurch:- self.sites['jpg.church'] = True- if kemono:- self.sites['kemono.party'] = True- if pixeldrain:- self.sites['pixeldrain.com'] = True- if pixl:- self.sites['pixl.is'] = True- if putmega:- self.sites['putme.ga'] = True- self.sites['putmega.com'] = True- if redgifs:- self.sites['redgifs.com'] = True- if saint:- self.sites['saint.to'] = True-+ supported_hosts: ClassVar[Tuple[str]] = (+ "anonfiles.com", "bunkr", "coomer.party", "cyberdrop", "cyberfile.is",+ "erome.com", "gfycat.com", "gofile.io", "jpg.church", "kemono.party",+ "pixeldrain.com", "pixl.is", "putme.ga", "putmega.com", "redgifs.com",+ "saint.to", "thotsbay.com")+ sites = {host: False for host in supported_hosts}++ async def add_skips(self, skip_hosts: List[str]):+ if not skip_hosts:+ return+ for host in skip_hosts:+ self.sites[host] = True