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.

bug fix the last successful source feature

Pas 0c192d25 d575d711

+47 -3
+1 -1
src/assets/locales/en.json
··· 1110 1110 "manualSourceLabel": "Manual source selection", 1111 1111 "lastSuccessfulSource": "Last successful source", 1112 1112 "lastSuccessfulSourceDescription": "Automatically prioritize the source that successfully provided content for the previous episode. This helps ensure continuity when watching series.", 1113 - "lastSuccessfulSourceEnableLabel": "Enable last successful source" 1113 + "lastSuccessfulSourceEnableLabel": "Last successful source" 1114 1114 }, 1115 1115 "reset": "Reset", 1116 1116 "save": "Save",
+43 -2
src/components/player/hooks/useSourceSelection.ts
··· 22 22 import { useOverlayRouter } from "@/hooks/useOverlayRouter"; 23 23 import { metaToScrapeMedia } from "@/stores/player/slices/source"; 24 24 import { usePlayerStore } from "@/stores/player/store"; 25 + import { usePreferencesStore } from "@/stores/preferences"; 25 26 26 27 export function useEmbedScraping( 27 28 routerId: string, ··· 37 38 const meta = usePlayerStore((s) => s.meta); 38 39 const router = useOverlayRouter(routerId); 39 40 const { report } = useReportProviders(); 41 + const setLastSuccessfulSource = usePreferencesStore( 42 + (s) => s.setLastSuccessfulSource, 43 + ); 44 + const enableLastSuccessfulSource = usePreferencesStore( 45 + (s) => s.enableLastSuccessfulSource, 46 + ); 40 47 41 48 const [request, run] = useAsyncFn(async () => { 42 49 const providerApiUrl = getLoadbalancedProviderApiUrl(); ··· 83 90 convertProviderCaption(result.stream[0].captions), 84 91 progress, 85 92 ); 93 + // Save the last successful source when manually selected 94 + if (enableLastSuccessfulSource) { 95 + setLastSuccessfulSource(sourceId); 96 + } 86 97 router.close(); 87 - }, [embedId, sourceId, meta, router, report, setCaption]); 98 + }, [ 99 + embedId, 100 + sourceId, 101 + meta, 102 + router, 103 + report, 104 + setCaption, 105 + enableLastSuccessfulSource, 106 + setLastSuccessfulSource, 107 + ]); 88 108 89 109 return { 90 110 run, ··· 102 122 const progress = usePlayerStore((s) => s.progress.time); 103 123 const router = useOverlayRouter(routerId); 104 124 const { report } = useReportProviders(); 125 + const setLastSuccessfulSource = usePreferencesStore( 126 + (s) => s.setLastSuccessfulSource, 127 + ); 128 + const enableLastSuccessfulSource = usePreferencesStore( 129 + (s) => s.enableLastSuccessfulSource, 130 + ); 105 131 106 132 const [request, run] = useAsyncFn(async () => { 107 133 if (!sourceId || !meta) return null; ··· 147 173 progress, 148 174 ); 149 175 setSourceId(sourceId); 176 + // Save the last successful source when manually selected 177 + if (enableLastSuccessfulSource) { 178 + setLastSuccessfulSource(sourceId); 179 + } 150 180 router.close(); 151 181 return null; 152 182 } ··· 203 233 convertProviderCaption(embedResult.stream[0].captions), 204 234 progress, 205 235 ); 236 + // Save the last successful source when manually selected 237 + if (enableLastSuccessfulSource) { 238 + setLastSuccessfulSource(sourceId); 239 + } 206 240 router.close(); 207 241 } 208 242 return result.embeds; 209 - }, [sourceId, meta, router, setCaption]); 243 + }, [ 244 + sourceId, 245 + meta, 246 + router, 247 + setCaption, 248 + enableLastSuccessfulSource, 249 + setLastSuccessfulSource, 250 + ]); 210 251 211 252 return { 212 253 run,
+3
src/stores/player/slices/display.ts
··· 1 1 import { DisplayInterface } from "@/components/player/display/displayInterface"; 2 2 import { playerStatus } from "@/stores/player/slices/source"; 3 3 import { MakeSlice } from "@/stores/player/slices/types"; 4 + import { usePreferencesStore } from "@/stores/preferences"; 4 5 5 6 export interface DisplaySlice { 6 7 display: DisplayInterface | null; ··· 105 106 s.status = playerStatus.PLAYBACK_ERROR; 106 107 s.interface.error = err; 107 108 }); 109 + // Reset last successful source on playback error 110 + usePreferencesStore.getState().setLastSuccessfulSource(null); 108 111 }); 109 112 110 113 set((s) => {