Revert "add wyzie subs"

This reverts commit 3d9efcc8f8.
This commit is contained in:
Pas 2025-04-06 12:18:31 -06:00
parent 3d9efcc8f8
commit d3f7dd088d
6 changed files with 31 additions and 138 deletions

View file

@ -93,8 +93,7 @@
"nanoid": "^3.3.8",
"node-fetch": "^3.3.2",
"set-cookie-parser": "^2.7.1",
"unpacker": "^1.0.1",
"wyzie-lib": "^2.2.1"
"unpacker": "^1.0.1"
},
"packageManager": "pnpm@9.14.4"
}

View file

@ -41,9 +41,6 @@ importers:
unpacker:
specifier: ^1.0.1
version: 1.0.1
wyzie-lib:
specifier: ^2.2.1
version: 2.2.1
devDependencies:
'@nabla/vite-plugin-eslint':
specifier: ^2.0.5
@ -2528,9 +2525,6 @@ packages:
utf-8-validate:
optional: true
wyzie-lib@2.2.1:
resolution: {integrity: sha512-oZtJnCTQCqLZimlD1Ex195+8e21/G5BWhixCE5/4Of77AI9igmIQCo/thWngOsdOufcnzvzTPYkWoNDxHc5lQg==}
y18n@5.0.8:
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'}
@ -5231,8 +5225,6 @@ snapshots:
ws@8.18.0: {}
wyzie-lib@2.2.1: {}
y18n@5.0.8: {}
yallist@4.0.0: {}

View file

@ -10,7 +10,6 @@ export type Caption = {
type: CaptionType;
id: string; // only unique per stream
opensubtitles?: boolean;
wyziesubs?: boolean;
url: string;
hasCorsRestrictions: boolean;
language: string;

View file

@ -9,7 +9,6 @@ import { NotFoundError } from '@/utils/errors';
import { addOpenSubtitlesCaptions } from '@/utils/opensubtitles';
import { requiresProxy, setupProxy } from '@/utils/proxy';
import { isValidStream, validatePlayableStreams } from '@/utils/valid';
import { addWyzieCaptions } from '@/utils/wyziesubs';
export type IndividualSourceRunnerOptions = {
features: FeatureMap;
@ -93,33 +92,18 @@ export async function scrapeInvidualSource(
if (playableStreams.length === 0) throw new NotFoundError('No playable streams found');
// opensubtitles
if (!ops.disableOpensubtitles) {
if (!ops.disableOpensubtitles)
for (const playableStream of playableStreams) {
// Try Wyzie subs first
if (ops.media.imdbId) {
playableStream.captions = await addWyzieCaptions(
playableStream.captions,
ops.media.tmdbId,
ops.media.imdbId,
ops.media.type === 'show' ? ops.media.season.number : undefined,
ops.media.type === 'show' ? ops.media.episode.number : undefined,
);
// Fall back to OpenSubtitles if no Wyzie subs found
if (!playableStream.captions.some((caption) => caption.wyziesubs)) {
playableStream.captions = await addOpenSubtitlesCaptions(
playableStream.captions,
ops,
btoa(
`${ops.media.imdbId}${
ops.media.type === 'show' ? `.${ops.media.season.number}.${ops.media.episode.number}` : ''
}`,
),
);
}
}
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;

View file

@ -11,7 +11,6 @@ import { reorderOnIdList } from '@/utils/list';
import { addOpenSubtitlesCaptions } from '@/utils/opensubtitles';
import { requiresProxy, setupProxy } from '@/utils/proxy';
import { isValidStream, validatePlayableStream } from '@/utils/valid';
import { addWyzieCaptions } from '@/utils/wyziesubs';
export type RunOutput = {
sourceId: string;
@ -117,31 +116,16 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt
if (!playableStream) throw new NotFoundError('No streams found');
// opensubtitles
if (!ops.disableOpensubtitles) {
if (ops.media.imdbId) {
// Try Wyzie subs first
playableStream.captions = await addWyzieCaptions(
playableStream.captions,
ops.media.tmdbId,
ops.media.imdbId,
ops.media.type === 'show' ? ops.media.season.number : undefined,
ops.media.type === 'show' ? ops.media.episode.number : undefined,
);
// Fall back to OpenSubtitles if no Wyzie subs found
if (!playableStream.captions.some((caption) => caption.wyziesubs)) {
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,
@ -195,31 +179,16 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt
if (!playableStream) throw new NotFoundError('No streams found');
// opensubtitles
if (!ops.disableOpensubtitles) {
if (ops.media.imdbId) {
// Try Wyzie subs first
playableStream.captions = await addWyzieCaptions(
playableStream.captions,
ops.media.tmdbId,
ops.media.imdbId,
ops.media.type === 'show' ? ops.media.season.number : undefined,
ops.media.type === 'show' ? ops.media.episode.number : undefined,
);
// Fall back to OpenSubtitles if no Wyzie subs found
if (!playableStream.captions.some((caption) => caption.wyziesubs)) {
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 = {

View file

@ -1,50 +0,0 @@
import { type SubtitleData, searchSubtitles } from 'wyzie-lib';
import { Caption } from '@/providers/captions';
export async function addWyzieCaptions(
captions: Caption[],
tmdbId: string | number,
imdbId: string,
season?: number,
episode?: number,
): Promise<Caption[]> {
try {
const searchParams: any = {
format: 'srt',
};
// Prefer TMDB ID if available, otherwise use IMDB ID
if (tmdbId) {
// Convert TMDB ID to number if it's a string
searchParams.tmdb_id = typeof tmdbId === 'string' ? parseInt(tmdbId, 10) : tmdbId;
} else if (imdbId) {
// Remove 'tt' prefix from IMDB ID if present
searchParams.imdb_id = imdbId.replace(/^tt/, '');
}
// Add season and episode if provided (for TV shows)
if (season && episode) {
searchParams.season = season;
searchParams.episode = episode;
}
console.log('Searching Wyzie subtitles with params:', searchParams);
const wyzieSubtitles: SubtitleData[] = await searchSubtitles(searchParams);
console.log('Found Wyzie subtitles:', wyzieSubtitles);
const wyzieCaptions: Caption[] = wyzieSubtitles.map((subtitle) => ({
id: subtitle.id,
url: subtitle.url,
type: subtitle.format as 'srt' | 'vtt',
hasCorsRestrictions: false,
language: subtitle.language,
wyziesubs: true,
}));
return [...captions, ...wyzieCaptions];
} catch (error) {
console.error('Error fetching Wyzie subtitles:', error);
return captions;
}
}