From 64bbc09e990cde43828077e37e1be877a52c8bb9 Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Sat, 27 Dec 2025 14:05:16 -0700 Subject: [PATCH] remove warning part and treat scraping error as playback error to auto resume --- src/pages/parts/player/ScrapingPart.tsx | 43 ++++++++++++++++++++----- src/pages/parts/util/WarningPart.tsx | 14 -------- 2 files changed, 35 insertions(+), 22 deletions(-) delete mode 100644 src/pages/parts/util/WarningPart.tsx diff --git a/src/pages/parts/player/ScrapingPart.tsx b/src/pages/parts/player/ScrapingPart.tsx index 20df4309..425e2312 100644 --- a/src/pages/parts/player/ScrapingPart.tsx +++ b/src/pages/parts/player/ScrapingPart.tsx @@ -21,8 +21,8 @@ import { useListCenter, useScrape, } from "@/hooks/useProviderScrape"; - -import { WarningPart } from "../util/WarningPart"; +import { playerStatus } from "@/stores/player/slices/source"; +import { usePlayerStore } from "@/stores/player/store"; export interface ScrapingProps { media: ScrapeMedia; @@ -40,10 +40,12 @@ export function ScrapingPart(props: ScrapingProps) { useScrape(); const isMounted = useMountedState(); const { t } = useTranslation(); + const setStatus = usePlayerStore((s) => s.setStatus); + const addFailedSource = usePlayerStore((s) => s.addFailedSource); + const sourceId = usePlayerStore((s) => s.sourceId); const containerRef = useRef(null); const listRef = useRef(null); - const [failedStartScrape, setFailedStartScrape] = useState(false); const renderedOnce = useListCenter( containerRef, listRef, @@ -86,8 +88,36 @@ export function ScrapingPart(props: ScrapingProps) { ), ); props.onGetStream?.(output); - })().catch(() => setFailedStartScrape(true)); - }, [startScraping, resumeScraping, props, report, isMounted]); + })().catch((error) => { + if (!isMounted()) return; + // Treat scraping failure as fatal error + // Mark current source as failed if we have one + if (sourceId) { + addFailedSource(sourceId); + } else if (currentSource) { + addFailedSource(currentSource); + } + // Set error and status to trigger PlaybackErrorPart + usePlayerStore.setState((s) => { + s.interface.error = { + errorName: "ScrapingError", + message: error?.message || "Failed to start scraping", + type: "global", + }; + s.status = playerStatus.PLAYBACK_ERROR; + }); + }); + }, [ + startScraping, + resumeScraping, + props, + report, + isMounted, + setStatus, + addFailedSource, + sourceId, + currentSource, + ]); let currentProviderIndex = sourceOrder.findIndex( (s) => s.id === currentSource || s.children.includes(currentSource ?? ""), @@ -95,9 +125,6 @@ export function ScrapingPart(props: ScrapingProps) { if (currentProviderIndex === -1) currentProviderIndex = sourceOrder.length - 1; - if (failedStartScrape) - return {t("player.scraping.items.failure")}; - return (
- - -
- {props.children} -
-
- ); -}