From ba2bfd6c9b36817728b51d5bb094ecbbdd081a24 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Tue, 16 Sep 2025 17:45:23 +0300 Subject: [PATCH] Use local downloaded thumbnail if avaliable instead of referencing external one --- ui/app/components/History.vue | 31 ++++++++++++++++++------------- ui/app/types/store.d.ts | 16 ++++++++++++++++ ui/app/utils/index.ts | 10 +++++++++- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/ui/app/components/History.vue b/ui/app/components/History.vue index b3c1f51e..8bf45cf2 100644 --- a/ui/app/components/History.vue +++ b/ui/app/components/History.vue @@ -117,10 +117,8 @@ {{ formatTime(item.extras.duration) }} -
- +
+
{{ item.title }}
@@ -272,22 +270,17 @@
- +
- +
@@ -912,6 +905,18 @@ const makePath = (item: StoreItem) => { return '' } const real_path = eTrim(item.download_dir, '/') + '/' + sTrim(item.filename, '/') - return real_path.replace(config.app.download_path, '').replace(/^\//, '') + return stripPath(config.app.download_path, real_path) +} + +const getImage = (item: StoreItem): string => { + if (item.sidecar?.image && item.sidecar.image.length > 0) { + return uri('/api/download/' + encodeURIComponent(stripPath(config.app.download_path, item.sidecar.image[0]?.file || ''))) + } + + if (!item?.extras?.thumbnail) { + return '/images/placeholder.png' + } + + return uri('/api/thumbnail?id=' + item._id + '&url=' + encodePath(item.extras.thumbnail)) } diff --git a/ui/app/types/store.d.ts b/ui/app/types/store.d.ts index c08089ab..7d755464 100644 --- a/ui/app/types/store.d.ts +++ b/ui/app/types/store.d.ts @@ -1,4 +1,14 @@ type ItemStatus = 'finished' | 'preparing' | 'error' | 'cancelled' | 'downloading' | 'postprocessing' | 'not_live' | 'skip' | null; + +type SideCar = { + file: string +} + +type sideCarSubtitle = SideCar & { + lang: string + name: string +} + type StoreItem = { /** Unique identifier for the item */ _id: string @@ -42,6 +52,12 @@ type StoreItem = { auto_start: boolean /** Options for the item */ options: Record + /** Sidecar associated with the item. */ + sidecar: { + Unknown?: Array + subtitle?: Array + image?: Array + }, /** Extras for the item */ extras: { /** Which channel the item belongs to */ diff --git a/ui/app/utils/index.ts b/ui/app/utils/index.ts index 63be4eee..cbd3b431 100644 --- a/ui/app/utils/index.ts +++ b/ui/app/utils/index.ts @@ -677,10 +677,18 @@ const enableOpacity = (): boolean => { return true } +const stripPath = (base_path: string, real_path: string): string => { + if (!base_path) { + return real_path + } + + return real_path.replace(base_path, '').replace(/^\//, '') +} + export { separators, convertCliOptions, getSeparatorsName, iTrim, eTrim, sTrim, ucFirst, getValue, ag, ag_set, awaitElement, r, copyText, dEvent, makePagination, encodePath, request, removeANSIColors, dec2hex, makeId, basename, dirname, getQueryParams, makeDownload, formatBytes, has_data, toggleClass, cleanObject, uri, formatTime, - sleep, awaiter, encode, decode, disableOpacity, enableOpacity + sleep, awaiter, encode, decode, disableOpacity, enableOpacity, stripPath }