From 38d4c97032a8ace0d479a65048beb6ee025f6147 Mon Sep 17 00:00:00 2001 From: TPN Date: Mon, 1 Apr 2024 12:48:35 +0000 Subject: [PATCH] use thumnails from vidplay --- src/providers/embeds/vidplay/index.ts | 12 +++++++++++- src/providers/embeds/vidplay/types.ts | 13 +++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/providers/embeds/vidplay/index.ts b/src/providers/embeds/vidplay/index.ts index 045e19e..fb5b7c2 100644 --- a/src/providers/embeds/vidplay/index.ts +++ b/src/providers/embeds/vidplay/index.ts @@ -3,7 +3,7 @@ import { makeEmbed } from '@/providers/base'; import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '@/providers/captions'; import { getFileUrl } from './common'; -import { SubtitleResult, VidplaySourceResponse } from './types'; +import { SubtitleResult, ThumbnailTrack, VidplaySourceResponse } from './types'; export const vidplayScraper = makeEmbed({ id: 'vidplay', @@ -18,6 +18,15 @@ export const vidplayScraper = makeEmbed({ }); if (typeof fileUrlRes.result === 'number') throw new Error('File not found'); const source = fileUrlRes.result.sources[0].file; + const thumbnailSource = fileUrlRes.result.tracks.find((track) => track.kind === 'thumbnails'); + + let thumbnailTrack: ThumbnailTrack | undefined; + if (thumbnailSource) { + thumbnailTrack = { + type: 'vtt', + url: thumbnailSource.file, + }; + } const url = new URL(ctx.url); const subtitlesLink = url.searchParams.get('sub.info'); @@ -47,6 +56,7 @@ export const vidplayScraper = makeEmbed({ playlist: source, flags: [flags.CORS_ALLOWED], captions, + thumbnailTrack, }, ], }; diff --git a/src/providers/embeds/vidplay/types.ts b/src/providers/embeds/vidplay/types.ts index 29cde1d..8810647 100644 --- a/src/providers/embeds/vidplay/types.ts +++ b/src/providers/embeds/vidplay/types.ts @@ -3,10 +3,10 @@ export type VidplaySourceResponse = { | { sources: { file: string; - tracks: { - file: string; - kind: string; - }[]; + }[]; + tracks: { + file: string; + kind: string; }[]; } | number; @@ -17,3 +17,8 @@ export type SubtitleResult = { label: string; kind: string; }[]; + +export type ThumbnailTrack = { + type: 'vtt'; + url: string; +};