From 94193b808fc9286dffeec23b925c789f925d4839 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Sat, 19 Jul 2025 20:49:50 +0300 Subject: [PATCH 1/3] removed useless log statement. --- app/library/ItemDTO.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/library/ItemDTO.py b/app/library/ItemDTO.py index 55adef71..4a264e67 100644 --- a/app/library/ItemDTO.py +++ b/app/library/ItemDTO.py @@ -161,7 +161,6 @@ class Item: data["template"] = item.get("template") if "auto_start" in item and isinstance(item.get("auto_start"), bool): - LOG.info("Item '%s' auto_start is set to %s.", url, item.get("auto_start")) data["auto_start"] = bool(item.get("auto_start")) extras = item.get("extras") From 472b8cb46859e2ace13d7d9d338896c61456e9a5 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Sun, 20 Jul 2025 16:53:56 +0300 Subject: [PATCH 2/3] Fixes #344 --- app/library/DataStore.py | 2 +- app/library/DownloadQueue.py | 6 ++-- app/library/YTDLPOpts.py | 15 +++------ app/routes/socket/history.py | 62 ++++++------------------------------ 4 files changed, 17 insertions(+), 68 deletions(-) diff --git a/app/library/DataStore.py b/app/library/DataStore.py index 0276dd2e..435d2bcd 100644 --- a/app/library/DataStore.py +++ b/app/library/DataStore.py @@ -16,7 +16,7 @@ LOG = logging.getLogger("datastore") class StoreType(str, Enum): - DONE = "done" + HISTORY = "done" QUEUE = "queue" @classmethod diff --git a/app/library/DownloadQueue.py b/app/library/DownloadQueue.py index f9351556..f883d1b7 100644 --- a/app/library/DownloadQueue.py +++ b/app/library/DownloadQueue.py @@ -76,7 +76,7 @@ class DownloadQueue(metaclass=Singleton): self.config = config or Config.get_instance() self._notify = EventBus.get_instance() - self.done = DataStore(type=StoreType.DONE, connection=connection) + self.done = DataStore(type=StoreType.HISTORY, connection=connection) self.queue = DataStore(type=StoreType.QUEUE, connection=connection) self.done.load() self.queue.load() @@ -981,13 +981,13 @@ class DownloadQueue(metaclass=Singleton): if entry.is_cancelled() is True: nTitle = "Download Cancelled" - nMessage = f"Download '{entry.info.title}' has been cancelled." + nMessage = f"Cancelled '{entry.info.title}' download." await self._notify.emit(Events.ITEM_CANCELLED, data=entry.info, title=nTitle, message=nMessage) entry.info.status = "cancelled" if entry.info.status == "finished" and entry.info.filename: nTitle = "Download Completed" - nMessage = f"Download '{entry.info.title}' has been finished." + nMessage = f"Completed '{entry.info.title}' download." _tasks.append(self._notify.emit(Events.ITEM_COMPLETED, data=entry.info, title=nTitle, message=nMessage)) self.done.put(value=entry) diff --git a/app/library/YTDLPOpts.py b/app/library/YTDLPOpts.py index a7a8a43f..874ba01f 100644 --- a/app/library/YTDLPOpts.py +++ b/app/library/YTDLPOpts.py @@ -3,13 +3,12 @@ from pathlib import Path from .config import Config from .Presets import Preset, Presets -from .Singleton import Singleton from .Utils import REMOVE_KEYS, arg_converter, calc_download_path, load_cookies, merge_dict LOG: logging.Logger = logging.getLogger("YTDLPOpts") -class YTDLPOpts(metaclass=Singleton): +class YTDLPOpts: _item_opts: dict = {} """The item options.""" @@ -22,9 +21,6 @@ class YTDLPOpts(metaclass=Singleton): _preset_cli: str = "" """The command options for yt-dlp from preset.""" - _instance = None - """The instance of the class.""" - def __init__(self): self._config = Config.get_instance() @@ -37,10 +33,7 @@ class YTDLPOpts(metaclass=Singleton): Presets: The instance of the class """ - if not YTDLPOpts._instance: - YTDLPOpts._instance = YTDLPOpts() - - return YTDLPOpts._instance + return YTDLPOpts() def add_cli(self, args: str, from_user: int | bool = False) -> "YTDLPOpts": """ @@ -133,7 +126,7 @@ class YTDLPOpts(metaclass=Singleton): load_cookies(file) self._preset_opts["cookiefile"] = str(file) except ValueError as e: - LOG.error(str(e)) + LOG.error(f"Failed to load '{preset.name}' cookies from '{file}'. {e!s}") if preset.template: self._preset_opts["outtmpl"] = {"default": preset.template, "chapter": self._config.output_template_chapter} @@ -210,6 +203,6 @@ class YTDLPOpts(metaclass=Singleton): if data["format"] == "-best": data["format"] = data["format"][1:] - LOG.debug(f"Parsed yt-dlp options are: '{data!s}'.") + LOG.debug(f"Final yt-dlp options: '{data!s}'.") return data diff --git a/app/routes/socket/history.py b/app/routes/socket/history.py index 5b9df302..1202deb6 100644 --- a/app/routes/socket/history.py +++ b/app/routes/socket/history.py @@ -40,15 +40,9 @@ async def resume(notify: EventBus, queue: DownloadQueue): @route(RouteType.SOCKET, "add_url", "add_url") async def add_url(queue: DownloadQueue, notify: EventBus, sid: str, data: dict): - url: str | None = data.get("url") - - if not url: - await notify.emit( - Events.LOG_ERROR, - title="Invalid URL", - message="Please provide a valid URL to add to the download queue.", - to=sid, - ) + data = data if isinstance(data, dict) else {} + if not (url := data.get("url", None)): + await notify.emit(Events.LOG_ERROR, title="Invalid request", message="No URL provided.", to=sid) return try: @@ -67,57 +61,19 @@ async def add_url(queue: DownloadQueue, notify: EventBus, sid: str, data: dict): @route(RouteType.SOCKET, "item_cancel", "item_cancel") async def item_cancel(queue: DownloadQueue, notify: EventBus, sid: str, data: str): - if not data: - await notify.emit( - Events.LOG_ERROR, - title="Invalid Request", - message="No item ID provided to cancel.", - to=sid, - ) + if not (data := data if isinstance(data, str) else None): + await notify.emit(Events.LOG_ERROR, title="Invalid Request", message="No item ID provided.", to=sid) return - try: - item = queue.get_item(id=data) - except KeyError: - await notify.emit( - Events.LOG_ERROR, - title="Item Not Found", - message=f"Item with ID '{data}' not found.", - to=sid, - ) - return - - status: dict[str, str] = {} - status = await queue.cancel([data]) - status.update({"identifier": data}) - - await notify.emit( - Events.ITEM_CANCELLED, - data=item.info, - title="Item Cancelled", - message=f"Cancelled '{item.info.title}'.", - ) + await queue.cancel([data]) @route(RouteType.SOCKET, "item_delete", "item_delete") async def item_delete(queue: DownloadQueue, notify: EventBus, sid: str, data: dict): - if not data: - await notify.emit( - Events.LOG_ERROR, - title="Invalid Request", - message="No item ID provided to delete.", - to=sid, - ) - return + data = data if isinstance(data, dict) else {} - id: str | None = data.get("id") - if not id: - await notify.emit( - Events.LOG_ERROR, - title="Invalid Request", - message="No item ID provided to delete.", - to=sid, - ) + if not (id := data.get("id", None)): + await notify.emit(Events.LOG_ERROR, title="Invalid Request", message="No item ID provided.", to=sid) return await queue.clear([id], remove_file=bool(data.get("remove_file", False))) From ac2056f03890889b4d86a309553f9ef3513e1643 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Sun, 20 Jul 2025 17:02:01 +0300 Subject: [PATCH 3/3] Fix text overflow, Closes #345 --- ui/assets/css/style.css | 5 +++++ ui/components/History.vue | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/assets/css/style.css b/ui/assets/css/style.css index fc1277a8..c2f8644d 100644 --- a/ui/assets/css/style.css +++ b/ui/assets/css/style.css @@ -340,3 +340,8 @@ hr { .Vue-Toastification__toast-body { user-select: none; } + +.is-word-break { + word-break: break-word; + text-wrap: auto; +} diff --git a/ui/components/History.vue b/ui/components/History.vue index dc4fe876..ddd33b44 100644 --- a/ui/components/History.vue +++ b/ui/components/History.vue @@ -889,7 +889,7 @@ const downloadSelected = async () => { } } -const toggle_class = e => e.currentTarget.classList.toggle('is-text-overflow') +const toggle_class = e => ['is-text-overflow', 'is-word-break'].forEach(c => e.currentTarget.classList.toggle(c)) const removeFromArchiveDialog = (item) => { dialog_confirm.value.visible = true