use thumnails from vidplay

This commit is contained in:
TPN
2024-04-01 12:48:35 +00:00
parent 7e5d06434d
commit 38d4c97032
2 changed files with 20 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ import { makeEmbed } from '@/providers/base';
import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '@/providers/captions'; import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '@/providers/captions';
import { getFileUrl } from './common'; import { getFileUrl } from './common';
import { SubtitleResult, VidplaySourceResponse } from './types'; import { SubtitleResult, ThumbnailTrack, VidplaySourceResponse } from './types';
export const vidplayScraper = makeEmbed({ export const vidplayScraper = makeEmbed({
id: 'vidplay', id: 'vidplay',
@@ -18,6 +18,15 @@ export const vidplayScraper = makeEmbed({
}); });
if (typeof fileUrlRes.result === 'number') throw new Error('File not found'); if (typeof fileUrlRes.result === 'number') throw new Error('File not found');
const source = fileUrlRes.result.sources[0].file; 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 url = new URL(ctx.url);
const subtitlesLink = url.searchParams.get('sub.info'); const subtitlesLink = url.searchParams.get('sub.info');
@@ -47,6 +56,7 @@ export const vidplayScraper = makeEmbed({
playlist: source, playlist: source,
flags: [flags.CORS_ALLOWED], flags: [flags.CORS_ALLOWED],
captions, captions,
thumbnailTrack,
}, },
], ],
}; };

View File

@@ -3,10 +3,10 @@ export type VidplaySourceResponse = {
| { | {
sources: { sources: {
file: string; file: string;
tracks: { }[];
file: string; tracks: {
kind: string; file: string;
}[]; kind: string;
}[]; }[];
} }
| number; | number;
@@ -17,3 +17,8 @@ export type SubtitleResult = {
label: string; label: string;
kind: string; kind: string;
}[]; }[];
export type ThumbnailTrack = {
type: 'vtt';
url: string;
};