diff --git a/package.json b/package.json index 9dba5413..a5aa09bd 100644 --- a/package.json +++ b/package.json @@ -12,18 +12,18 @@ "hls.js": "^1.5.17", "imsc": "^1.1.5", "solid-js": "^1.9.3", - "sortablejs": "^1.15.3" + "sortablejs": "^1.15.6" }, "devDependencies": { "@netlify/edge-functions": "^2.11.1", - "@types/node": "^22.9.3", + "@types/node": "^22.10.1", "@types/sortablejs": "^1.15.8", "autoprefixer": "^10.4.20", "eruda": "^3.4.1", "typescript": "^5.7.2", - "vite": "^5.4.11", - "vite-plugin-pwa": "^0.21.0", - "vite-plugin-solid": "^2.10.2" + "vite": "^6.0.2", + "vite-plugin-pwa": "^0.21.1", + "vite-plugin-solid": "^2.11.0" }, "browserslist": [ "defaults" diff --git a/src/lib/store.ts b/src/lib/store.ts index 81bb5e1e..c2295a6b 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -13,6 +13,7 @@ export const store: { supportsOpus: Promise, data: Piped | undefined, legacy: boolean, + fallback: string, proxy: string }, queue: string[] @@ -48,6 +49,7 @@ export const store: { }).then(res => res.supported), data: undefined, legacy: !('OffscreenCanvas' in window), + fallback: '', proxy: '' }, queue: [], diff --git a/src/modules/getStreamData.ts b/src/modules/getStreamData.ts index bc4655ea..832773c7 100644 --- a/src/modules/getStreamData.ts +++ b/src/modules/getStreamData.ts @@ -69,14 +69,17 @@ export async function getData( const pi = store.api.piped; const res = await Promise.any( - pi.map(fetchDataFromPiped) + pi + .filter((_, i) => i < (h ? pi.length : store.api.unified)) + .map(fetchDataFromPiped) ) .catch(() => h ? {} : Promise.any( iv.map(fetchDataFromInvidious) ) .catch(() => { - if (!prefetch) - return fetchDataFromPiped('https://video-api-transform.vercel.app/api'); + if (!prefetch && store.player.fallback) + return fetchDataFromPiped(store.player.fallback) + .catch(() => getData(id)) }) ); diff --git a/src/modules/setAudioStreams.ts b/src/modules/setAudioStreams.ts index 954a0cce..3734ffac 100644 --- a/src/modules/setAudioStreams.ts +++ b/src/modules/setAudioStreams.ts @@ -28,15 +28,21 @@ export function setAudioStreams(audioStreams: { } function proxyHandler(url: string) { - const useProxy = url.startsWith('https://ymd') || isMusic || getSaved('enforceProxy'); + const useProxy = isMusic || getSaved('enforceProxy'); const oldUrl = new URL(url); const origin = oldUrl.origin; + if (url.startsWith('https://ymd')) + return url; + if (url.startsWith('https://redirector')) return url.replace(origin, store.player.proxy) + '&host=' + origin.slice(8); - return useProxy ? url : url.replace(origin, `https://${oldUrl.searchParams.get('host')}`); + return url.replace(origin, + useProxy ? + store.api.invidious[store.api.index] : `https://${oldUrl.searchParams.get('host')}` + ); } diff --git a/src/modules/start.ts b/src/modules/start.ts index 3ad0a94d..cb707b71 100644 --- a/src/modules/start.ts +++ b/src/modules/start.ts @@ -17,8 +17,13 @@ export default async function() { a.invidious.push(iv); } else { - const apiUrl = 'https://raw.githubusercontent.com/n-ce/Uma/main/dynamic_instances.json'; - await fetch(apiUrl) + const ytifyApi = + (window as Window & typeof globalThis & { ytifyApi: string } + ).ytifyApi; + + if (!ytifyApi) return; + + await fetch(ytifyApi) .then(res => res.json()) .then(data => { a.piped = data.piped; @@ -26,6 +31,7 @@ export default async function() { a.unified = data.unified; store.downloadAPI = data.cobalt; store.player.proxy = data.proxy; + store.player.fallback = data.fallback; }); }