From 29b7748b8a454e546db528be739aac196c2c5898 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Thu, 28 Aug 2025 21:42:02 +0300 Subject: [PATCH] add is_archived to both local info and yt-dlp info --- app/routes/api/history.py | 12 ++++++++++++ app/routes/api/yt_dlp.py | 8 +++++++- ui/app/components/History.vue | 16 ++++++---------- ui/app/components/Queue.vue | 22 ++++++++++------------ 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/app/routes/api/history.py b/app/routes/api/history.py index 568ed480..b9dcc4f6 100644 --- a/app/routes/api/history.py +++ b/app/routes/api/history.py @@ -13,6 +13,8 @@ from app.library.Events import EventBus, Events from app.library.ItemDTO import Item from app.library.Presets import Preset, Presets from app.library.router import route +from app.library.Utils import is_downloaded +from app.library.YTDLPOpts import YTDLPOpts if TYPE_CHECKING: from library.Download import Download @@ -98,8 +100,18 @@ async def item_view(request: Request, queue: DownloadQueue, encoder: Encoder, co if not item.info: return web.json_response(data={"error": "item has no info."}, status=web.HTTPNotFound.status_code) + is_archived = False + params: YTDLPOpts = YTDLPOpts.get_instance().preset(name=item.info.preset) + if item.info.cli: + params.add_cli(item.info.cli, from_user=True) + + params = params.get_all() + if archive_file := params.get("download_archive"): + is_archived, _ = is_downloaded(archive_file, item.info.url) + info = { **item.info.serialize(), + "is_archived": is_archived, "ffprobe": {}, } diff --git a/app/routes/api/yt_dlp.py b/app/routes/api/yt_dlp.py index 5ca2e459..2643b829 100644 --- a/app/routes/api/yt_dlp.py +++ b/app/routes/api/yt_dlp.py @@ -14,7 +14,7 @@ from app.library.cache import Cache from app.library.config import Config from app.library.Presets import Presets from app.library.router import route -from app.library.Utils import REMOVE_KEYS, arg_converter, extract_info, validate_url +from app.library.Utils import REMOVE_KEYS, arg_converter, extract_info, is_downloaded, validate_url from app.library.YTDLPOpts import YTDLPOpts LOG: logging.Logger = logging.getLogger(__name__) @@ -199,6 +199,12 @@ async def get_info(request: Request, cache: Cache, config: Config) -> Response: "expires": time.time() + 300, } + is_archived = False + if user_file := ytdlp_opts.get("download_archive"): + is_archived, _ = is_downloaded(user_file, url) + + data["is_archived"] = is_archived + data = OrderedDict(sorted(data.items(), key=lambda item: len(str(item[1])))) cache.set(key=key, value=data, ttl=300) diff --git a/ui/app/components/History.vue b/ui/app/components/History.vue index 27315d27..1fe47119 100644 --- a/ui/app/components/History.vue +++ b/ui/app/components/History.vue @@ -139,11 +139,8 @@ - - - {{ setStatus(item) }} - + + {{ setStatus(item) }}
-
@@ -299,10 +297,8 @@
- - - {{ setStatus(item) }} - + + {{ setStatus(item) }}
diff --git a/ui/app/components/Queue.vue b/ui/app/components/Queue.vue index 43ceacd7..1e4e39d5 100644 --- a/ui/app/components/Queue.vue +++ b/ui/app/components/Queue.vue @@ -84,7 +84,8 @@
-
{{ item.title }} @@ -98,12 +99,10 @@ - - - - - + + +
@@ -206,7 +205,8 @@
-
@@ -226,12 +226,10 @@
- - - - - + + +