diff --git a/package.json b/package.json index edf71a662..e91063265 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@types/sortablejs": "^1.15.8", "autoprefixer": "^10.4.21", "eruda": "^3.4.3", - "typescript": "^5.8.3", + "typescript": "^5.9.2", "vite": "^7.0.6", "vite-plugin-pwa": "^1.0.2" }, diff --git a/src/modules/fetchList.ts b/src/modules/fetchList.ts index 541c9712f..8c1d92231 100644 --- a/src/modules/fetchList.ts +++ b/src/modules/fetchList.ts @@ -19,7 +19,6 @@ export default async function fetchList( let listData: StreamItem[] = []; const useHyperpipe = !mix && (store.actionsMenu.author.endsWith(' - Topic') || store.list.name.startsWith('Artist')); - const musicEnforcer = url.includes('OLAK5uy'); if (useHyperpipe) { url = await getPlaylistIdFromArtist(url) || ''; @@ -32,6 +31,7 @@ export default async function fetchList( const api = getApi('piped'); const type = url.includes('channel') ? 'channel' : 'playlist'; + const musicEnforcer = url.includes('OLAK5uy'); const group = await fetch(api + url) .then(res => res.json()) .then(data => { diff --git a/src/modules/getStreamData.ts b/src/modules/getStreamData.ts index 5c5ffa922..25f949be7 100644 --- a/src/modules/getStreamData.ts +++ b/src/modules/getStreamData.ts @@ -10,13 +10,14 @@ export default async function( const fetchDataFromPiped = ( api: string - ) => fetch(`${api}/streams/${id}`) - .then(res => res.json()) - .then(data => { - if (state.HLS ? data.hls : data.audioStreams.length) - return data; - else throw new Error(data.message); - }); + ) => + fetch(`${api}/streams/${id}`) + .then(res => res.json()) + .then(data => { + if (state.HLS ? data.hls : data.audioStreams.length) + return data; + else throw new Error(data.message); + }); const fetchDataFromInvidious = ( api: string @@ -73,7 +74,7 @@ export default async function( else return useInvidious(index + 1); }); - const usePiped = (src = piped, index = 0): Promise => fetchDataFromPiped(src[index]) + const usePiped = (src: string[], index = 0): Promise => fetchDataFromPiped(src[index]) .catch(() => { if (index + 1 === src.length) return useInvidious(); @@ -97,8 +98,20 @@ export default async function( const useLocal = async () => await import('./localExtraction.ts').then(mod => mod.fetchDataFromLocal(id)); + if (location.port === '9999') + return useLocal(); + if (state.HLS) + return useHls(); - return (location.port === '9999') ? useLocal() : state.HLS ? useHls() : status === 'I' ? useInvidious() : status === 'N' ? fetchDataFromPiped(fallback) : usePiped(status === 'U' ? piped : proxy); - + switch (status) { + case 'U': + return usePiped(piped); + case 'P': + return usePiped(proxy); + case 'I': + return useInvidious(); + default: + return emergency(Error('Playback Unsuccesful')); + } } diff --git a/src/modules/start.ts b/src/modules/start.ts index e70f5aaab..b8ca125f9 100644 --- a/src/modules/start.ts +++ b/src/modules/start.ts @@ -25,9 +25,9 @@ export default async function() { .then(res => res.json()) .then(data => { document.querySelector('samp')!.textContent = { - U: "⬛⬛⬛⬛", P: "⬛⬛⬛⬜", I: "🟧⬛⬛⬜⬜", N: "⬛⬜⬜⬜" + U: "⬛⬛⬛⬛", P: "⬛⬛⬛⬜", I: "⬛⬛⬜⬜", N: "⬛⬜⬜⬜" }[data.health as 'U']; - + store.api.status = data.health; store.api.piped = data.piped; store.api.proxy = data.proxy; store.api.invidious = data.invidious;