mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 11:33:25 +00:00
Merge pull request #112 from Paradox-77/dev
Fix embedUrl matching for Vidplay and Filemoon sources
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { unpack } from 'unpacker';
|
import { unpack } from 'unpacker';
|
||||||
|
|
||||||
|
import { flags } from '@/entrypoint/utils/targets';
|
||||||
|
|
||||||
import { SubtitleResult } from './types';
|
import { SubtitleResult } from './types';
|
||||||
import { makeEmbed } from '../../base';
|
import { makeEmbed } from '../../base';
|
||||||
import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '../../captions';
|
import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '../../captions';
|
||||||
@@ -49,7 +51,7 @@ export const fileMoonScraper = makeEmbed({
|
|||||||
id: 'primary',
|
id: 'primary',
|
||||||
type: 'hls',
|
type: 'hls',
|
||||||
playlist: file[1],
|
playlist: file[1],
|
||||||
flags: [],
|
flags: [flags.CORS_ALLOWED],
|
||||||
captions,
|
captions,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
|
import { flags } from '@/entrypoint/utils/targets';
|
||||||
import { makeEmbed } from '@/providers/base';
|
import { makeEmbed } from '@/providers/base';
|
||||||
import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '@/providers/captions';
|
import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '@/providers/captions';
|
||||||
|
|
||||||
import { getFileUrl, referer } from './common';
|
import { getFileUrl } from './common';
|
||||||
import { SubtitleResult, VidplaySourceResponse } from './types';
|
import { SubtitleResult, VidplaySourceResponse } from './types';
|
||||||
|
|
||||||
export const vidplayScraper = makeEmbed({
|
export const vidplayScraper = makeEmbed({
|
||||||
@@ -44,12 +45,8 @@ export const vidplayScraper = makeEmbed({
|
|||||||
id: 'primary',
|
id: 'primary',
|
||||||
type: 'hls',
|
type: 'hls',
|
||||||
playlist: source,
|
playlist: source,
|
||||||
flags: [],
|
flags: [flags.CORS_ALLOWED],
|
||||||
captions,
|
captions,
|
||||||
preferredHeaders: {
|
|
||||||
Referer: referer,
|
|
||||||
Origin: referer,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { load } from 'cheerio';
|
import { load } from 'cheerio';
|
||||||
|
|
||||||
|
import { flags } from '@/entrypoint/utils/targets';
|
||||||
import { SourcererEmbed, SourcererOutput, makeSourcerer } from '@/providers/base';
|
import { SourcererEmbed, SourcererOutput, makeSourcerer } from '@/providers/base';
|
||||||
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr
|
|||||||
if (sources.status !== 200) throw new Error('No sources found');
|
if (sources.status !== 200) throw new Error('No sources found');
|
||||||
|
|
||||||
const embeds: SourcererEmbed[] = [];
|
const embeds: SourcererEmbed[] = [];
|
||||||
const embedUrls = [];
|
const embedArr = [];
|
||||||
for (const source of sources.result) {
|
for (const source of sources.result) {
|
||||||
const sourceRes = await ctx.proxiedFetcher<SourceResult>(`/ajax/embed/source/${source.id}`, {
|
const sourceRes = await ctx.proxiedFetcher<SourceResult>(`/ajax/embed/source/${source.id}`, {
|
||||||
baseUrl: vidSrcToBase,
|
baseUrl: vidSrcToBase,
|
||||||
@@ -42,28 +43,23 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const decryptedUrl = decryptSourceUrl(sourceRes.result.url);
|
const decryptedUrl = decryptSourceUrl(sourceRes.result.url);
|
||||||
embedUrls.push(decryptedUrl);
|
embedArr.push({ source: source.title, url: decryptedUrl });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Originally Filemoon does not have subtitles. But we can use the ones from Vidplay.
|
for (const embedObj of embedArr) {
|
||||||
const urlWithSubtitles = embedUrls.find((v) => v.includes('sub.info'));
|
if (embedObj.source === 'Vidplay') {
|
||||||
let subtitleUrl: string | null = null;
|
const fullUrl = new URL(embedObj.url);
|
||||||
if (urlWithSubtitles) subtitleUrl = new URL(urlWithSubtitles).searchParams.get('sub.info');
|
|
||||||
|
|
||||||
for (const source of sources.result) {
|
|
||||||
if (source.title === 'Vidplay') {
|
|
||||||
const embedUrl = embedUrls.find((v) => v.includes('vidplay'));
|
|
||||||
if (!embedUrl) continue;
|
|
||||||
embeds.push({
|
embeds.push({
|
||||||
embedId: 'vidplay',
|
embedId: 'vidplay',
|
||||||
url: embedUrl,
|
url: fullUrl.toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source.title === 'Filemoon') {
|
if (embedObj.source === 'Filemoon') {
|
||||||
const embedUrl = embedUrls.find((v) => v.includes('filemoon'));
|
const fullUrl = new URL(embedObj.url);
|
||||||
if (!embedUrl) continue;
|
// Originally Filemoon does not have subtitles. But we can use the ones from Vidplay.
|
||||||
const fullUrl = new URL(embedUrl);
|
const urlWithSubtitles = embedArr.find((v) => v.source === 'Vidplay' && v.url.includes('sub.info'))?.url;
|
||||||
|
const subtitleUrl = urlWithSubtitles ? new URL(urlWithSubtitles).searchParams.get('sub.info') : null;
|
||||||
if (subtitleUrl) fullUrl.searchParams.set('sub.info', subtitleUrl);
|
if (subtitleUrl) fullUrl.searchParams.set('sub.info', subtitleUrl);
|
||||||
embeds.push({
|
embeds.push({
|
||||||
embedId: 'filemoon',
|
embedId: 'filemoon',
|
||||||
@@ -82,6 +78,6 @@ export const vidSrcToScraper = makeSourcerer({
|
|||||||
name: 'VidSrcTo',
|
name: 'VidSrcTo',
|
||||||
scrapeMovie: universalScraper,
|
scrapeMovie: universalScraper,
|
||||||
scrapeShow: universalScraper,
|
scrapeShow: universalScraper,
|
||||||
flags: [],
|
flags: [flags.CORS_ALLOWED],
|
||||||
rank: 300,
|
rank: 300,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user