Add an option to disable opensubtitles in runners

This commit is contained in:
TPN 2024-08-05 14:47:31 +00:00
parent 0c7f65edb6
commit 2627406b77
3 changed files with 55 additions and 36 deletions

View File

@ -31,6 +31,10 @@ export interface RunnerOptions {
// the media you want to see sources from
media: ScrapeMedia;
// it makes sense to have this in the builder
// but I belive it's more useful in runner ops
disableOpensubtitles?: boolean;
}
export interface SourceRunnerOptions {
@ -42,6 +46,10 @@ export interface SourceRunnerOptions {
// id of the source scraper you want to scrape from
id: string;
// it makes sense to have this in the builder
// but I belive it's more useful in runner ops
disableOpensubtitles?: boolean;
}
export interface EmbedRunnerOptions {
@ -53,6 +61,10 @@ export interface EmbedRunnerOptions {
// id of the embed scraper you want to scrape from
id: string;
// it makes sense to have this in the builder
// but I belive it's more useful in runner ops
disableOpensubtitles?: boolean;
}
export interface ProviderControls {

View File

@ -18,6 +18,7 @@ export type IndividualSourceRunnerOptions = {
id: string;
events?: IndividualScraperEvents;
proxyStreams?: boolean; // temporary
disableOpensubtitles?: boolean;
};
export async function scrapeInvidualSource(
@ -74,6 +75,7 @@ export async function scrapeInvidualSource(
});
// opensubtitles
if (!ops.disableOpensubtitles)
for (const embed of output.embeds)
embed.url = `${embed.url}${btoa('MEDIA=')}${btoa(
`${ops.media.imdbId}${
@ -90,6 +92,7 @@ export async function scrapeInvidualSource(
if (playableStreams.length === 0) throw new NotFoundError('No playable streams found');
// opensubtitles
if (!ops.disableOpensubtitles)
for (const playableStream of playableStreams) {
playableStream.captions = await addOpenSubtitlesCaptions(
playableStream.captions,
@ -114,6 +117,7 @@ export type IndividualEmbedRunnerOptions = {
id: string;
events?: IndividualScraperEvents;
proxyStreams?: boolean; // temporary
disableOpensubtitles?: boolean;
};
export async function scrapeIndividualEmbed(
@ -152,7 +156,7 @@ export async function scrapeIndividualEmbed(
const playableStreams = await validatePlayableStreams(output.stream, ops, embedScraper.id);
if (playableStreams.length === 0) throw new NotFoundError('No playable streams found');
if (media)
if (media && !ops.disableOpensubtitles)
for (const playableStream of playableStreams)
playableStream.captions = await addOpenSubtitlesCaptions(playableStream.captions, ops, media);

View File

@ -38,6 +38,7 @@ export type ProviderRunnerOptions = {
events?: FullScraperEvents;
media: ScrapeMedia;
proxyStreams?: boolean; // temporary
disableOpensubtitles?: boolean;
};
export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOptions): Promise<RunOutput | null> {
@ -115,6 +116,7 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt
if (!playableStream) throw new NotFoundError('No streams found');
// opensubtitles
if (!ops.disableOpensubtitles)
playableStream.captions = await addOpenSubtitlesCaptions(
playableStream.captions,
ops,
@ -177,6 +179,7 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt
if (!playableStream) throw new NotFoundError('No streams found');
// opensubtitles
if (!ops.disableOpensubtitles)
playableStream.captions = await addOpenSubtitlesCaptions(
playableStream.captions,
ops,