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 { 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,
},
],
};

View File

@@ -3,11 +3,11 @@ export type VidplaySourceResponse = {
| {
sources: {
file: 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;
};