diff --git a/.dockerignore b/.dockerignore index f49e1494..c4546ea5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ .git .venv -ui/.angular -ui/node_modules +ui/ diff --git a/.gitignore b/.gitignore index 647126e0..fa02d578 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ /frontend/dist # dependencies -/frontend/node_modules +**/node_modules/* +**/.nuxt/* # IDEs and editors /ui/.idea diff --git a/.vscode/launch.json b/.vscode/launch.json index 86c5d828..19fd6843 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -73,6 +73,6 @@ } ], "justMyCode": true - } + }, ] } diff --git a/Pipfile.lock b/Pipfile.lock index b3df96c6..3431b8c9 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1080,12 +1080,12 @@ }, "yt-dlp": { "hashes": [ - "sha256:743dbe081ea871be3f5ff083e2cd95da866dea773fc70ae6b109838cfbf72ac4", - "sha256:a7b8724e58fff4f3204cae4feb936dbd249ca6d22c5f25dec1b3c6f1cb7745a2" + "sha256:5a16b7511e8500cbb13ff0babc9c6deb1e049dc1c854a51738aad2529167fcdf", + "sha256:77e15afb9d460ecb7294a39bb5e39dc9f4e8a65f3a37ef4db58800b94d095511" ], "index": "pypi", "markers": "python_version >= '3.9'", - "version": "==2024.12.6" + "version": "==2024.12.13" } }, "develop": {} 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..a2bdd8bf 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -import argparse import asyncio import base64 from datetime import datetime @@ -688,6 +687,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: