=> {
+ if (requestInput.toString().startsWith(localProxy)) {
+ return originalFetch(requestInput, requestOptions);
}
- if (!requestUrl.startsWith(corsProxyUrl) && !requestUrl.startsWith('/') && !requestUrl.startsWith('blob:')) {
- requestInput = corsProxyUrl + requestUrl;
- }
-
- // Use the original fetch with the proxied URL and options
- return originalFetch(requestInput, requestOptions);
- };
-
- const currentOrigin: string = window.location.protocol + '//' + window.location.host;
- const originalXhrOpen = XMLHttpRequest.prototype.open;
-
- XMLHttpRequest.prototype.open = function (...args: any[]): void {
- const targetOriginMatch = /^https?:\/\/([^\/]+)/i.exec(args[1]);
- if (targetOriginMatch && targetOriginMatch[0].toLowerCase() !== currentOrigin) {
- args[1] = corsProxyUrl + args[1];
- }
- /* @ts-ignore */
- return originalXhrOpen.apply(this, args);
+ return capacitorFetch(requestInput, requestOptions);
};
setTimeout(() => goto('/', { replaceState: true }), 10);
diff --git a/materialious/src/lib/components/Player.svelte b/materialious/src/lib/components/Player.svelte
index 640cc406..cdc7648c 100644
--- a/materialious/src/lib/components/Player.svelte
+++ b/materialious/src/lib/components/Player.svelte
@@ -1,18 +1,22 @@
@@ -418,6 +402,16 @@
{/if}
+
+
+
+
{#if !isEmbed}
{snackBarAlert}
diff --git a/materialious/src/lib/misc.ts b/materialious/src/lib/misc.ts
index 14055d8b..a4f00eba 100644
--- a/materialious/src/lib/misc.ts
+++ b/materialious/src/lib/misc.ts
@@ -29,20 +29,6 @@ export function proxyVideoUrl(source: string): string {
return rawSrc.toString();
}
-export function pullBitratePreference(): number {
- const vidstack = localStorage.getItem('video-player');
-
- if (vidstack) {
- const vidstackSettings = JSON.parse(vidstack);
- if (vidstackSettings.quality && vidstackSettings.quality.bitrate) {
- return vidstackSettings.quality.bitrate;
- }
- }
-
- return -1;
-}
-
-
export function unsafeRandomItem(array: any[]): any {
return array[Math.floor(Math.random() * array.length)];
}
diff --git a/materialious/src/lib/patches/youtubejs.ts b/materialious/src/lib/patches/youtubejs.ts
index 88e2d693..ebf3b829 100644
--- a/materialious/src/lib/patches/youtubejs.ts
+++ b/materialious/src/lib/patches/youtubejs.ts
@@ -5,8 +5,7 @@ import { Capacitor } from '@capacitor/core';
import type { WebPoSignalOutput } from 'bgutils-js';
import { BG, buildURL, GOOG_API_KEY } from 'bgutils-js';
import { get } from 'svelte/store';
-import { Innertube, UniversalCache } from 'youtubei.js';
-import { capacitorFetch } from '../android/http/capacitorFetch';
+import { Innertube, UniversalCache, YT, YTNodes } from 'youtubei.js';
type WebPoMinter = {
integrityTokenBasedMinter?: BG.WebPoMinter;
@@ -88,7 +87,7 @@ export async function patchYoutubeJs(videoId: string): Promise {
}
const youtube = await Innertube.create({
- fetch: Capacitor.getPlatform() === 'android' ? capacitorFetch : fetch,
+ fetch: fetch,
generate_session_locally: true,
cache: new UniversalCache(false),
location: get(interfaceRegionStore)
@@ -105,7 +104,35 @@ export async function patchYoutubeJs(videoId: string): Promise {
sessionWebPo = poTokensCached;
}
- const video = await youtube.getInfo(videoId);
+ const extraArgs: Record = {
+ playbackContext: {
+ contentPlaybackContext: {
+ vis: 0,
+ splay: false,
+ lactMilliseconds: '-1',
+ signatureTimestamp: youtube.session.player?.sts
+ }
+ },
+ contentCheckOk: true,
+ racyCheckOk: true
+ };
+
+ // Generate content WebPO token.
+ if (integrityTokenBasedMinter) {
+ extraArgs.serviceIntegrityDimensions = {
+ poToken: await integrityTokenBasedMinter.mintAsWebsafeString(videoId)
+ };
+ }
+
+ const watchEndpoint = new YTNodes.NavigationEndpoint({ watchEndpoint: { videoId } });
+ const rawPlayerResponse = await watchEndpoint.call(youtube.actions, extraArgs);
+ const rawNextResponse = await watchEndpoint.call(youtube.actions, {
+ override_endpoint: '/next',
+ racyCheckOk: true,
+ contentCheckOk: true
+ });
+
+ const video = new YT.VideoInfo([rawPlayerResponse, rawNextResponse], youtube!.actions, '');
if (!video.primary_info || !video.secondary_info) {
throw new Error('Unable to pull video info from youtube.js');
@@ -115,21 +142,6 @@ export async function patchYoutubeJs(videoId: string): Promise {
if (!video.basic_info.is_live) {
let manifest = await video.toDash();
-
- let parser = new DOMParser();
- let xmlDoc = parser.parseFromString(manifest, 'application/xml');
-
- let baseURLs = xmlDoc.getElementsByTagName('BaseURL');
-
- Array.from(baseURLs).forEach((baseURL) => {
- let url = new URL(baseURL.textContent as string);
- url.searchParams.set('pot', (sessionWebPo ?? BG.PoToken.generateColdStartToken(youtube.session.context.client.visitorData ?? '')));
- baseURL.textContent = url.toString();
- });
-
- const serializer = new XMLSerializer();
- manifest = serializer.serializeToString(xmlDoc);
-
dashUri = URL.createObjectURL(new Blob([manifest], { type: 'application/dash+xml;charset=utf8' }));
}
@@ -199,8 +211,6 @@ export async function patchYoutubeJs(videoId: string): Promise {
});
}
- console.log(video.primary_info);
-
return {
type: 'video',
title: video.primary_info.title?.toString() || '',
diff --git a/materialious/tsconfig.json b/materialious/tsconfig.json
index d9a18b12..0fe20b84 100644
--- a/materialious/tsconfig.json
+++ b/materialious/tsconfig.json
@@ -11,7 +11,7 @@
"strict": true,
"moduleResolution": "bundler",
"types": [
- "vidstack/svelte"
+ "shaka-player"
]
},
"include": [