mirror of
https://github.com/movie-web/movie-web.git
synced 2025-01-15 23:39:12 +01:00
Fix some thumbnail scraping setting logic
Co-authored-by: Jip Frijlink <JipFr@users.noreply.github.com>
This commit is contained in:
parent
dc95bd7455
commit
b3222b130f
@ -11,7 +11,6 @@ import { VideoClickTarget } from "@/components/player/internals/VideoClickTarget
|
|||||||
import { VideoContainer } from "@/components/player/internals/VideoContainer";
|
import { VideoContainer } from "@/components/player/internals/VideoContainer";
|
||||||
import { PlayerHoverState } from "@/stores/player/slices/interface";
|
import { PlayerHoverState } from "@/stores/player/slices/interface";
|
||||||
import { usePlayerStore } from "@/stores/player/store";
|
import { usePlayerStore } from "@/stores/player/store";
|
||||||
import { usePreferencesStore } from "@/stores/preferences";
|
|
||||||
|
|
||||||
export interface PlayerProps {
|
export interface PlayerProps {
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
@ -79,7 +78,6 @@ function BaseContainer(props: { children?: ReactNode }) {
|
|||||||
|
|
||||||
export function Container(props: PlayerProps) {
|
export function Container(props: PlayerProps) {
|
||||||
const propRef = useRef(props.onLoad);
|
const propRef = useRef(props.onLoad);
|
||||||
const enableThumbnails = usePreferencesStore((s) => s.enableThumbnails);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
propRef.current?.();
|
propRef.current?.();
|
||||||
}, []);
|
}, []);
|
||||||
@ -88,7 +86,7 @@ export function Container(props: PlayerProps) {
|
|||||||
<div className="relative">
|
<div className="relative">
|
||||||
<BaseContainer>
|
<BaseContainer>
|
||||||
<MetaReporter />
|
<MetaReporter />
|
||||||
{enableThumbnails ? <ThumbnailScraper /> : null}
|
<ThumbnailScraper />
|
||||||
<CastingInternal />
|
<CastingInternal />
|
||||||
<VideoContainer />
|
<VideoContainer />
|
||||||
<ProgressSaver />
|
<ProgressSaver />
|
||||||
|
@ -5,6 +5,7 @@ import {
|
|||||||
} from "@movie-web/providers";
|
} from "@movie-web/providers";
|
||||||
import { useAsyncFn } from "react-use";
|
import { useAsyncFn } from "react-use";
|
||||||
|
|
||||||
|
import { isExtensionActiveCached } from "@/backend/extension/messaging";
|
||||||
import { prepareStream } from "@/backend/extension/streams";
|
import { prepareStream } from "@/backend/extension/streams";
|
||||||
import {
|
import {
|
||||||
connectServerSideEvents,
|
connectServerSideEvents,
|
||||||
@ -72,7 +73,7 @@ export function useEmbedScraping(
|
|||||||
report([
|
report([
|
||||||
scrapeSourceOutputToProviderMetric(meta, sourceId, null, "success", null),
|
scrapeSourceOutputToProviderMetric(meta, sourceId, null, "success", null),
|
||||||
]);
|
]);
|
||||||
await prepareStream(result.stream[0]);
|
if (isExtensionActiveCached()) await prepareStream(result.stream[0]);
|
||||||
setSourceId(sourceId);
|
setSourceId(sourceId);
|
||||||
setCaption(null);
|
setCaption(null);
|
||||||
setSource(
|
setSource(
|
||||||
@ -133,7 +134,7 @@ export function useSourceScraping(sourceId: string | null, routerId: string) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (result.stream) {
|
if (result.stream) {
|
||||||
await prepareStream(result.stream[0]);
|
if (isExtensionActiveCached()) await prepareStream(result.stream[0]);
|
||||||
setCaption(null);
|
setCaption(null);
|
||||||
setSource(
|
setSource(
|
||||||
convertRunoutputToSource({ stream: result.stream[0] }),
|
convertRunoutputToSource({ stream: result.stream[0] }),
|
||||||
@ -190,7 +191,7 @@ export function useSourceScraping(sourceId: string | null, routerId: string) {
|
|||||||
]);
|
]);
|
||||||
setSourceId(sourceId);
|
setSourceId(sourceId);
|
||||||
setCaption(null);
|
setCaption(null);
|
||||||
await prepareStream(embedResult.stream[0]);
|
if (isExtensionActiveCached()) await prepareStream(embedResult.stream[0]);
|
||||||
setSource(
|
setSource(
|
||||||
convertRunoutputToSource({ stream: embedResult.stream[0] }),
|
convertRunoutputToSource({ stream: embedResult.stream[0] }),
|
||||||
convertProviderCaption(embedResult.stream[0].captions),
|
convertProviderCaption(embedResult.stream[0].captions),
|
||||||
|
@ -5,6 +5,7 @@ import { playerStatus } from "@/stores/player/slices/source";
|
|||||||
import { ThumbnailImage } from "@/stores/player/slices/thumbnails";
|
import { ThumbnailImage } from "@/stores/player/slices/thumbnails";
|
||||||
import { usePlayerStore } from "@/stores/player/store";
|
import { usePlayerStore } from "@/stores/player/store";
|
||||||
import { LoadableSource, selectQuality } from "@/stores/player/utils/qualities";
|
import { LoadableSource, selectQuality } from "@/stores/player/utils/qualities";
|
||||||
|
import { usePreferencesStore } from "@/stores/preferences";
|
||||||
import { processCdnLink } from "@/utils/cdn";
|
import { processCdnLink } from "@/utils/cdn";
|
||||||
import { isSafari } from "@/utils/detectFeatures";
|
import { isSafari } from "@/utils/detectFeatures";
|
||||||
|
|
||||||
@ -128,6 +129,7 @@ export function ThumbnailScraper() {
|
|||||||
const resetImages = usePlayerStore((s) => s.thumbnails.resetImages);
|
const resetImages = usePlayerStore((s) => s.thumbnails.resetImages);
|
||||||
const meta = usePlayerStore((s) => s.meta);
|
const meta = usePlayerStore((s) => s.meta);
|
||||||
const source = usePlayerStore((s) => s.source);
|
const source = usePlayerStore((s) => s.source);
|
||||||
|
const enableThumbnails = usePreferencesStore((s) => s.enableThumbnails);
|
||||||
const workerRef = useRef<ThumnbnailWorker | null>(null);
|
const workerRef = useRef<ThumnbnailWorker | null>(null);
|
||||||
|
|
||||||
// object references dont always trigger changes, so we serialize it to detect *any* change
|
// object references dont always trigger changes, so we serialize it to detect *any* change
|
||||||
@ -159,8 +161,8 @@ export function ThumbnailScraper() {
|
|||||||
|
|
||||||
// start worker with the stream
|
// start worker with the stream
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
startRef.current();
|
if (enableThumbnails) startRef.current();
|
||||||
}, [sourceSeralized]);
|
}, [sourceSeralized, enableThumbnails]);
|
||||||
|
|
||||||
// destroy worker on unmount
|
// destroy worker on unmount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -183,8 +185,8 @@ export function ThumbnailScraper() {
|
|||||||
workerRef.current.destroy();
|
workerRef.current.destroy();
|
||||||
workerRef.current = null;
|
workerRef.current = null;
|
||||||
}
|
}
|
||||||
startRef.current();
|
if (enableThumbnails) startRef.current();
|
||||||
}, [serializedMeta, sourceSeralized, status]);
|
}, [serializedMeta, sourceSeralized, status, enableThumbnails]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,8 @@ export function useScrape() {
|
|||||||
conn.on("update", updateEvent);
|
conn.on("update", updateEvent);
|
||||||
conn.on("discoverEmbeds", discoverEmbedsEvent);
|
conn.on("discoverEmbeds", discoverEmbedsEvent);
|
||||||
const sseOutput = await conn.promise();
|
const sseOutput = await conn.promise();
|
||||||
if (sseOutput) await prepareStream(sseOutput.stream);
|
if (sseOutput && isExtensionActiveCached())
|
||||||
|
await prepareStream(sseOutput.stream);
|
||||||
|
|
||||||
return getResult(sseOutput === "" ? null : sseOutput);
|
return getResult(sseOutput === "" ? null : sseOutput);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user