pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

remove warning part and treat scraping error as playback error to auto resume

Pas 64bbc09e ecd5daea

+35 -22
+35 -8
src/pages/parts/player/ScrapingPart.tsx
··· 21 21 useListCenter, 22 22 useScrape, 23 23 } from "@/hooks/useProviderScrape"; 24 - 25 - import { WarningPart } from "../util/WarningPart"; 24 + import { playerStatus } from "@/stores/player/slices/source"; 25 + import { usePlayerStore } from "@/stores/player/store"; 26 26 27 27 export interface ScrapingProps { 28 28 media: ScrapeMedia; ··· 40 40 useScrape(); 41 41 const isMounted = useMountedState(); 42 42 const { t } = useTranslation(); 43 + const setStatus = usePlayerStore((s) => s.setStatus); 44 + const addFailedSource = usePlayerStore((s) => s.addFailedSource); 45 + const sourceId = usePlayerStore((s) => s.sourceId); 43 46 44 47 const containerRef = useRef<HTMLDivElement | null>(null); 45 48 const listRef = useRef<HTMLDivElement | null>(null); 46 - const [failedStartScrape, setFailedStartScrape] = useState<boolean>(false); 47 49 const renderedOnce = useListCenter( 48 50 containerRef, 49 51 listRef, ··· 86 88 ), 87 89 ); 88 90 props.onGetStream?.(output); 89 - })().catch(() => setFailedStartScrape(true)); 90 - }, [startScraping, resumeScraping, props, report, isMounted]); 91 + })().catch((error) => { 92 + if (!isMounted()) return; 93 + // Treat scraping failure as fatal error 94 + // Mark current source as failed if we have one 95 + if (sourceId) { 96 + addFailedSource(sourceId); 97 + } else if (currentSource) { 98 + addFailedSource(currentSource); 99 + } 100 + // Set error and status to trigger PlaybackErrorPart 101 + usePlayerStore.setState((s) => { 102 + s.interface.error = { 103 + errorName: "ScrapingError", 104 + message: error?.message || "Failed to start scraping", 105 + type: "global", 106 + }; 107 + s.status = playerStatus.PLAYBACK_ERROR; 108 + }); 109 + }); 110 + }, [ 111 + startScraping, 112 + resumeScraping, 113 + props, 114 + report, 115 + isMounted, 116 + setStatus, 117 + addFailedSource, 118 + sourceId, 119 + currentSource, 120 + ]); 91 121 92 122 let currentProviderIndex = sourceOrder.findIndex( 93 123 (s) => s.id === currentSource || s.children.includes(currentSource ?? ""), 94 124 ); 95 125 if (currentProviderIndex === -1) 96 126 currentProviderIndex = sourceOrder.length - 1; 97 - 98 - if (failedStartScrape) 99 - return <WarningPart>{t("player.scraping.items.failure")}</WarningPart>; 100 127 101 128 return ( 102 129 <div
-14
src/pages/parts/util/WarningPart.tsx
··· 1 - import { Icon, Icons } from "@/components/Icon"; 2 - import { BlurEllipsis } from "@/pages/layouts/SubPageLayout"; 3 - 4 - export function WarningPart(props: { children: React.ReactNode }) { 5 - return ( 6 - <div className="flex flex-col justify-center items-center h-screen text-center font-medium"> 7 - <BlurEllipsis /> 8 - <Icon className="text-type-danger text-2xl" icon={Icons.WARNING} /> 9 - <div className="max-w-[19rem] mt-3 mb-12 text-type-secondary"> 10 - {props.children} 11 - </div> 12 - </div> 13 - ); 14 - }