mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-13 07:55:06 +01:00
general bug fixing
This commit is contained in:
parent
008c91b0fe
commit
281f6b82a7
@ -63,6 +63,6 @@
|
|||||||
"prettier-plugin-tailwindcss": "^0.1.7",
|
"prettier-plugin-tailwindcss": "^0.1.7",
|
||||||
"tailwind-scrollbar": "^1.3.1",
|
"tailwind-scrollbar": "^1.3.1",
|
||||||
"tailwindcss": "^3.0.20",
|
"tailwindcss": "^3.0.20",
|
||||||
"typescript": "^4.6.2"
|
"typescript": "^4.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import { Icons } from "components/Icon";
|
|||||||
import { Loading } from "components/layout/Loading";
|
import { Loading } from "components/layout/Loading";
|
||||||
import { MWMediaCaption, MWMediaStream } from "providers";
|
import { MWMediaCaption, MWMediaStream } from "providers";
|
||||||
import { ReactElement, useEffect, useRef, useState } from "react";
|
import { ReactElement, useEffect, useRef, useState } from "react";
|
||||||
|
import Hls from "hls.js";
|
||||||
|
|
||||||
export interface VideoPlayerProps {
|
export interface VideoPlayerProps {
|
||||||
source: MWMediaStream;
|
source: MWMediaStream;
|
||||||
@ -40,7 +41,34 @@ export function VideoPlayer(props: VideoPlayerProps) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setErrored(false);
|
setErrored(false);
|
||||||
}, [props.source.url]);
|
|
||||||
|
// hls support
|
||||||
|
if (mustUseHls) {
|
||||||
|
if (!videoRef.current)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!Hls.isSupported()) {
|
||||||
|
setLoading(false);
|
||||||
|
setErrored(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hls = new Hls();
|
||||||
|
|
||||||
|
if (videoRef.current.canPlayType('application/vnd.apple.mpegurl')) {
|
||||||
|
videoRef.current.src = props.source.url;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hls.attachMedia(videoRef.current);
|
||||||
|
hls.loadSource(props.source.url);
|
||||||
|
|
||||||
|
hls.on(Hls.Events.ERROR, (event, data) => {
|
||||||
|
setErrored(true);
|
||||||
|
console.error(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [props.source.url, videoRef, mustUseHls]);
|
||||||
|
|
||||||
let skeletonUi: null | ReactElement = null;
|
let skeletonUi: null | ReactElement = null;
|
||||||
if (hasErrored) {
|
if (hasErrored) {
|
||||||
@ -53,9 +81,8 @@ export function VideoPlayer(props: VideoPlayerProps) {
|
|||||||
<>
|
<>
|
||||||
{skeletonUi}
|
{skeletonUi}
|
||||||
<video
|
<video
|
||||||
className={`bg-denim-500 w-full rounded-xl ${
|
className={`bg-denim-500 w-full rounded-xl ${!showVideo ? "hidden" : ""
|
||||||
!showVideo ? "hidden" : ""
|
}`}
|
||||||
}`}
|
|
||||||
ref={videoRef}
|
ref={videoRef}
|
||||||
onProgress={(e) =>
|
onProgress={(e) =>
|
||||||
props.onProgress && props.onProgress(e.nativeEvent as ProgressEvent)
|
props.onProgress && props.onProgress(e.nativeEvent as ProgressEvent)
|
||||||
|
@ -4,7 +4,6 @@ import {
|
|||||||
MWPortableMedia,
|
MWPortableMedia,
|
||||||
MWMediaStream,
|
MWMediaStream,
|
||||||
MWQuery,
|
MWQuery,
|
||||||
MWMediaSeasons,
|
|
||||||
MWProviderMediaResult
|
MWProviderMediaResult
|
||||||
} from "providers/types";
|
} from "providers/types";
|
||||||
|
|
||||||
@ -57,14 +56,13 @@ export const gDrivePlayerScraper: MWMediaProvider = {
|
|||||||
async searchForMedia(query: MWQuery): Promise<MWProviderMediaResult[]> {
|
async searchForMedia(query: MWQuery): Promise<MWProviderMediaResult[]> {
|
||||||
const searchRes = await fetch(`${CORS_PROXY_URL}https://api.gdriveplayer.us/v1/movie/search?title=${query.searchQuery}`).then((d) => d.json());
|
const searchRes = await fetch(`${CORS_PROXY_URL}https://api.gdriveplayer.us/v1/movie/search?title=${query.searchQuery}`).then((d) => d.json());
|
||||||
|
|
||||||
const results: MWProviderMediaResult[] = searchRes.map((item: any) => ({
|
const results: MWProviderMediaResult[] = (searchRes || []).map((item: any) => ({
|
||||||
title: item.title,
|
title: item.title,
|
||||||
year: item.year,
|
year: item.year,
|
||||||
mediaId: item.imdb,
|
mediaId: item.imdb,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async getStream(media: MWPortableMedia): Promise<MWMediaStream> {
|
async getStream(media: MWPortableMedia): Promise<MWMediaStream> {
|
||||||
@ -89,8 +87,4 @@ export const gDrivePlayerScraper: MWMediaProvider = {
|
|||||||
|
|
||||||
return { url: `https:${source.file}`, type: source.type, captions: [] };
|
return { url: `https:${source.file}`, type: source.type, captions: [] };
|
||||||
},
|
},
|
||||||
|
|
||||||
async getSeasonDataFromMedia(media: MWPortableMedia): Promise<MWMediaSeasons> {
|
|
||||||
return {} as MWMediaSeasons;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,6 @@ import {
|
|||||||
MWPortableMedia,
|
MWPortableMedia,
|
||||||
MWMediaStream,
|
MWMediaStream,
|
||||||
MWQuery,
|
MWQuery,
|
||||||
MWMediaSeasons,
|
|
||||||
MWProviderMediaResult
|
MWProviderMediaResult
|
||||||
} from "providers/types";
|
} from "providers/types";
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ export const gomostreamScraper: MWMediaProvider = {
|
|||||||
`${CORS_PROXY_URL}http://www.omdbapi.com/?${encodeURIComponent(params.toString())}`,
|
`${CORS_PROXY_URL}http://www.omdbapi.com/?${encodeURIComponent(params.toString())}`,
|
||||||
).then(d => d.json())
|
).then(d => d.json())
|
||||||
|
|
||||||
const results: MWProviderMediaResult[] = searchRes.Search.map((d: any) => ({
|
const results: MWProviderMediaResult[] = (searchRes.Search || []).map((d: any) => ({
|
||||||
title: d.Title,
|
title: d.Title,
|
||||||
year: d.Year,
|
year: d.Year,
|
||||||
mediaId: d.imdbID
|
mediaId: d.imdbID
|
||||||
@ -92,9 +91,5 @@ export const gomostreamScraper: MWMediaProvider = {
|
|||||||
if (streamType !== "mp4" && streamType !== "m3u8") throw new Error("Unsupported stream type");
|
if (streamType !== "mp4" && streamType !== "m3u8") throw new Error("Unsupported stream type");
|
||||||
|
|
||||||
return { url: streamUrl, type: streamType, captions: [] };
|
return { url: streamUrl, type: streamType, captions: [] };
|
||||||
},
|
|
||||||
|
|
||||||
async getSeasonDataFromMedia(media: MWPortableMedia): Promise<MWMediaSeasons> {
|
|
||||||
return {} as MWMediaSeasons;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { SimpleCache } from "utils/cache";
|
import { SimpleCache } from "utils/cache";
|
||||||
import { MWPortableMedia } from "providers";
|
import { MWPortableMedia } from "providers";
|
||||||
import { MWMediaSeasons } from "providers/types";
|
import { MWMediaSeasons, MWMediaType, MWMediaProviderSeries } from "providers/types";
|
||||||
import { getProviderFromId } from "./helpers";
|
import { getProviderFromId } from "./helpers";
|
||||||
|
|
||||||
// cache
|
// cache
|
||||||
@ -16,13 +16,19 @@ seasonCache.initialize();
|
|||||||
export async function getSeasonDataFromMedia(
|
export async function getSeasonDataFromMedia(
|
||||||
media: MWPortableMedia
|
media: MWPortableMedia
|
||||||
): Promise<MWMediaSeasons> {
|
): Promise<MWMediaSeasons> {
|
||||||
const provider = getProviderFromId(media.providerId);
|
const provider = getProviderFromId(media.providerId) as MWMediaProviderSeries;
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
return {
|
return {
|
||||||
seasons: [],
|
seasons: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!provider.type.includes(MWMediaType.SERIES) && !provider.type.includes(MWMediaType.ANIME)) {
|
||||||
|
return {
|
||||||
|
seasons: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (seasonCache.has(media)) {
|
if (seasonCache.has(media)) {
|
||||||
return seasonCache.get(media) as MWMediaSeasons;
|
return seasonCache.get(media) as MWMediaSeasons;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ export interface MWQuery {
|
|||||||
type: MWMediaType;
|
type: MWMediaType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MWMediaProvider {
|
export interface MWMediaProviderBase {
|
||||||
id: string; // id of provider, must be unique
|
id: string; // id of provider, must be unique
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
type: MWMediaType[];
|
type: MWMediaType[];
|
||||||
@ -66,9 +66,15 @@ export interface MWMediaProvider {
|
|||||||
getMediaFromPortable(media: MWPortableMedia): Promise<MWProviderMediaResult>;
|
getMediaFromPortable(media: MWPortableMedia): Promise<MWProviderMediaResult>;
|
||||||
searchForMedia(query: MWQuery): Promise<MWProviderMediaResult[]>;
|
searchForMedia(query: MWQuery): Promise<MWProviderMediaResult[]>;
|
||||||
getStream(media: MWPortableMedia): Promise<MWMediaStream>;
|
getStream(media: MWPortableMedia): Promise<MWMediaStream>;
|
||||||
getSeasonDataFromMedia(media: MWPortableMedia): Promise<MWMediaSeasons>;
|
getSeasonDataFromMedia?: (media: MWPortableMedia) => Promise<MWMediaSeasons>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type MWMediaProviderSeries = MWMediaProviderBase & {
|
||||||
|
getSeasonDataFromMedia: (media: MWPortableMedia) => Promise<MWMediaSeasons>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MWMediaProvider = MWMediaProviderBase;
|
||||||
|
|
||||||
export interface MWMediaProviderMetadata {
|
export interface MWMediaProviderMetadata {
|
||||||
exists: boolean;
|
exists: boolean;
|
||||||
id?: string;
|
id?: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user