From cf8f9717859f50f7bac85c9b3795088d32e2a176 Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Sat, 14 Dec 2024 16:42:31 +0300 Subject: [PATCH] updates --- app/Utils.py | 3 + app/main.py | 43 +++++++++ ui/assets/css/style.css | 19 ++++ ui/components/Queue.vue | 91 +++++++++++++++---- ui/layouts/default.vue | 22 +++-- .../NewDownload.vue => pages/add.vue} | 21 ++++- ui/pages/console.vue | 7 +- ui/pages/index.vue | 18 ---- ui/stores/SocketStore.js | 9 +- ui/utils/index.js | 3 - 10 files changed, 183 insertions(+), 53 deletions(-) rename ui/{components/NewDownload.vue => pages/add.vue} (94%) diff --git a/app/Utils.py b/app/Utils.py index 4448896e..866e6965 100644 --- a/app/Utils.py +++ b/app/Utils.py @@ -342,6 +342,9 @@ class Notifier: async def error(self, dl: dict, message: str): await self.emit('error', (dl, message)) + async def warning(self, message: str): + await self.emit('error', message) + async def emit(self, event: str, data): tasks = [] tasks.append(self.sio.emit(event, self.serializer.encode(data))) diff --git a/app/main.py b/app/main.py index d7c41959..aa82ff2f 100644 --- a/app/main.py +++ b/app/main.py @@ -688,6 +688,49 @@ class Main: }) await self.sio.emit('cli_close', {'exitcode': -1}) + @self.sio.event() + async def add_url(sid, post: dict): + url: str = post.get('url') + quality: str = post.get('quality') + + if not url: + self.notifier.warning('No URL provided.') + return + + format: str = post.get('format') + folder: str = post.get('folder') + ytdlp_cookies: str = post.get('ytdlp_cookies') + ytdlp_config: dict = post.get('ytdlp_config') + output_template: str = post.get('output_template') + if ytdlp_config is None: + ytdlp_config = {} + + status = await self.add( + url=url, + quality=quality, + format=format, + folder=folder, + ytdlp_cookies=ytdlp_cookies, + ytdlp_config=ytdlp_config, + output_template=output_template + ) + await self.sio.emit('status', self.serializer.encode(status)) + + @self.sio.event + async def cancel_items(sid, post: dict): + ids = post.get('ids') + identifier: str = post.get('identifier') + + if not ids: + await self.notifier.warning('Invalid request.') + return + + status: dict[str, str] = {} + status = await self.queue.cancel(ids) + status.update({'identifier': identifier}) + + await self.sio.emit('cancel_items', self.serializer.encode(status)) + @self.sio.event() async def archive_item(sid, data): if not isinstance(data, dict) or 'url' not in data or not self.config.keep_archive: diff --git a/ui/assets/css/style.css b/ui/assets/css/style.css index 63c2ed20..4492540d 100644 --- a/ui/assets/css/style.css +++ b/ui/assets/css/style.css @@ -188,3 +188,22 @@ hr { background-color: #087363; } } + +.vue-notification { + background: unset; + border-left: none; +} + +.notification-title { + font-size: 1.5em; + font-weight: bold; +} + +.notification-content { + font-size: 1.2em; +} + +.vue-notification-wrapper { + cursor: pointer; + padding-top: 0.5em; +} diff --git a/ui/components/Queue.vue b/ui/components/Queue.vue index f1f935b7..2edcacc7 100644 --- a/ui/components/Queue.vue +++ b/ui/components/Queue.vue @@ -4,7 +4,7 @@ - Queue ({{ getTotal }}) + Queue ({{ stateStore.count('queue') }}) @@ -35,7 +35,7 @@
-
@@ -57,7 +57,7 @@ Live Streaming - {{ capitalize(item.status) }} + {{ ucFirst(item.status) }}
@@ -76,7 +76,7 @@
- + + + + Add + +
@@ -46,6 +47,7 @@
+