From 473058351066f2ffd4b064080198692aeec98641 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Tue, 1 Apr 2025 20:34:14 +0300 Subject: [PATCH] update newDownload template --- app/library/DownloadQueue.py | 4 +-- app/library/HttpAPI.py | 3 +- app/library/Utils.py | 19 +++++++++++ ui/components/NewDownload.vue | 64 +++++++++++++++++++++-------------- ui/components/TaskForm.vue | 2 +- 5 files changed, 62 insertions(+), 30 deletions(-) diff --git a/app/library/DownloadQueue.py b/app/library/DownloadQueue.py index edf4214a..e756ecf5 100644 --- a/app/library/DownloadQueue.py +++ b/app/library/DownloadQueue.py @@ -21,7 +21,7 @@ from .Events import EventBus, Events from .ItemDTO import ItemDTO from .Presets import Presets from .Singleton import Singleton -from .Utils import arg_converter, calc_download_path, extract_info, is_downloaded +from .Utils import arg_converter, calc_download_path, extract_info, is_downloaded, strip_newline from .YTDLPOpts import YTDLPOpts LOG = logging.getLogger("DownloadQueue") @@ -421,7 +421,7 @@ class DownloadQueue(metaclass=Singleton): cookie_file = os.path.join(self.config.temp_path, f"c_{uuid.uuid4().hex}.txt") LOG.info( - f"Adding 'URL: {url}' to 'Folder: {filePath}' with 'Preset: {preset}' 'Naming: {template}', 'Cookies: {len(cookies)}/chars' 'CLI: {cli}' 'Extras: {extras}'." + f"Adding 'URL: {url}' to 'Folder: {filePath}' with 'Preset: {preset}' 'Naming: {template}', 'Cookies: {len(cookies)}/chars' 'CLI: {strip_newline(cli)}' 'Extras: {extras}'." ) if isinstance(config, str): diff --git a/app/library/HttpAPI.py b/app/library/HttpAPI.py index 30f31e88..bf6edb87 100644 --- a/app/library/HttpAPI.py +++ b/app/library/HttpAPI.py @@ -475,7 +475,8 @@ class HttpAPI(Common): err = err.split("\n")[-1] if "\n" in err else err err = err.replace("main.py: error: ", "").strip().capitalize() return web.json_response( - data={"error": f"Failed to command line arguments for yt-dlp. '{err}'."}, status=web.HTTPBadRequest.status_code + data={"error": f"Failed to parse command arguments for yt-dlp. '{err}'."}, + status=web.HTTPBadRequest.status_code, ) @route("GET", "api/yt-dlp/url/info") diff --git a/app/library/Utils.py b/app/library/Utils.py index a09e6bd6..0e5ae8b8 100644 --- a/app/library/Utils.py +++ b/app/library/Utils.py @@ -925,3 +925,22 @@ def clean_item(item: dict, keys: list | tuple) -> tuple[dict, bool]: item.pop(key) return item, status + + +def strip_newline(string: str) -> str: + """ + Remove newlines from a string. + + Args: + string (str): The string to process. + + Returns: + str: The string without newlines. + + """ + if not string: + return "" + + res = re.sub(r"(\r\n|\r|\n)", " ", string) + + return res.strip() if res else "" diff --git a/ui/components/NewDownload.vue b/ui/components/NewDownload.vue index 57852735..8ff3f473 100644 --- a/ui/components/NewDownload.vue +++ b/ui/components/NewDownload.vue @@ -5,31 +5,39 @@
-
+ +
- - -
+ + + You can add multiple URLs separated by a comma ,. +
-
+
-
-
+
-