Add an option to disable opensubtitles in runners
This commit is contained in:
parent
0c7f65edb6
commit
2627406b77
|
@ -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 {
|
||||
|
|
|
@ -18,6 +18,7 @@ export type IndividualSourceRunnerOptions = {
|
|||
id: string;
|
||||
events?: IndividualScraperEvents;
|
||||
proxyStreams?: boolean; // temporary
|
||||
disableOpensubtitles?: boolean;
|
||||
};
|
||||
|
||||
export async function scrapeInvidualSource(
|
||||
|
@ -74,12 +75,13 @@ export async function scrapeInvidualSource(
|
|||
});
|
||||
|
||||
// opensubtitles
|
||||
for (const embed of output.embeds)
|
||||
embed.url = `${embed.url}${btoa('MEDIA=')}${btoa(
|
||||
`${ops.media.imdbId}${
|
||||
ops.media.type === 'show' ? `.${ops.media.season.number}.${ops.media.episode.number}` : ''
|
||||
}`,
|
||||
)}`;
|
||||
if (!ops.disableOpensubtitles)
|
||||
for (const embed of output.embeds)
|
||||
embed.url = `${embed.url}${btoa('MEDIA=')}${btoa(
|
||||
`${ops.media.imdbId}${
|
||||
ops.media.type === 'show' ? `.${ops.media.season.number}.${ops.media.episode.number}` : ''
|
||||
}`,
|
||||
)}`;
|
||||
|
||||
if ((!output.stream || output.stream.length === 0) && output.embeds.length === 0)
|
||||
throw new NotFoundError('No streams found');
|
||||
|
@ -90,17 +92,18 @@ export async function scrapeInvidualSource(
|
|||
if (playableStreams.length === 0) throw new NotFoundError('No playable streams found');
|
||||
|
||||
// opensubtitles
|
||||
for (const playableStream of playableStreams) {
|
||||
playableStream.captions = await addOpenSubtitlesCaptions(
|
||||
playableStream.captions,
|
||||
ops,
|
||||
btoa(
|
||||
`${ops.media.imdbId}${
|
||||
ops.media.type === 'show' ? `.${ops.media.season.number}.${ops.media.episode.number}` : ''
|
||||
}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (!ops.disableOpensubtitles)
|
||||
for (const playableStream of playableStreams) {
|
||||
playableStream.captions = await addOpenSubtitlesCaptions(
|
||||
playableStream.captions,
|
||||
ops,
|
||||
btoa(
|
||||
`${ops.media.imdbId}${
|
||||
ops.media.type === 'show' ? `.${ops.media.season.number}.${ops.media.episode.number}` : ''
|
||||
}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
output.stream = playableStreams;
|
||||
}
|
||||
return output;
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,15 +116,16 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt
|
|||
if (!playableStream) throw new NotFoundError('No streams found');
|
||||
|
||||
// opensubtitles
|
||||
playableStream.captions = await addOpenSubtitlesCaptions(
|
||||
playableStream.captions,
|
||||
ops,
|
||||
btoa(
|
||||
`${ops.media.imdbId}${
|
||||
ops.media.type === 'show' ? `.${ops.media.season.number}.${ops.media.episode.number}` : ''
|
||||
}`,
|
||||
),
|
||||
);
|
||||
if (!ops.disableOpensubtitles)
|
||||
playableStream.captions = await addOpenSubtitlesCaptions(
|
||||
playableStream.captions,
|
||||
ops,
|
||||
btoa(
|
||||
`${ops.media.imdbId}${
|
||||
ops.media.type === 'show' ? `.${ops.media.season.number}.${ops.media.episode.number}` : ''
|
||||
}`,
|
||||
),
|
||||
);
|
||||
|
||||
return {
|
||||
sourceId: source.id,
|
||||
|
@ -177,15 +179,16 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt
|
|||
if (!playableStream) throw new NotFoundError('No streams found');
|
||||
|
||||
// opensubtitles
|
||||
playableStream.captions = await addOpenSubtitlesCaptions(
|
||||
playableStream.captions,
|
||||
ops,
|
||||
btoa(
|
||||
`${ops.media.imdbId}${
|
||||
ops.media.type === 'show' ? `.${ops.media.season.number}.${ops.media.episode.number}` : ''
|
||||
}`,
|
||||
),
|
||||
);
|
||||
if (!ops.disableOpensubtitles)
|
||||
playableStream.captions = await addOpenSubtitlesCaptions(
|
||||
playableStream.captions,
|
||||
ops,
|
||||
btoa(
|
||||
`${ops.media.imdbId}${
|
||||
ops.media.type === 'show' ? `.${ops.media.season.number}.${ops.media.episode.number}` : ''
|
||||
}`,
|
||||
),
|
||||
);
|
||||
embedOutput.stream = [playableStream];
|
||||
} catch (error) {
|
||||
const updateParams: UpdateEvent = {
|
||||
|
|
Loading…
Reference in New Issue