mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 14:53:24 +00:00
fixed feedback, added external_ids
This commit is contained in:
@@ -2,7 +2,7 @@ import { getConfig } from '@/dev-cli/config';
|
|||||||
|
|
||||||
import { MovieMedia, ShowMedia } from '..';
|
import { MovieMedia, ShowMedia } from '..';
|
||||||
|
|
||||||
export async function makeTMDBRequest(url: string): Promise<Response> {
|
export async function makeTMDBRequest(url: string, appendToResponse?: string): Promise<Response> {
|
||||||
const headers: {
|
const headers: {
|
||||||
accept: 'application/json';
|
accept: 'application/json';
|
||||||
authorization?: string;
|
authorization?: string;
|
||||||
@@ -10,7 +10,7 @@ export async function makeTMDBRequest(url: string): Promise<Response> {
|
|||||||
accept: 'application/json',
|
accept: 'application/json',
|
||||||
};
|
};
|
||||||
|
|
||||||
let requestURL = url;
|
const requestURL = new URL(url);
|
||||||
const key = getConfig().tmdbApiKey;
|
const key = getConfig().tmdbApiKey;
|
||||||
|
|
||||||
// * JWT keys always start with ey and are ONLY valid as a header.
|
// * JWT keys always start with ey and are ONLY valid as a header.
|
||||||
@@ -19,7 +19,11 @@ export async function makeTMDBRequest(url: string): Promise<Response> {
|
|||||||
if (key.startsWith('ey')) {
|
if (key.startsWith('ey')) {
|
||||||
headers.authorization = `Bearer ${key}`;
|
headers.authorization = `Bearer ${key}`;
|
||||||
} else {
|
} else {
|
||||||
requestURL += `?api_key=${key}`;
|
requestURL.searchParams.append('api_key', key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appendToResponse) {
|
||||||
|
requestURL.searchParams.append('append_to_response', appendToResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetch(requestURL, {
|
return fetch(requestURL, {
|
||||||
@@ -29,7 +33,7 @@ export async function makeTMDBRequest(url: string): Promise<Response> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getMovieMediaDetails(id: string): Promise<MovieMedia> {
|
export async function getMovieMediaDetails(id: string): Promise<MovieMedia> {
|
||||||
const response = await makeTMDBRequest(`https://api.themoviedb.org/3/movie/${id}`);
|
const response = await makeTMDBRequest(`https://api.themoviedb.org/3/movie/${id}`, 'external_ids');
|
||||||
const movie = await response.json();
|
const movie = await response.json();
|
||||||
|
|
||||||
if (movie.success === false) {
|
if (movie.success === false) {
|
||||||
@@ -52,7 +56,7 @@ export async function getMovieMediaDetails(id: string): Promise<MovieMedia> {
|
|||||||
export async function getShowMediaDetails(id: string, seasonNumber: string, episodeNumber: string): Promise<ShowMedia> {
|
export async function getShowMediaDetails(id: string, seasonNumber: string, episodeNumber: string): Promise<ShowMedia> {
|
||||||
// * TV shows require the TMDB ID for the series, season, and episode
|
// * TV shows require the TMDB ID for the series, season, and episode
|
||||||
// * and the name of the series. Needs multiple requests
|
// * and the name of the series. Needs multiple requests
|
||||||
let response = await makeTMDBRequest(`https://api.themoviedb.org/3/tv/${id}`);
|
let response = await makeTMDBRequest(`https://api.themoviedb.org/3/tv/${id}`, 'external_ids');
|
||||||
const series = await response.json();
|
const series = await response.json();
|
||||||
|
|
||||||
if (series.success === false) {
|
if (series.success === false) {
|
||||||
@@ -92,6 +96,6 @@ export async function getShowMediaDetails(id: string, seasonNumber: string, epis
|
|||||||
number: season.season_number,
|
number: season.season_number,
|
||||||
tmdbId: season.id,
|
tmdbId: season.id,
|
||||||
},
|
},
|
||||||
imdbId: series.imdb_id,
|
imdbId: series.external_ids.imdb_id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { makeFullUrl } from '@/fetchers/common';
|
||||||
import { EmbedScrapeContext } from '@/utils/context';
|
import { EmbedScrapeContext } from '@/utils/context';
|
||||||
|
|
||||||
export const vidplayBase = 'https://vidplay.site';
|
export const vidplayBase = 'https://vidplay.site';
|
||||||
@@ -66,5 +67,11 @@ export const getFuTokenKey = async (ctx: EmbedScrapeContext) => {
|
|||||||
|
|
||||||
export const getFileUrl = async (ctx: EmbedScrapeContext) => {
|
export const getFileUrl = async (ctx: EmbedScrapeContext) => {
|
||||||
const fuToken = await getFuTokenKey(ctx);
|
const fuToken = await getFuTokenKey(ctx);
|
||||||
return `${vidplayBase}/mediainfo/${fuToken}${new URL(ctx.url).search}&autostart=true`;
|
return makeFullUrl(`/mediainfo/${fuToken}`, {
|
||||||
|
baseUrl: vidplayBase,
|
||||||
|
query: {
|
||||||
|
...Object.fromEntries(new URL(ctx.url).searchParams.entries()),
|
||||||
|
autostart: 'true',
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
@@ -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';
|
||||||
|
|
||||||
@@ -12,10 +13,11 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr
|
|||||||
const imdbId = ctx.media.imdbId;
|
const imdbId = ctx.media.imdbId;
|
||||||
const url =
|
const url =
|
||||||
ctx.media.type === 'movie'
|
ctx.media.type === 'movie'
|
||||||
? `${vidSrcToBase}/embed/movie/${imdbId}`
|
? `/embed/movie/${imdbId}`
|
||||||
: `${vidSrcToBase}}/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.fetcher<string>(url);
|
baseUrl: vidSrcToBase,
|
||||||
|
});
|
||||||
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');
|
||||||
@@ -68,6 +70,6 @@ export const vidSrcToScraper = makeSourcerer({
|
|||||||
name: 'VidSrcTo',
|
name: 'VidSrcTo',
|
||||||
scrapeMovie: universalScraper,
|
scrapeMovie: universalScraper,
|
||||||
scrapeShow: universalScraper,
|
scrapeShow: universalScraper,
|
||||||
flags: [],
|
flags: [flags.CORS_ALLOWED],
|
||||||
rank: 400,
|
rank: 400,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user