mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-19 10:32:05 +00:00
bug fix the last successful source feature
This commit is contained in:
parent
d575d71108
commit
0c192d2582
3 changed files with 47 additions and 3 deletions
|
|
@ -1110,7 +1110,7 @@
|
|||
"manualSourceLabel": "Manual source selection",
|
||||
"lastSuccessfulSource": "Last successful source",
|
||||
"lastSuccessfulSourceDescription": "Automatically prioritize the source that successfully provided content for the previous episode. This helps ensure continuity when watching series.",
|
||||
"lastSuccessfulSourceEnableLabel": "Enable last successful source"
|
||||
"lastSuccessfulSourceEnableLabel": "Last successful source"
|
||||
},
|
||||
"reset": "Reset",
|
||||
"save": "Save",
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import { convertRunoutputToSource } from "@/components/player/utils/convertRunou
|
|||
import { useOverlayRouter } from "@/hooks/useOverlayRouter";
|
||||
import { metaToScrapeMedia } from "@/stores/player/slices/source";
|
||||
import { usePlayerStore } from "@/stores/player/store";
|
||||
import { usePreferencesStore } from "@/stores/preferences";
|
||||
|
||||
export function useEmbedScraping(
|
||||
routerId: string,
|
||||
|
|
@ -37,6 +38,12 @@ export function useEmbedScraping(
|
|||
const meta = usePlayerStore((s) => s.meta);
|
||||
const router = useOverlayRouter(routerId);
|
||||
const { report } = useReportProviders();
|
||||
const setLastSuccessfulSource = usePreferencesStore(
|
||||
(s) => s.setLastSuccessfulSource,
|
||||
);
|
||||
const enableLastSuccessfulSource = usePreferencesStore(
|
||||
(s) => s.enableLastSuccessfulSource,
|
||||
);
|
||||
|
||||
const [request, run] = useAsyncFn(async () => {
|
||||
const providerApiUrl = getLoadbalancedProviderApiUrl();
|
||||
|
|
@ -83,8 +90,21 @@ export function useEmbedScraping(
|
|||
convertProviderCaption(result.stream[0].captions),
|
||||
progress,
|
||||
);
|
||||
// Save the last successful source when manually selected
|
||||
if (enableLastSuccessfulSource) {
|
||||
setLastSuccessfulSource(sourceId);
|
||||
}
|
||||
router.close();
|
||||
}, [embedId, sourceId, meta, router, report, setCaption]);
|
||||
}, [
|
||||
embedId,
|
||||
sourceId,
|
||||
meta,
|
||||
router,
|
||||
report,
|
||||
setCaption,
|
||||
enableLastSuccessfulSource,
|
||||
setLastSuccessfulSource,
|
||||
]);
|
||||
|
||||
return {
|
||||
run,
|
||||
|
|
@ -102,6 +122,12 @@ export function useSourceScraping(sourceId: string | null, routerId: string) {
|
|||
const progress = usePlayerStore((s) => s.progress.time);
|
||||
const router = useOverlayRouter(routerId);
|
||||
const { report } = useReportProviders();
|
||||
const setLastSuccessfulSource = usePreferencesStore(
|
||||
(s) => s.setLastSuccessfulSource,
|
||||
);
|
||||
const enableLastSuccessfulSource = usePreferencesStore(
|
||||
(s) => s.enableLastSuccessfulSource,
|
||||
);
|
||||
|
||||
const [request, run] = useAsyncFn(async () => {
|
||||
if (!sourceId || !meta) return null;
|
||||
|
|
@ -147,6 +173,10 @@ export function useSourceScraping(sourceId: string | null, routerId: string) {
|
|||
progress,
|
||||
);
|
||||
setSourceId(sourceId);
|
||||
// Save the last successful source when manually selected
|
||||
if (enableLastSuccessfulSource) {
|
||||
setLastSuccessfulSource(sourceId);
|
||||
}
|
||||
router.close();
|
||||
return null;
|
||||
}
|
||||
|
|
@ -203,10 +233,21 @@ export function useSourceScraping(sourceId: string | null, routerId: string) {
|
|||
convertProviderCaption(embedResult.stream[0].captions),
|
||||
progress,
|
||||
);
|
||||
// Save the last successful source when manually selected
|
||||
if (enableLastSuccessfulSource) {
|
||||
setLastSuccessfulSource(sourceId);
|
||||
}
|
||||
router.close();
|
||||
}
|
||||
return result.embeds;
|
||||
}, [sourceId, meta, router, setCaption]);
|
||||
}, [
|
||||
sourceId,
|
||||
meta,
|
||||
router,
|
||||
setCaption,
|
||||
enableLastSuccessfulSource,
|
||||
setLastSuccessfulSource,
|
||||
]);
|
||||
|
||||
return {
|
||||
run,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { DisplayInterface } from "@/components/player/display/displayInterface";
|
||||
import { playerStatus } from "@/stores/player/slices/source";
|
||||
import { MakeSlice } from "@/stores/player/slices/types";
|
||||
import { usePreferencesStore } from "@/stores/preferences";
|
||||
|
||||
export interface DisplaySlice {
|
||||
display: DisplayInterface | null;
|
||||
|
|
@ -105,6 +106,8 @@ export const createDisplaySlice: MakeSlice<DisplaySlice> = (set, get) => ({
|
|||
s.status = playerStatus.PLAYBACK_ERROR;
|
||||
s.interface.error = err;
|
||||
});
|
||||
// Reset last successful source on playback error
|
||||
usePreferencesStore.getState().setLastSuccessfulSource(null);
|
||||
});
|
||||
|
||||
set((s) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue