Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
refactor: enable `--force-original-path` (#2131)
NTFSvolumeeb0e8c069c10
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5363465c8..ca6a53356 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -29,6 +29,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Support premium URLs (direct links)(GoFile)- FileditchAlbums support+### Changed++- Enable the `--force-original-path` option on retry commands+- Ask the user if they want to use the original download path after choosing `retry failed downloads` (main menu)+### Fixed- Pagination of some profiles stopping early (Twitter/x.com)diff --git a/cyberdrop_dl/clients/downloads.py b/cyberdrop_dl/clients/downloads.pyindex 59b48db59..ddd92e969 100644--- a/cyberdrop_dl/clients/downloads.py+++ b/cyberdrop_dl/clients/downloads.py@@ -13,7 +13,7 @@ from aiohttp import hdrsfrom cyberdrop_dl import aio, constants, ffmpeg, storagefrom cyberdrop_dl.clients import etagfrom cyberdrop_dl.clients.http import JSON_CHECK, check_http_status-from cyberdrop_dl.constants import FileExt+from cyberdrop_dl.constants import USE_RETRY_PATH, FileExtfrom cyberdrop_dl.exceptions import DownloadError, InvalidContentTypeError, SlowDownloadErrorfrom cyberdrop_dl.signature import simple_reprfrom cyberdrop_dl.utils import dates, enter_context@@ -479,7 +479,7 @@ async def _check_response(media_item: MediaItem, resp: AbstractResponse[Any], redef resolve_download_dir(download_folder: Path, config: Config) -> Path:- if config.subfolders.create:+ if config.subfolders.create or USE_RETRY_PATH.get():return download_folderwhile download_folder.parent != config.download_folder:diff --git a/cyberdrop_dl/commands/retry.py b/cyberdrop_dl/commands/retry.pyindex 2910dea2c..886c325a1 100644--- a/cyberdrop_dl/commands/retry.py+++ b/cyberdrop_dl/commands/retry.py@@ -6,7 +6,7 @@ from cyclopts import App, Parameterfrom cyberdrop_dl.commands import CLIargumentsfrom cyberdrop_dl.commands.scrape import prepare_manager, scrapefrom cyberdrop_dl.config import Config-from cyberdrop_dl.exceptions import CDLConfigRuntimeErrorsGroup+from cyberdrop_dl.constants import USE_RETRY_PATHfrom cyberdrop_dl.models import ConfigModelfrom cyberdrop_dl.scrape_source import RetryScrapeSource, RetrySource@@ -35,8 +35,7 @@ def _tomorrow() -> datetime.date:def create_retry_src(retry: RetrySource, args: RetryArgs | None = None) -> RetryScrapeSource:args = args or RetryArgs()if args.force_original_path:- error = RuntimeError("Support for '--force-original-path' has been temporarily removed")- raise CDLConfigRuntimeErrorsGroup("Unsupported option", (error,))+ USE_RETRY_PATH.set(True)return RetryScrapeSource(retry, after=args.from_, before=args.to or _tomorrow())diff --git a/cyberdrop_dl/constants.py b/cyberdrop_dl/constants.pyindex 9c7b4fd51..67f96374c 100644--- a/cyberdrop_dl/constants.py+++ b/cyberdrop_dl/constants.py@@ -25,6 +25,7 @@ MISSING: Any = Sentinel("MISSING")HttpMethod = Literal["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "TRACE", "PATCH", "QUERY"]MAIN_LOG_FILE: ContextVar[Path] = ContextVar("MAIN_LOG_FILE")+USE_RETRY_PATH: ContextVar[bool] = ContextVar("USE_RETRY_PATH", default=False)DEFAULT_PARAMETER = Parameter(negative_iterable=[],diff --git a/cyberdrop_dl/crawlers/crawler.py b/cyberdrop_dl/crawlers/crawler.pyindex c504b2fe3..bec679aba 100644--- a/cyberdrop_dl/crawlers/crawler.py+++ b/cyberdrop_dl/crawlers/crawler.py@@ -18,7 +18,7 @@ from cyberdrop_dl import aio, envfrom cyberdrop_dl.cache import TTLCacheAdapterfrom cyberdrop_dl.clients.downloads import IGNORE_CONTENT_TYPEfrom cyberdrop_dl.clients.http import HTTPClient, HTTPConfig, HTTPContext, HTTPMixin-from cyberdrop_dl.constants import FileExt, HttpMethod+from cyberdrop_dl.constants import USE_RETRY_PATH, FileExt, HttpMethodfrom cyberdrop_dl.crawlers import ALLOW_NO_EXT, SKIP_DOWNLOAD, Registryfrom cyberdrop_dl.crawlers._hls import HLSMixinfrom cyberdrop_dl.downloader.http import Downloader@@ -1231,6 +1231,8 @@ def _should_skip_by_config(media_item: MediaItem, config: Config) -> bool:def _prepare_download_path(item: ScrapeItem, domain: str) -> Path:+ if item.retry_info and USE_RETRY_PATH.get():+ return item.retry_info.download_pathpath = item.download_folder / item.pathif item.is_loose_file:path = path / f"Loose Files ({domain})"diff --git a/cyberdrop_dl/program_ui.py b/cyberdrop_dl/program_ui.pyindex fd906a6b9..bc31463b8 100644--- a/cyberdrop_dl/program_ui.py+++ b/cyberdrop_dl/program_ui.py@@ -8,6 +8,7 @@ import aiohttpfrom rich.markdown import Markdownfrom cyberdrop_dl import __version__, aio, stats+from cyberdrop_dl.constants import USE_RETRY_PATHfrom cyberdrop_dl.hasher import Hasher, hash_directoryfrom cyberdrop_dl.progress import hyperlinkfrom cyberdrop_dl.prompts import (@@ -15,6 +16,7 @@ from cyberdrop_dl.prompts import (ask_confirmation,ask_dir,ask_should_create_config,+ ask_should_use_retry_path,console,enter_to_continue,)@@ -45,7 +47,7 @@ def run(manager: Manager, input_file: Path) -> RetrySource | Path:_INPUT_FILE.set(input_file)choices: dict[str, Callable[[Manager], RetrySource | Path | None]] = {"Download": lambda _: input_file,- "Retry failed downloads": lambda _: RetrySource.FAILED,+ "Retry failed downloads": _retry_failed,"Create file hashes": _scan_and_create_hashes,"Sort files in download folder": _sort_files,"Edit URLs.txt": lambda _: _edit_urls(),@@ -62,6 +64,11 @@ def run(manager: Manager, input_file: Path) -> RetrySource | Path:return source+def _retry_failed(_: object) -> RetrySource:+ USE_RETRY_PATH.set(ask_should_use_retry_path())+ return RetrySource.FAILED++def _scan_and_create_hashes(manager: Manager) -> None:path = ask_dir("Select the directory to scan", default=manager.config.download_folder)with Hasher.create(manager.config, manager.database, path) as hasher:diff --git a/cyberdrop_dl/prompts.py b/cyberdrop_dl/prompts.pyindex 8c21677b6..96a1dfa2b 100644--- a/cyberdrop_dl/prompts.py+++ b/cyberdrop_dl/prompts.py@@ -125,3 +125,7 @@ def ask_should_create_config(file: Path) -> bool:def ask_should_create_folder(folder: Path) -> bool:console.warning(f"Folder '{folder}' does not exists")return ask_confirmation("Do you want to create it?")+++def ask_should_use_retry_path() -> bool:+ return ask_confirmation("Do you want to use the exact same download path as the original attempt?")