mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-28 03:11:51 +01:00
Fix for flixHQ provider
This commit is contained in:
parent
f2ea05708f
commit
436a2388b9
@ -8,10 +8,7 @@ import {
|
|||||||
} from "../helpers/streams";
|
} from "../helpers/streams";
|
||||||
import { MWMediaType } from "../metadata/types";
|
import { MWMediaType } from "../metadata/types";
|
||||||
|
|
||||||
// const flixHqBase = "https://api.consumet.org/movies/flixhq";
|
const flixHqBase = "https://api.consumet.org/meta/tmdb";
|
||||||
// *** TEMPORARY FIX - use other instance
|
|
||||||
// SEE ISSUE: https://github.com/consumet/api.consumet.org/issues/326
|
|
||||||
const flixHqBase = "https://c.delusionz.xyz/movies/flixhq";
|
|
||||||
|
|
||||||
interface FLIXMediaBase {
|
interface FLIXMediaBase {
|
||||||
id: number;
|
id: number;
|
||||||
@ -19,13 +16,6 @@ interface FLIXMediaBase {
|
|||||||
url: string;
|
url: string;
|
||||||
image: string;
|
image: string;
|
||||||
type: "Movie" | "TV Series";
|
type: "Movie" | "TV Series";
|
||||||
}
|
|
||||||
|
|
||||||
interface FLIXTVSerie extends FLIXMediaBase {
|
|
||||||
seasons: number | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FLIXMovie extends FLIXMediaBase {
|
|
||||||
releaseDate: string;
|
releaseDate: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +38,11 @@ const qualityMap: Record<string, MWStreamQuality> = {
|
|||||||
"1080": MWStreamQuality.Q1080P,
|
"1080": MWStreamQuality.Q1080P,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum FlixHQMediaType {
|
||||||
|
MOVIE = "movie",
|
||||||
|
SERIES = "series",
|
||||||
|
}
|
||||||
|
|
||||||
registerProvider({
|
registerProvider({
|
||||||
id: "flixhq",
|
id: "flixhq",
|
||||||
displayName: "FlixHQ",
|
displayName: "FlixHQ",
|
||||||
@ -67,60 +62,47 @@ registerProvider({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const foundItem = searchResults.results.find((v: FLIXMediaBase) => {
|
const foundItem = searchResults.results.find((v: FLIXMediaBase) => {
|
||||||
if (media.meta.type === MWMediaType.MOVIE) {
|
if (v.type !== "Movie" && v.type !== "TV Series") return false;
|
||||||
if (v.type !== "Movie") return false;
|
return (
|
||||||
const movie = v as FLIXMovie;
|
compareTitle(v.title, media.meta.title) &&
|
||||||
return (
|
v.releaseDate === media.meta.year
|
||||||
compareTitle(movie.title, media.meta.title) &&
|
);
|
||||||
movie.releaseDate === media.meta.year
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (media.meta.type === MWMediaType.SERIES) {
|
|
||||||
if (v.type !== "TV Series") return false;
|
|
||||||
const serie = v as FLIXTVSerie;
|
|
||||||
if (serie.seasons && media.meta.seasons) {
|
|
||||||
return (
|
|
||||||
compareTitle(serie.title, media.meta.title) &&
|
|
||||||
serie.seasons === media.meta.seasons.length
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
if (!foundItem) throw new Error("No watchable item found");
|
if (!foundItem) throw new Error("No watchable item found");
|
||||||
const flixId = foundItem.id;
|
|
||||||
|
|
||||||
// get media info
|
// get media info
|
||||||
progress(25);
|
progress(25);
|
||||||
const mediaInfo = await proxiedFetch<any>("/info", {
|
const mediaInfo = await proxiedFetch<any>(`/info/${foundItem.id}`, {
|
||||||
baseURL: flixHqBase,
|
baseURL: flixHqBase,
|
||||||
params: {
|
params: {
|
||||||
id: flixId,
|
type:
|
||||||
|
media.meta.type === MWMediaType.MOVIE
|
||||||
|
? FlixHQMediaType.MOVIE
|
||||||
|
: FlixHQMediaType.SERIES,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!mediaInfo.episodes) throw new Error("No watchable item found");
|
if (!mediaInfo.id) throw new Error("No watchable item found");
|
||||||
// get stream info from media
|
// get stream info from media
|
||||||
progress(75);
|
progress(75);
|
||||||
|
|
||||||
// By default we assume it is a movie
|
let episodeId: string | undefined;
|
||||||
let episodeId: string | undefined = mediaInfo.episodes[0].id;
|
if (media.meta.type === MWMediaType.MOVIE) {
|
||||||
if (media.meta.type === MWMediaType.SERIES) {
|
episodeId = mediaInfo.episodeId;
|
||||||
|
} else if (media.meta.type === MWMediaType.SERIES) {
|
||||||
const seasonNo = media.meta.seasonData.number;
|
const seasonNo = media.meta.seasonData.number;
|
||||||
const episodeNo = media.meta.seasonData.episodes.find(
|
const episodeNo = media.meta.seasonData.episodes.find(
|
||||||
(e) => e.id === episode
|
(e) => e.id === episode
|
||||||
)?.number;
|
)?.number;
|
||||||
episodeId = mediaInfo.episodes.find(
|
|
||||||
(e: any) => e.season === seasonNo && e.number === episodeNo
|
const season = mediaInfo.seasons.find((o: any) => o.season === seasonNo);
|
||||||
)?.id;
|
episodeId = season.episodes.find((o: any) => o.episode === episodeNo).id;
|
||||||
}
|
}
|
||||||
if (!episodeId) throw new Error("No watchable item found");
|
if (!episodeId) throw new Error("No watchable item found");
|
||||||
|
|
||||||
const watchInfo = await proxiedFetch<any>("/watch", {
|
const watchInfo = await proxiedFetch<any>(`/watch/${episodeId}`, {
|
||||||
baseURL: flixHqBase,
|
baseURL: flixHqBase,
|
||||||
params: {
|
params: {
|
||||||
episodeId,
|
id: mediaInfo.id,
|
||||||
mediaId: flixId,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user