Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Add groups and default values for options
Arkadiy Illarionovd6689990d797
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex 80a5905f7..a3273e2a4 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -8,7 +8,7 @@ import aiofilesfrom yarl import URLfrom cyberdrop_dl.base_functions.base_functions import clear, log, purge_dir-from cyberdrop_dl.base_functions.config_manager import run_args, document_args+from cyberdrop_dl.base_functions.config_manager import document_args, run_argsfrom cyberdrop_dl.base_functions.sorting_functions import Sorterfrom cyberdrop_dl.base_functions.sql_helper import SQLHelperfrom cyberdrop_dl.client.client import Client@@ -16,96 +16,105 @@ from cyberdrop_dl.downloader.downloader_utils import check_free_spacefrom cyberdrop_dl.downloader.downloaders import download_cascade, download_forumsfrom cyberdrop_dl.downloader.old_downloaders import old_download_cascade, old_download_forumsfrom cyberdrop_dl.scraper.Scraper import ScrapeMapper+from . import __version__ as VERSION-from .base_functions.data_classes import SkipData, CascadeItem+from .base_functions.data_classes import CascadeItem, SkipDatadef parse_args() -> argparse.Namespace:"""Parses the command line arguments passed into the program"""parser = argparse.ArgumentParser(description="Bulk downloader for multiple file hosts")- parser.add_argument("-V", "--version", action="version", version="%(prog)s " + VERSION)+ parser.add_argument("-V", "--version", action="version", version=f"%(prog)s {VERSION}")# Path options- parser.add_argument("-i", "--input-file", type=Path, help="file containing links to download", default="URLs.txt")- parser.add_argument("-o", "--output-folder", type=Path, help="folder to download files to", default="Downloads")+ path_opts = parser.add_argument_group("Path options")+ path_opts.add_argument("-i", "--input-file", type=Path, help="file containing links to download (default: %(default)s)", default="URLs.txt")+ path_opts.add_argument("-o", "--output-folder", type=Path, help="folder to download files to (default: %(default)s)", default="Downloads")- parser.add_argument("--config-file", type=Path, help="config file to read arguments from", default="config.yaml")- parser.add_argument("--db-file", type=Path, help="history database file to write to", default="download_history.sqlite")- parser.add_argument("--errored-urls-file", type=Path, help="csv file to write failed download information to", default="Errored_URLs.csv")- parser.add_argument("--log-file", type=Path, help="log file to write to", default="downloader.log")- parser.add_argument("--output-last-forum-post-file", type=Path, help="the text file to output last scraped post from a forum thread for re-feeding into CDL", default="URLs_Last_Post.txt")- parser.add_argument("--unsupported-urls-file", type=Path, help="the csv file to output unsupported links into", default="Unsupported_URLs.csv")+ path_opts.add_argument("--config-file", type=Path, help="config file to read arguments from (default: %(default)s)", default="config.yaml")+ path_opts.add_argument("--db-file", type=Path, help="history database file to write to (default: %(default)s)", default="download_history.sqlite")+ path_opts.add_argument("--errored-urls-file", type=Path, help="csv file to write failed download information to (default: %(default)s)", default="Errored_URLs.csv")+ path_opts.add_argument("--log-file", type=Path, help="log file to write to (default: %(default)s)", default="downloader.log")+ path_opts.add_argument("--output-last-forum-post-file", type=Path, help="the text file to output last scraped post from a forum thread for re-feeding into CDL (default: %(default)s)", default="URLs_Last_Post.txt")+ path_opts.add_argument("--unsupported-urls-file", type=Path, help="the csv file to output unsupported links into (default: %(default)s)", default="Unsupported_URLs.csv")# Ignore- parser.add_argument("--exclude-audio", help="skip downloading of audio files", action="store_true")- parser.add_argument("--exclude-images", help="skip downloading of image files", action="store_true")- parser.add_argument("--exclude-other", help="skip downloading of images", action="store_true")- parser.add_argument("--exclude-videos", help="skip downloading of video files", action="store_true")- parser.add_argument("--ignore-cache", help="ignores previous runs cached scrape history", action="store_true")- parser.add_argument("--ignore-history", help="ignores previous download history", action="store_true")- parser.add_argument("--skip-hosts", choices=SkipData.supported_hosts, help="removes host links from downloads", action="append", default=[])- parser.add_argument("--only-hosts", choices=SkipData.supported_hosts, help="only allows downloads from these hosts", action="append", default=[])+ ignore_opts = parser.add_argument_group("Ignore options")+ ignore_opts.add_argument("--exclude-audio", help="skip downloading of audio files", action="store_true")+ ignore_opts.add_argument("--exclude-images", help="skip downloading of image files", action="store_true")+ ignore_opts.add_argument("--exclude-other", help="skip downloading of images", action="store_true")+ ignore_opts.add_argument("--exclude-videos", help="skip downloading of video files", action="store_true")+ ignore_opts.add_argument("--ignore-cache", help="ignores previous runs cached scrape history", action="store_true")+ ignore_opts.add_argument("--ignore-history", help="ignores previous download history", action="store_true")+ ignore_opts.add_argument("--skip-hosts", choices=SkipData.supported_hosts, help="removes host links from downloads", action="append", default=[])+ ignore_opts.add_argument("--only-hosts", choices=SkipData.supported_hosts, help="only allows downloads from these hosts", action="append", default=[])# Runtime arguments- parser.add_argument("--allow-insecure-connections", help="allows insecure connections from content hosts", action="store_true")- parser.add_argument("--attempts", type=int, help="number of attempts to download each file", default=10)- parser.add_argument("--block-sub-folders", help="block sub folders from being created", action="store_true")- 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("--skip-download-mark-completed", help="sets the scraped files as downloaded without downloading", action="store_true")- parser.add_argument("--output-errored-urls", help="sets the failed urls to be output to the errored urls file", action="store_true")- parser.add_argument("--output-unsupported-urls", help="sets the unsupported urls to be output to the unsupported urls file", action="store_true")- parser.add_argument("--proxy", help="HTTP/HTTPS proxy used for downloading, format [protocal]://[ip]:[port]", default=None)- parser.add_argument("--remove-bunkr-identifier", help="removes the bunkr added identifier from output filenames", action="store_true")- parser.add_argument("--required-free-space", type=int, help="required free space (in gigabytes) for the program to run", default=5)- parser.add_argument("--simultaneous-downloads-per-domain", type=int, help="Number of simultaneous downloads to use per domain", default=4)+ runtime_opts = parser.add_argument_group("Runtime options")+ runtime_opts.add_argument("--allow-insecure-connections", help="allows insecure connections from content hosts", action="store_true")+ runtime_opts.add_argument("--attempts", type=int, help="number of attempts to download each file (default: %(default)s)", default=10)+ runtime_opts.add_argument("--block-sub-folders", help="block sub folders from being created", action="store_true")+ runtime_opts.add_argument("--disable-attempt-limit", help="disables the attempt limitation", action="store_true")+ runtime_opts.add_argument("--include-id", help="include the ID in the download folder name", action="store_true")+ runtime_opts.add_argument("--skip-download-mark-completed", help="sets the scraped files as downloaded without downloading", action="store_true")+ runtime_opts.add_argument("--output-errored-urls", help="sets the failed urls to be output to the errored urls file", action="store_true")+ runtime_opts.add_argument("--output-unsupported-urls", help="sets the unsupported urls to be output to the unsupported urls file", action="store_true")+ runtime_opts.add_argument("--proxy", help="HTTP/HTTPS proxy used for downloading, format [protocal]://[ip]:[port]", default=None)+ runtime_opts.add_argument("--remove-bunkr-identifier", help="removes the bunkr added identifier from output filenames", action="store_true")+ runtime_opts.add_argument("--required-free-space", type=int, help="required free space (in gigabytes) for the program to run (default: %(default)s)", default=5)+ runtime_opts.add_argument("--simultaneous-downloads-per-domain", type=int, help="Number of simultaneous downloads to use per domain (default: %(default)s)", default=4)# Sorting- parser.add_argument("--sort-downloads", help="sorts downloaded files after downloads have finished", action="store_true")- parser.add_argument("--sort-directory", type=Path, help="folder to download files to", default="Sorted Downloads")- parser.add_argument("--sorted-audio", type=str, help="schema to sort audio", default="{sort_dir}/{base_dir}/Audio")- parser.add_argument("--sorted-images", type=str, help="schema to sort images", default="{sort_dir}/{base_dir}/Images")- parser.add_argument("--sorted-others", type=str, help="schema to sort other", default="{sort_dir}/{base_dir}/Other")- parser.add_argument("--sorted-videos", type=str, help="schema to sort videos", default="{sort_dir}/{base_dir}/Videos")+ sort_opts = parser.add_argument_group("Sorting options")+ sort_opts.add_argument("--sort-downloads", help="sorts downloaded files after downloads have finished", action="store_true")+ sort_opts.add_argument("--sort-directory", type=Path, help="folder to download files to (default: %(default)s)", default="Sorted Downloads")+ sort_opts.add_argument("--sorted-audio", type=str, help="schema to sort audio (default: %(default)s)", default="{sort_dir}/{base_dir}/Audio")+ sort_opts.add_argument("--sorted-images", type=str, help="schema to sort images (default: %(default)s)", default="{sort_dir}/{base_dir}/Images")+ sort_opts.add_argument("--sorted-others", type=str, help="schema to sort other (default: %(default)s)", default="{sort_dir}/{base_dir}/Other")+ sort_opts.add_argument("--sorted-videos", type=str, help="schema to sort videos (default: %(default)s)", default="{sort_dir}/{base_dir}/Videos")# Ratelimiting- parser.add_argument("--connection-timeout", type=int, help="number of seconds to wait attempting to connect to a URL during the downloading phase", default=15)- parser.add_argument("--ratelimit", type=int, help="this applies to requests made in the program during scraping, the number you provide is in requests/seconds", default=50)- parser.add_argument("--throttle", type=int, help="this is a throttle between requests during the downloading phase, the number is in seconds", default=0.5)+ ratelimit_opts = parser.add_argument_group("Ratelimiting options")+ ratelimit_opts.add_argument("--connection-timeout", type=int, help="number of seconds to wait attempting to connect to a URL during the downloading phase (default: %(default)s)", default=15)+ ratelimit_opts.add_argument("--ratelimit", type=int, help="this applies to requests made in the program during scraping, the number you provide is in requests/seconds (default: %(default)s)", default=50)+ ratelimit_opts.add_argument("--throttle", type=int, help="this is a throttle between requests during the downloading phase, the number is in seconds (default: %(default)s)", default=0.5)# Forum Options- parser.add_argument("--output-last-forum-post", help="outputs the last post of a forum scrape to use as a starting point for future runs", action="store_true")- parser.add_argument("--separate-posts", help="separates forum scraping into folders by post number", action="store_true")+ forum_opts = parser.add_argument_group("Forum options")+ forum_opts.add_argument("--output-last-forum-post", help="outputs the last post of a forum scrape to use as a starting point for future runs", action="store_true")+ forum_opts.add_argument("--separate-posts", help="separates forum scraping into folders by post number", action="store_true")# Authentication details- parser.add_argument("--pixeldrain-api-key", type=str, help="api key for premium pixeldrain", default=None)- parser.add_argument("--simpcity-password", type=str, help="password to login to simpcity", default=None)- parser.add_argument("--simpcity-username", type=str, help="username to login to simpcity", default=None)- parser.add_argument("--socialmediagirls-password", type=str, help="password to login to socialmediagirls", default=None)- parser.add_argument("--socialmediagirls-username", type=str, help="username to login to socialmediagirls", default=None)- parser.add_argument("--xbunker-password", type=str, help="password to login to xbunker", default=None)- parser.add_argument("--xbunker-username", type=str, help="username to login to xbunker", default=None)+ auth_opts = parser.add_argument_group("Authentication options")+ auth_opts.add_argument("--pixeldrain-api-key", type=str, help="api key for premium pixeldrain", default=None)+ auth_opts.add_argument("--simpcity-password", type=str, help="password to login to simpcity", default=None)+ auth_opts.add_argument("--simpcity-username", type=str, help="username to login to simpcity", default=None)+ auth_opts.add_argument("--socialmediagirls-password", type=str, help="password to login to socialmediagirls", default=None)+ auth_opts.add_argument("--socialmediagirls-username", type=str, help="username to login to socialmediagirls", default=None)+ auth_opts.add_argument("--xbunker-password", type=str, help="password to login to xbunker", default=None)+ auth_opts.add_argument("--xbunker-username", type=str, help="username to login to xbunker", default=None)# JDownloader details- parser.add_argument("--apply-jdownloader", help="enables sending unsupported URLs to a running jdownloader2 instance to download", action="store_true")- parser.add_argument("--jdownloader-username", type=str, help="username to login to jdownloader", default=None)- parser.add_argument("--jdownloader-password", type=str, help="password to login to jdownloader", default=None)- parser.add_argument("--jdownloader-device", type=str, help="device name to login to for jdownloader", default=None)+ jdownloader_opts = parser.add_argument_group("JDownloader options")+ jdownloader_opts.add_argument("--apply-jdownloader", help="enables sending unsupported URLs to a running jdownloader2 instance to download", action="store_true")+ jdownloader_opts.add_argument("--jdownloader-username", type=str, help="username to login to jdownloader", default=None)+ jdownloader_opts.add_argument("--jdownloader-password", type=str, help="password to login to jdownloader", default=None)+ jdownloader_opts.add_argument("--jdownloader-device", type=str, help="device name to login to for jdownloader", default=None)# Progress Options- parser.add_argument("--hide-new-progress", help="disables the new rich progress entirely and uses older methods", action="store_true")- parser.add_argument("--dont-show-overall-progress", help="removes overall progress section while downloading", action="store_true")- parser.add_argument("--dont-show-forum-progress", help="removes forum progress section while downloading", action="store_true")- parser.add_argument("--dont-show-thread-progress", help="removes thread progress section while downloading", action="store_true")- parser.add_argument("--dont-show-domain-progress", help="removes domain progress section while downloading", action="store_true")- parser.add_argument("--dont-show-album-progress", help="removes album progress section while downloading", action="store_true")- parser.add_argument("--dont-show-file-progress", help="removes file progress section while downloading", action="store_true")- parser.add_argument("--refresh-rate", type=int, help="refresh rate for the progress table", default=10)+ progress_opts = parser.add_argument_group("Progress options")+ progress_opts.add_argument("--hide-new-progress", help="disables the new rich progress entirely and uses older methods", action="store_true")+ progress_opts.add_argument("--dont-show-overall-progress", help="removes overall progress section while downloading", action="store_true")+ progress_opts.add_argument("--dont-show-forum-progress", help="removes forum progress section while downloading", action="store_true")+ progress_opts.add_argument("--dont-show-thread-progress", help="removes thread progress section while downloading", action="store_true")+ progress_opts.add_argument("--dont-show-domain-progress", help="removes domain progress section while downloading", action="store_true")+ progress_opts.add_argument("--dont-show-album-progress", help="removes album progress section while downloading", action="store_true")+ progress_opts.add_argument("--dont-show-file-progress", help="removes file progress section while downloading", action="store_true")+ progress_opts.add_argument("--refresh-rate", type=int, help="refresh rate for the progress table (default: %(default)s)", default=10)# Linksparser.add_argument("links", metavar="link", nargs="*", help="link to content to download (passing multiple links is supported)", default=[])- args = parser.parse_args()- return args+ return parser.parse_args()async def file_management(args: dict, links: list) -> None: