Merge branch 'dev' into dev

This commit is contained in:
mrjvs 2023-03-31 00:55:05 +02:00 committed by GitHub
commit 3a44eb550d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 15 deletions

View File

@ -10,12 +10,13 @@ import { MWMediaType } from "../metadata/types";
const flixHqBase = "https://api.consumet.org/meta/tmdb"; const flixHqBase = "https://api.consumet.org/meta/tmdb";
type FlixHQMediaType = "Movie" | "TV Series";
interface FLIXMediaBase { interface FLIXMediaBase {
id: number; id: number;
title: string; title: string;
url: string; url: string;
image: string; image: string;
type: "Movie" | "TV Series"; type: FlixHQMediaType;
releaseDate: string; releaseDate: string;
} }
@ -38,9 +39,9 @@ const qualityMap: Record<string, MWStreamQuality> = {
"1080": MWStreamQuality.Q1080P, "1080": MWStreamQuality.Q1080P,
}; };
enum FlixHQMediaType { function flixTypeToMWType(type: FlixHQMediaType) {
MOVIE = "movie", if (type === "Movie") return MWMediaType.MOVIE;
SERIES = "series", return MWMediaType.SERIES;
} }
registerProvider({ registerProvider({
@ -48,7 +49,6 @@ registerProvider({
displayName: "FlixHQ", displayName: "FlixHQ",
rank: 100, rank: 100,
type: [MWMediaType.MOVIE, MWMediaType.SERIES], type: [MWMediaType.MOVIE, MWMediaType.SERIES],
async scrape({ media, episode, progress }) { async scrape({ media, episode, progress }) {
if (!this.type.includes(media.meta.type)) { if (!this.type.includes(media.meta.type)) {
throw new Error("Unsupported type"); throw new Error("Unsupported type");
@ -65,9 +65,11 @@ registerProvider({
if (v.type !== "Movie" && v.type !== "TV Series") return false; if (v.type !== "Movie" && v.type !== "TV Series") return false;
return ( return (
compareTitle(v.title, media.meta.title) && compareTitle(v.title, media.meta.title) &&
flixTypeToMWType(v.type) === media.meta.type &&
v.releaseDate === media.meta.year v.releaseDate === media.meta.year
); );
}); });
if (!foundItem) throw new Error("No watchable item found"); if (!foundItem) throw new Error("No watchable item found");
// get media info // get media info
@ -75,15 +77,12 @@ registerProvider({
const mediaInfo = await proxiedFetch<any>(`/info/${foundItem.id}`, { const mediaInfo = await proxiedFetch<any>(`/info/${foundItem.id}`, {
baseURL: flixHqBase, baseURL: flixHqBase,
params: { params: {
type: type: flixTypeToMWType(foundItem.type),
media.meta.type === MWMediaType.MOVIE
? FlixHQMediaType.MOVIE
: FlixHQMediaType.SERIES,
}, },
}); });
if (!mediaInfo.id) 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(50);
let episodeId: string | undefined; let episodeId: string | undefined;
if (media.meta.type === MWMediaType.MOVIE) { if (media.meta.type === MWMediaType.MOVIE) {
@ -98,7 +97,7 @@ registerProvider({
episodeId = season.episodes.find((o: any) => o.episode === episodeNo).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");
progress(75);
const watchInfo = await proxiedFetch<any>(`/watch/${episodeId}`, { const watchInfo = await proxiedFetch<any>(`/watch/${episodeId}`, {
baseURL: flixHqBase, baseURL: flixHqBase,
params: { params: {

View File

@ -6,7 +6,7 @@ function getInitialValue(params: { type: string; query: string }) {
const type = const type =
Object.values(MWMediaType).find((v) => params.type === v) || Object.values(MWMediaType).find((v) => params.type === v) ||
MWMediaType.MOVIE; MWMediaType.MOVIE;
const searchQuery = params.query || ""; const searchQuery = decodeURIComponent(params.query || "");
return { type, searchQuery }; return { type, searchQuery };
} }

View File

@ -277,7 +277,9 @@ export function createVideoStateProvider(
updateMediaPlaying(descriptor, state); updateMediaPlaying(descriptor, state);
}; };
const fullscreenchange = () => { const fullscreenchange = () => {
state.interface.isFullscreen = !!document.fullscreenElement; state.interface.isFullscreen =
!!document.fullscreenElement || // other browsers
!!(document as any).webkitFullscreenElement; // safari
updateInterface(descriptor, state); updateInterface(descriptor, state);
}; };
const volumechange = async () => { const volumechange = async () => {

View File

@ -64,8 +64,8 @@ export function VideoTesterView() {
/> />
<SourceController <SourceController
source={video.streamUrl} source={video.streamUrl}
type={MWStreamType.MP4} type={videoType}
quality={MWStreamQuality.Q720P} quality={MWStreamQuality.QUNKNOWN}
/> />
</VideoPlayer> </VideoPlayer>
</div> </div>