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