mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-28 16:51:52 +01:00
fix: move meta id check to providers
This commit is contained in:
parent
b9448b5231
commit
bb869fd7e3
@ -4,7 +4,6 @@ import { MWMediaType } from "@/backend/metadata/types";
|
|||||||
export const testData: DetailedMeta[] = [
|
export const testData: DetailedMeta[] = [
|
||||||
{
|
{
|
||||||
imdbId: "tt10954562",
|
imdbId: "tt10954562",
|
||||||
tmdbId: "572716",
|
|
||||||
meta: {
|
meta: {
|
||||||
id: "439596",
|
id: "439596",
|
||||||
title: "Hamilton",
|
title: "Hamilton",
|
||||||
@ -15,7 +14,6 @@ export const testData: DetailedMeta[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
imdbId: "tt11126994",
|
imdbId: "tt11126994",
|
||||||
tmdbId: "94605",
|
|
||||||
meta: {
|
meta: {
|
||||||
id: "222333",
|
id: "222333",
|
||||||
title: "Arcane",
|
title: "Arcane",
|
||||||
|
@ -29,8 +29,7 @@ interface JWDetailedMeta extends JWMediaResult {
|
|||||||
|
|
||||||
export interface DetailedMeta {
|
export interface DetailedMeta {
|
||||||
meta: MWMediaMeta;
|
meta: MWMediaMeta;
|
||||||
tmdbId: string;
|
imdbId?: string;
|
||||||
imdbId: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMetaFromId(
|
export async function getMetaFromId(
|
||||||
@ -61,14 +60,6 @@ export async function getMetaFromId(
|
|||||||
if (!imdbId)
|
if (!imdbId)
|
||||||
imdbId = data.external_ids.find((v) => v.provider === "imdb")?.external_id;
|
imdbId = data.external_ids.find((v) => v.provider === "imdb")?.external_id;
|
||||||
|
|
||||||
let tmdbId = data.external_ids.find(
|
|
||||||
(v) => v.provider === "tmdb_latest"
|
|
||||||
)?.external_id;
|
|
||||||
if (!tmdbId)
|
|
||||||
tmdbId = data.external_ids.find((v) => v.provider === "tmdb")?.external_id;
|
|
||||||
|
|
||||||
if (!imdbId || !tmdbId) throw new Error("not enough info");
|
|
||||||
|
|
||||||
let seasonData: JWSeasonMetaResult | undefined;
|
let seasonData: JWSeasonMetaResult | undefined;
|
||||||
if (data.object_type === "show") {
|
if (data.object_type === "show") {
|
||||||
const seasonToScrape = seasonId ?? data.seasons?.[0].id.toString() ?? "";
|
const seasonToScrape = seasonId ?? data.seasons?.[0].id.toString() ?? "";
|
||||||
@ -81,6 +72,5 @@ export async function getMetaFromId(
|
|||||||
return {
|
return {
|
||||||
meta: formatJWMeta(data, seasonData),
|
meta: formatJWMeta(data, seasonData),
|
||||||
imdbId,
|
imdbId,
|
||||||
tmdbId,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ registerProvider({
|
|||||||
type: [MWMediaType.MOVIE],
|
type: [MWMediaType.MOVIE],
|
||||||
|
|
||||||
async scrape({ progress, media: { imdbId } }) {
|
async scrape({ progress, media: { imdbId } }) {
|
||||||
|
if (!imdbId) throw new Error("not enough info");
|
||||||
progress(10);
|
progress(10);
|
||||||
const streamRes = await proxiedFetch<string>(
|
const streamRes = await proxiedFetch<string>(
|
||||||
"https://database.gdriveplayer.us/player.php",
|
"https://database.gdriveplayer.us/player.php",
|
||||||
|
@ -123,6 +123,7 @@ registerProvider({
|
|||||||
type: [MWMediaType.MOVIE, MWMediaType.SERIES],
|
type: [MWMediaType.MOVIE, MWMediaType.SERIES],
|
||||||
async scrape(options) {
|
async scrape(options) {
|
||||||
const { media, progress } = options;
|
const { media, progress } = options;
|
||||||
|
if (!media.imdbId) throw new Error("not enough info");
|
||||||
if (!this.type.includes(media.meta.type)) {
|
if (!this.type.includes(media.meta.type)) {
|
||||||
throw new Error("Unsupported type");
|
throw new Error("Unsupported type");
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ const testData: VideoData = {
|
|||||||
};
|
};
|
||||||
const testMeta: DetailedMeta = {
|
const testMeta: DetailedMeta = {
|
||||||
imdbId: "",
|
imdbId: "",
|
||||||
tmdbId: "",
|
|
||||||
meta: {
|
meta: {
|
||||||
id: "hello-world",
|
id: "hello-world",
|
||||||
title: "Big Buck Bunny",
|
title: "Big Buck Bunny",
|
||||||
|
Loading…
Reference in New Issue
Block a user