Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
feat: add `dir` subcommands for appdata files
NTFSvolume355b932350db
diff --git a/cyberdrop_dl/commands/__init__.py b/cyberdrop_dl/commands/__init__.pyindex fda961e51..ea1a4ced8 100644--- a/cyberdrop_dl/commands/__init__.py+++ b/cyberdrop_dl/commands/__init__.py@@ -38,3 +38,17 @@ class CLIarguments:def __json__(self) -> dict[str, Any]:return {k: None if v is None else str(v) for k, v in self}+++def open_folder(folder: Path) -> None:+ if not folder.exists():+ from cyberdrop_dl.prompts import ask_should_create_folder++ if not ask_should_create_folder(folder):+ return++ folder.mkdir(parents=True)++ import webbrowser++ webbrowser.open_new(str(folder))diff --git a/cyberdrop_dl/commands/cache.py b/cyberdrop_dl/commands/cache.pyindex 657b2c11a..b57d4b232 100644--- a/cyberdrop_dl/commands/cache.py+++ b/cyberdrop_dl/commands/cache.py@@ -2,7 +2,7 @@ import loggingfrom cyclopts import App-from cyberdrop_dl.commands import CLIarguments+from cyberdrop_dl.commands import CLIarguments, open_folderfrom cyberdrop_dl.config.appdata import AppDataapp = App(name="cache", help="Cache operations")@@ -12,8 +12,7 @@ logger = logging.getLogger(__name__)@app.command()def file(*, cli: CLIarguments | None = None) -> None:"Show path to the cache file"- file = cli.cache_file if cli else None- file = file or AppData.default().cache_file+ file = (cli and cli.cache_file) or AppData.default().cache_fileapp.console.print(file)@@ -21,11 +20,18 @@ def file(*, cli: CLIarguments | None = None) -> None:def clear(*, cli: CLIarguments | None = None) -> None:"Delete the cache file"- file = cli.cache_file if cli else None- file = file or AppData.default().cache_file+ file = (cli and cli.cache_file) or AppData.default().cache_filetry:file.unlink()except FileNotFoundError:logger.info("Cache file does not exists. Nothing to do")else:logger.info("Cache file at '%s' deleted", file)++[email protected](name="dir", alias="folder")+def folder(*, cli: CLIarguments | None = None) -> None:+ "Open folder with cache file in default file explorer"+ file = (cli and cli.cache_file) or AppData.default().cache_file++ open_folder(file.parent)diff --git a/cyberdrop_dl/commands/config.py b/cyberdrop_dl/commands/config.pyindex abe415ecc..9cea7ec66 100644--- a/cyberdrop_dl/commands/config.py+++ b/cyberdrop_dl/commands/config.py@@ -1,6 +1,6 @@from cyclopts import App-from cyberdrop_dl.commands import CLIarguments+from cyberdrop_dl.commands import CLIarguments, open_folderfrom cyberdrop_dl.config import Configfrom cyberdrop_dl.config.appdata import AppDatafrom cyberdrop_dl.prompts import ask_should_create_config@@ -11,8 +11,7 @@ app = App(name="config", help="Config file operations")@app.command()def file(*, cli: CLIarguments | None = None) -> None:"Show path to the config file"- file = cli.config_file if cli else None- file = file or AppData.default().config_file+ file = (cli and cli.config_file) or AppData.default().config_fileapp.console.print(file)@@ -21,7 +20,7 @@ def edit(*, cli: CLIarguments | None = None) -> None:"Open the default config file on a text editor"from cyberdrop_dl.utils import text_editor- file = cli.config_file if cli else None+ file = cli and cli.config_fileif not file:file = AppData.default().config_fileif not file.exists():@@ -36,3 +35,11 @@ def edit(*, cli: CLIarguments | None = None) -> None:def new() -> None:"Create a new config with default options and print it"app.console.print(Config().dump_yaml(), soft_wrap=True)++[email protected](name="dir", alias="folder")+def folder(*, cli: CLIarguments | None = None) -> None:+ "Open folder with config file in default file explorer"+ file = (cli and cli.config_file) or AppData.default().config_file++ open_folder(file.parent)diff --git a/cyberdrop_dl/commands/database.py b/cyberdrop_dl/commands/database.pyindex 99b929023..eb8cb3801 100644--- a/cyberdrop_dl/commands/database.py+++ b/cyberdrop_dl/commands/database.py@@ -2,7 +2,7 @@ from typing import Annotatedfrom cyclopts import App, Parameter-from cyberdrop_dl.commands import CLIarguments, SQLiteFile+from cyberdrop_dl.commands import CLIarguments, SQLiteFile, open_folderfrom cyberdrop_dl.config.appdata import AppDataapp = App(name="database", help="Commands for managing the database")@@ -31,4 +31,13 @@ def transfer(@app.command()def file(*, cli: CLIarguments | None = None) -> None:"Show file path to the database"- app.console.print(cli.database_file if cli else AppData.default().db_file)+ file = (cli and cli.database_file) or AppData.default().db_file+ app.console.print(file)++[email protected](name="dir", alias="folder")+def folder(*, cli: CLIarguments | None = None) -> None:+ "Open folder with database in default file explorer"+ file = (cli and cli.database_file) or AppData.default().db_file++ open_folder(file.parent)diff --git a/cyberdrop_dl/prompts.py b/cyberdrop_dl/prompts.pyindex a2279a8d5..96682a5d4 100644--- a/cyberdrop_dl/prompts.py+++ b/cyberdrop_dl/prompts.py@@ -111,3 +111,8 @@ def ask_path(def ask_should_create_config(file: Path) -> bool:console.warning("A default config file does not exists")return ask_confirmation(f"Do you want to create it at '{file}'?")+++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?")