chore: cleanup

This commit is contained in:
Adrian Castro
2024-02-20 16:18:59 +01:00
parent 45b924911c
commit 31f6a7e851

View File

@@ -116,106 +116,6 @@ export async function getVideoStreamFromEmbed({
return embedResult;
}
// export async function getVideoStream({
// sourceId,
// media,
// forceVTT,
// onEvent,
// }: {
// sourceId?: string;
// media: ScrapeMedia;
// forceVTT?: boolean;
// onEvent?: (event: RunnerEvent) => void;
// }): Promise<Stream | null> {
// const providers = makeProviders({
// fetcher: makeStandardFetcher(fetch),
// target: targets.NATIVE,
// consistentIpForRequests: true,
// });
// const options: RunnerOptions = {
// media,
// events: {
// init: onEvent,
// update: onEvent,
// discoverEmbeds: onEvent,
// start: onEvent,
// },
// };
// let stream: Stream | null = null;
// if (sourceId) {
// onEvent && onEvent({ sourceIds: [sourceId] });
// let embedOutput: EmbedOutput | undefined;
// const sourceResult = await providers
// .runSourceScraper({
// id: sourceId,
// media,
// events: {},
// })
// .catch((error: Error) => {
// onEvent &&
// onEvent({ id: sourceId, percentage: 0, status: "failure", error });
// return undefined;
// });
// if (sourceResult) {
// onEvent && onEvent({ id: sourceId, percentage: 50, status: "pending" });
// for (const embed of sourceResult.embeds) {
// const embedResult = await providers
// .runEmbedScraper({
// id: embed.embedId,
// url: embed.url,
// })
// .catch(() => undefined);
// if (embedResult) {
// embedOutput = embedResult;
// onEvent &&
// onEvent({ id: embed.embedId, percentage: 100, status: "success" });
// }
// }
// }
// if (embedOutput) {
// stream = embedOutput.stream[0] ?? null;
// } else if (sourceResult) {
// stream = sourceResult.stream?.[0] ?? null;
// }
// if (stream) {
// onEvent && onEvent({ id: sourceId, percentage: 100, status: "success" });
// } else {
// onEvent && onEvent({ id: sourceId, percentage: 100, status: "notfound" });
// }
// } else {
// stream = await providers
// .runAll(options)
// .then((result) => result?.stream ?? null);
// }
// if (!stream) return null;
// if (forceVTT) {
// if (stream.captions && stream.captions.length > 0) {
// for (const caption of stream.captions) {
// if (caption.type === "srt") {
// const response = await fetch(caption.url);
// const srtSubtitle = await response.blob();
// const vttSubtitleUrl = await toWebVTT(srtSubtitle);
// caption.url = vttSubtitleUrl;
// caption.type = "vtt";
// }
// }
// }
// }
// return stream;
// }
export function findHighestQuality(
stream: FileBasedStream,
): Qualities | undefined {