mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 12:43:25 +00:00
proxied fetcher
This commit is contained in:
@@ -14,7 +14,11 @@ export const fileMoonScraper = makeEmbed({
|
|||||||
name: 'Filemoon',
|
name: 'Filemoon',
|
||||||
rank: 400,
|
rank: 400,
|
||||||
scrape: async (ctx) => {
|
scrape: async (ctx) => {
|
||||||
const embedRes = await ctx.fetcher<string>(ctx.url);
|
const embedRes = await ctx.proxiedFetcher<string>(ctx.url, {
|
||||||
|
headers: {
|
||||||
|
referer: ctx.url,
|
||||||
|
},
|
||||||
|
});
|
||||||
const evalCode = evalCodeRegex.exec(embedRes);
|
const evalCode = evalCodeRegex.exec(embedRes);
|
||||||
if (!evalCode) throw new Error('Failed to find eval code');
|
if (!evalCode) throw new Error('Failed to find eval code');
|
||||||
const unpacked = unpack(evalCode[1]);
|
const unpacked = unpack(evalCode[1]);
|
||||||
@@ -25,7 +29,7 @@ export const fileMoonScraper = makeEmbed({
|
|||||||
const subtitlesLink = url.searchParams.get('sub.info');
|
const subtitlesLink = url.searchParams.get('sub.info');
|
||||||
const captions: Caption[] = [];
|
const captions: Caption[] = [];
|
||||||
if (subtitlesLink) {
|
if (subtitlesLink) {
|
||||||
const captionsResult = await ctx.fetcher<SubtitleResult>(subtitlesLink);
|
const captionsResult = await ctx.proxiedFetcher<SubtitleResult>(subtitlesLink);
|
||||||
|
|
||||||
for (const caption of captionsResult) {
|
for (const caption of captionsResult) {
|
||||||
const language = labelToLanguageCode(caption.label);
|
const language = labelToLanguageCode(caption.label);
|
||||||
|
@@ -22,7 +22,7 @@ export const vidplayScraper = makeEmbed({
|
|||||||
const subtitlesLink = url.searchParams.get('sub.info');
|
const subtitlesLink = url.searchParams.get('sub.info');
|
||||||
const captions: Caption[] = [];
|
const captions: Caption[] = [];
|
||||||
if (subtitlesLink) {
|
if (subtitlesLink) {
|
||||||
const captionsResult = await ctx.fetcher<SubtitleResult>(subtitlesLink);
|
const captionsResult = await ctx.proxiedFetcher<SubtitleResult>(subtitlesLink);
|
||||||
|
|
||||||
for (const caption of captionsResult) {
|
for (const caption of captionsResult) {
|
||||||
const language = labelToLanguageCode(caption.label);
|
const language = labelToLanguageCode(caption.label);
|
||||||
|
@@ -8,6 +8,7 @@ import { decryptSourceUrl } from './common';
|
|||||||
import { SourceResult, SourcesResult } from './types';
|
import { SourceResult, SourcesResult } from './types';
|
||||||
|
|
||||||
const vidSrcToBase = 'https://vidsrc.to';
|
const vidSrcToBase = 'https://vidsrc.to';
|
||||||
|
const referer = `${vidSrcToBase}/`;
|
||||||
|
|
||||||
const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Promise<SourcererOutput> => {
|
const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Promise<SourcererOutput> => {
|
||||||
const imdbId = ctx.media.imdbId;
|
const imdbId = ctx.media.imdbId;
|
||||||
@@ -15,22 +16,31 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr
|
|||||||
ctx.media.type === 'movie'
|
ctx.media.type === 'movie'
|
||||||
? `/embed/movie/${imdbId}`
|
? `/embed/movie/${imdbId}`
|
||||||
: `/embed/tv/${imdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`;
|
: `/embed/tv/${imdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`;
|
||||||
const mainPage = await ctx.fetcher<string>(url, {
|
const mainPage = await ctx.proxiedFetcher<string>(url, {
|
||||||
baseUrl: vidSrcToBase,
|
baseUrl: vidSrcToBase,
|
||||||
|
headers: {
|
||||||
|
referer,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const mainPage$ = load(mainPage);
|
const mainPage$ = load(mainPage);
|
||||||
const dataId = mainPage$('a[data-id]').attr('data-id');
|
const dataId = mainPage$('a[data-id]').attr('data-id');
|
||||||
if (!dataId) throw new Error('No data-id found');
|
if (!dataId) throw new Error('No data-id found');
|
||||||
const sources = await ctx.fetcher<SourcesResult>(`/ajax/embed/episode/${dataId}/sources`, {
|
const sources = await ctx.proxiedFetcher<SourcesResult>(`/ajax/embed/episode/${dataId}/sources`, {
|
||||||
baseUrl: vidSrcToBase,
|
baseUrl: vidSrcToBase,
|
||||||
|
headers: {
|
||||||
|
referer,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
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 embedUrls = [];
|
||||||
for (const source of sources.result) {
|
for (const source of sources.result) {
|
||||||
const sourceRes = await ctx.fetcher<SourceResult>(`/ajax/embed/source/${source.id}`, {
|
const sourceRes = await ctx.proxiedFetcher<SourceResult>(`/ajax/embed/source/${source.id}`, {
|
||||||
baseUrl: vidSrcToBase,
|
baseUrl: vidSrcToBase,
|
||||||
|
headers: {
|
||||||
|
referer,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const decryptedUrl = decryptSourceUrl(sourceRes.result.url);
|
const decryptedUrl = decryptSourceUrl(sourceRes.result.url);
|
||||||
embedUrls.push(decryptedUrl);
|
embedUrls.push(decryptedUrl);
|
||||||
|
Reference in New Issue
Block a user