mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 15:33:26 +00:00
fix gomovies
This commit is contained in:
@@ -2,7 +2,12 @@ import { load } from 'cheerio';
|
|||||||
|
|
||||||
import { flags } from '@/entrypoint/utils/targets';
|
import { flags } from '@/entrypoint/utils/targets';
|
||||||
import { makeSourcerer } from '@/providers/base';
|
import { makeSourcerer } from '@/providers/base';
|
||||||
|
import { doodScraper } from '@/providers/embeds/dood';
|
||||||
|
import { mixdropScraper } from '@/providers/embeds/mixdrop';
|
||||||
import { upcloudScraper } from '@/providers/embeds/upcloud';
|
import { upcloudScraper } from '@/providers/embeds/upcloud';
|
||||||
|
import { upstreamScraper } from '@/providers/embeds/upstream';
|
||||||
|
import { vidCloudScraper } from '@/providers/embeds/vidcloud';
|
||||||
|
import { voeScraper } from '@/providers/embeds/voe';
|
||||||
import { NotFoundError } from '@/utils/errors';
|
import { NotFoundError } from '@/utils/errors';
|
||||||
|
|
||||||
import { getSource } from './source';
|
import { getSource } from './source';
|
||||||
@@ -16,9 +21,8 @@ export const goMoviesScraper = makeSourcerer({
|
|||||||
flags: [flags.CORS_ALLOWED],
|
flags: [flags.CORS_ALLOWED],
|
||||||
disabled: true,
|
disabled: true,
|
||||||
async scrapeShow(ctx) {
|
async scrapeShow(ctx) {
|
||||||
const search = await ctx.proxiedFetcher<string>(`/ajax/search`, {
|
const search = await ctx.proxiedFetcher(`/search/${ctx.media.title.replaceAll(/[^a-z0-9A-Z]/g, '-')}`, {
|
||||||
method: 'POST',
|
method: 'GET',
|
||||||
body: new URLSearchParams({ keyword: ctx.media.title }),
|
|
||||||
headers: {
|
headers: {
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
},
|
},
|
||||||
@@ -26,12 +30,12 @@ export const goMoviesScraper = makeSourcerer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const searchPage = load(search);
|
const searchPage = load(search);
|
||||||
const mediaElements = searchPage('a.nav-item');
|
const mediaElements = searchPage('div.film-detail');
|
||||||
|
|
||||||
const mediaData = mediaElements.toArray().map((movieEl) => {
|
const mediaData = mediaElements.toArray().map((movieEl) => {
|
||||||
const name = searchPage(movieEl).find('h3.film-name')?.text();
|
const name = searchPage(movieEl).find('h2.film-name a')?.text();
|
||||||
const year = searchPage(movieEl).find('div.film-infor span:first-of-type')?.text();
|
const year = searchPage(movieEl).find('span.fdi-item:first')?.text();
|
||||||
const path = searchPage(movieEl).attr('href');
|
const path = searchPage(movieEl).find('h2.film-name a').attr('href');
|
||||||
return { name, year, path };
|
return { name, year, path };
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -89,21 +93,57 @@ export const goMoviesScraper = makeSourcerer({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const upcloudSource = await getSource(ctx, sources);
|
// there's a better way to do this but I'm too lazy to do that
|
||||||
|
const upcloudSource = await getSource(ctx, sources, 'upcloud');
|
||||||
|
const vidcloudSource = await getSource(ctx, sources, 'vidcloud');
|
||||||
|
const voeSource = await getSource(ctx, sources, 'voe');
|
||||||
|
const doodSource = await getSource(ctx, sources, 'doodstream');
|
||||||
|
const upstreamSource = await getSource(ctx, sources, 'upstream');
|
||||||
|
const mixdropSource = await getSource(ctx, sources, 'mixdrop');
|
||||||
|
|
||||||
|
const embeds = [
|
||||||
|
{
|
||||||
|
embedId: upcloudScraper.id,
|
||||||
|
url: upcloudSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: vidCloudScraper.id,
|
||||||
|
url: vidcloudSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: voeScraper.id,
|
||||||
|
url: voeSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: doodScraper.id,
|
||||||
|
url: doodSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: upstreamScraper.id,
|
||||||
|
url: upstreamSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: mixdropScraper.id,
|
||||||
|
url: mixdropSource?.link ?? null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const filteredEmbeds = embeds
|
||||||
|
.filter((embed) => embed.url !== null)
|
||||||
|
.map((embed) => ({
|
||||||
|
embedId: embed.embedId,
|
||||||
|
url: embed.url as string,
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (filteredEmbeds.length === 0) throw new Error('No valid embeds found.');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
embeds: [
|
embeds: filteredEmbeds,
|
||||||
{
|
|
||||||
embedId: upcloudScraper.id,
|
|
||||||
url: upcloudSource.link,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async scrapeMovie(ctx) {
|
async scrapeMovie(ctx) {
|
||||||
const search = await ctx.proxiedFetcher<string>(`ajax/search`, {
|
const search = await ctx.proxiedFetcher(`/search/${ctx.media.title.replaceAll(/[^a-z0-9A-Z]/g, '-')}`, {
|
||||||
method: 'POST',
|
method: 'GET',
|
||||||
body: new URLSearchParams({ keyword: ctx.media.title }),
|
|
||||||
headers: {
|
headers: {
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
},
|
},
|
||||||
@@ -111,12 +151,12 @@ export const goMoviesScraper = makeSourcerer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const searchPage = load(search);
|
const searchPage = load(search);
|
||||||
const mediaElements = searchPage('a.nav-item');
|
const mediaElements = searchPage('div.film-detail');
|
||||||
|
|
||||||
const mediaData = mediaElements.toArray().map((movieEl) => {
|
const mediaData = mediaElements.toArray().map((movieEl) => {
|
||||||
const name = searchPage(movieEl).find('h3.film-name')?.text();
|
const name = searchPage(movieEl).find('h2.film-name a')?.text();
|
||||||
const year = searchPage(movieEl).find('div.film-infor span:first-of-type')?.text();
|
const year = searchPage(movieEl).find('span.fdi-item:first')?.text();
|
||||||
const path = searchPage(movieEl).attr('href');
|
const path = searchPage(movieEl).find('h2.film-name a').attr('href');
|
||||||
return { name, year, path };
|
return { name, year, path };
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -136,15 +176,52 @@ export const goMoviesScraper = makeSourcerer({
|
|||||||
baseUrl: gomoviesBase,
|
baseUrl: gomoviesBase,
|
||||||
});
|
});
|
||||||
|
|
||||||
const upcloudSource = await getSource(ctx, sources);
|
// there's a better way to do this but I'm too lazy to do that
|
||||||
|
const upcloudSource = await getSource(ctx, sources, 'upcloud');
|
||||||
|
const vidcloudSource = await getSource(ctx, sources, 'vidcloud');
|
||||||
|
const voeSource = await getSource(ctx, sources, 'voe');
|
||||||
|
const doodSource = await getSource(ctx, sources, 'doodstream');
|
||||||
|
const upstreamSource = await getSource(ctx, sources, 'upstream');
|
||||||
|
const mixdropSource = await getSource(ctx, sources, 'mixdrop');
|
||||||
|
|
||||||
|
const embeds = [
|
||||||
|
{
|
||||||
|
embedId: upcloudScraper.id,
|
||||||
|
url: upcloudSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: vidCloudScraper.id,
|
||||||
|
url: vidcloudSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: voeScraper.id,
|
||||||
|
url: voeSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: doodScraper.id,
|
||||||
|
url: doodSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: upstreamScraper.id,
|
||||||
|
url: upstreamSource?.link ?? null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
embedId: mixdropScraper.id,
|
||||||
|
url: mixdropSource?.link ?? null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const filteredEmbeds = embeds
|
||||||
|
.filter((embed) => embed.url !== null)
|
||||||
|
.map((embed) => ({
|
||||||
|
embedId: embed.embedId,
|
||||||
|
url: embed.url as string,
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (filteredEmbeds.length === 0) throw new Error('No valid embeds found.');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
embeds: [
|
embeds: filteredEmbeds,
|
||||||
{
|
|
||||||
embedId: upcloudScraper.id,
|
|
||||||
url: upcloudSource.link,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@@ -1,31 +1,30 @@
|
|||||||
import { load } from 'cheerio';
|
import { load } from 'cheerio';
|
||||||
|
|
||||||
import { ScrapeContext } from '@/utils/context';
|
import { ScrapeContext } from '@/utils/context';
|
||||||
import { NotFoundError } from '@/utils/errors';
|
|
||||||
|
|
||||||
import { gomoviesBase } from '.';
|
import { gomoviesBase } from '.';
|
||||||
|
|
||||||
export async function getSource(ctx: ScrapeContext, sources: any) {
|
export async function getSource(ctx: ScrapeContext, sources: any, title: string) {
|
||||||
const upcloud = load(sources)('a[title*="upcloud" i]');
|
const source = load(sources)(`a[title*=${title} i]`);
|
||||||
|
|
||||||
const upcloudDataId = upcloud?.attr('data-id') ?? upcloud?.attr('data-linkid');
|
const sourceDataId = source?.attr('data-id') ?? source?.attr('data-linkid');
|
||||||
|
|
||||||
if (!upcloudDataId) throw new NotFoundError('Upcloud source not available');
|
if (!sourceDataId) return undefined;
|
||||||
|
|
||||||
const upcloudSource = await ctx.proxiedFetcher<{
|
const sourceData = await ctx.proxiedFetcher<{
|
||||||
type: 'iframe' | string;
|
type: 'iframe' | string;
|
||||||
link: string;
|
link: string;
|
||||||
sources: [];
|
sources: [];
|
||||||
title: string;
|
title: string;
|
||||||
tracks: [];
|
tracks: [];
|
||||||
}>(`/ajax/sources/${upcloudDataId}`, {
|
}>(`/ajax/sources/${sourceDataId}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
},
|
},
|
||||||
baseUrl: gomoviesBase,
|
baseUrl: gomoviesBase,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!upcloudSource.link || upcloudSource.type !== 'iframe') throw new NotFoundError('No upcloud stream found');
|
if (!sourceData.link || sourceData.type !== 'iframe') return undefined;
|
||||||
|
|
||||||
return upcloudSource;
|
return sourceData;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user