mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 10:33:25 +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 '..';
|
||||
|
||||
export async function makeTMDBRequest(url: string): Promise<Response> {
|
||||
export async function makeTMDBRequest(url: string, appendToResponse?: string): Promise<Response> {
|
||||
const headers: {
|
||||
accept: 'application/json';
|
||||
authorization?: string;
|
||||
@@ -10,7 +10,7 @@ export async function makeTMDBRequest(url: string): Promise<Response> {
|
||||
accept: 'application/json',
|
||||
};
|
||||
|
||||
let requestURL = url;
|
||||
const requestURL = new URL(url);
|
||||
const key = getConfig().tmdbApiKey;
|
||||
|
||||
// * 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')) {
|
||||
headers.authorization = `Bearer ${key}`;
|
||||
} else {
|
||||
requestURL += `?api_key=${key}`;
|
||||
requestURL.searchParams.append('api_key', key);
|
||||
}
|
||||
|
||||
if (appendToResponse) {
|
||||
requestURL.searchParams.append('append_to_response', appendToResponse);
|
||||
}
|
||||
|
||||
return fetch(requestURL, {
|
||||
@@ -29,7 +33,7 @@ export async function makeTMDBRequest(url: string): Promise<Response> {
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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> {
|
||||
// * TV shows require the TMDB ID for the series, season, and episode
|
||||
// * 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();
|
||||
|
||||
if (series.success === false) {
|
||||
@@ -92,6 +96,6 @@ export async function getShowMediaDetails(id: string, seasonNumber: string, epis
|
||||
number: season.season_number,
|
||||
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';
|
||||
|
||||
export const vidplayBase = 'https://vidplay.site';
|
||||
@@ -66,5 +67,11 @@ export const getFuTokenKey = async (ctx: EmbedScrapeContext) => {
|
||||
|
||||
export const getFileUrl = async (ctx: EmbedScrapeContext) => {
|
||||
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 { flags } from '@/entrypoint/utils/targets';
|
||||
import { SourcererEmbed, SourcererOutput, makeSourcerer } from '@/providers/base';
|
||||
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
||||
|
||||
@@ -12,10 +13,11 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr
|
||||
const imdbId = ctx.media.imdbId;
|
||||
const url =
|
||||
ctx.media.type === 'movie'
|
||||
? `${vidSrcToBase}/embed/movie/${imdbId}`
|
||||
: `${vidSrcToBase}}/embed/tv/${imdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`;
|
||||
|
||||
const mainPage = await ctx.fetcher<string>(url);
|
||||
? `/embed/movie/${imdbId}`
|
||||
: `/embed/tv/${imdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`;
|
||||
const mainPage = await ctx.fetcher<string>(url, {
|
||||
baseUrl: vidSrcToBase,
|
||||
});
|
||||
const mainPage$ = load(mainPage);
|
||||
const dataId = mainPage$('a[data-id]').attr('data-id');
|
||||
if (!dataId) throw new Error('No data-id found');
|
||||
@@ -68,6 +70,6 @@ export const vidSrcToScraper = makeSourcerer({
|
||||
name: 'VidSrcTo',
|
||||
scrapeMovie: universalScraper,
|
||||
scrapeShow: universalScraper,
|
||||
flags: [],
|
||||
flags: [flags.CORS_ALLOWED],
|
||||
rank: 400,
|
||||
});
|
||||
|
Reference in New Issue
Block a user