From 736b588b8ad73803d59f3deaf3b2206df8615502 Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Thu, 11 Jul 2024 13:38:53 +0300 Subject: [PATCH 1/2] Added option to archive failing download from WebUI --- app/main.py | 21 +++++++++++- frontend/src/App.vue | 28 ++++++++++++---- frontend/src/components/Page-Completed.vue | 37 +++++++++++++--------- frontend/src/main.js | 5 +-- 4 files changed, 67 insertions(+), 24 deletions(-) diff --git a/app/main.py b/app/main.py index 77f88e2c..76264b2e 100644 --- a/app/main.py +++ b/app/main.py @@ -9,7 +9,7 @@ import selectors import time from Config import Config from DownloadQueue import DownloadQueue -from Utils import ObjectSerializer, Notifier, load_file +from Utils import ObjectSerializer, Notifier, isDownloaded, load_file from aiohttp import web, client from aiohttp.web import Request, Response from Webhooks import Webhooks @@ -550,6 +550,25 @@ class Main: }) await self.sio.emit('cli_close', {'exitcode': -1}) + @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: + return + + file: str = self.config.ytdl_options.get('download_archive', None) + + if not file: + return + + exists, idDict = isDownloaded(file, data['url']) + if exists or 'archive_id' not in idDict or idDict['archive_id'] is None: + return + + with open(file, 'a') as f: + f.write(f"{idDict['archive_id']}\n") + + LOG.info(f'Archiving item: {data["url"]=}') + @self.sio.event() async def connect(sid, environ): await self.connect(sid, environ) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index beecf9d0..57898bb3 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -9,7 +9,7 @@ + @playItem="playItem" @archiveItem="archiveItem" />