diff --git a/materialious/package-lock.json b/materialious/package-lock.json index a8a940a8..56082b15 100644 --- a/materialious/package-lock.json +++ b/materialious/package-lock.json @@ -23,7 +23,6 @@ "beercss": "^3.8.0", "bgutils-js": "^3.1.3", "capacitor-nodejs": "https://github.com/EdenwareApps/Capacitor-NodeJS/releases/download/v1.0.0-beta.7/capacitor6-nodejs.tgz", - "dashjs": "^4.7.4", "fuse.js": "^7.0.0", "googlevideo": "^2.0.0", "he": "^1.2.0", @@ -4594,45 +4593,6 @@ ], "license": "MIT" }, - "node_modules/bcp-47": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/bcp-47/-/bcp-47-1.0.8.tgz", - "integrity": "sha512-Y9y1QNBBtYtv7hcmoX0tR+tUNSFZGZ6OL6vKPObq8BbOhkCoyayF6ogfLTgAli/KuAEbsYHYUNq2AQuY6IuLag==", - "license": "MIT", - "dependencies": { - "is-alphabetical": "^1.0.0", - "is-alphanumerical": "^1.0.0", - "is-decimal": "^1.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/bcp-47-match": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/bcp-47-match/-/bcp-47-match-1.0.3.tgz", - "integrity": "sha512-LggQ4YTdjWQSKELZF5JwchnBa1u0pIQSZf5lSdOHEdbVP55h0qICA/FUp3+W99q0xqxYa1ZQizTUH87gecII5w==", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/bcp-47-normalize": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/bcp-47-normalize/-/bcp-47-normalize-1.1.1.tgz", - "integrity": "sha512-jWZ1Jdu3cs0EZdfCkS0UE9Gg01PtxnChjEBySeB+Zo6nkqtFfnvtoQQgP1qU1Oo4qgJgxhTI6Sf9y/pZIhPs0A==", - "license": "MIT", - "dependencies": { - "bcp-47": "^1.0.0", - "bcp-47-match": "^1.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/beercss": { "version": "3.9.4", "resolved": "https://registry.npmjs.org/beercss/-/beercss-3.9.4.tgz", @@ -5088,12 +5048,6 @@ "node": ">=6" } }, - "node_modules/codem-isoboxer": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/codem-isoboxer/-/codem-isoboxer-0.3.9.tgz", - "integrity": "sha512-4XOTqEzBWrGOZaMd+sTED2hLpzfBbiQCf1W6OBGkIHqk1D8uwy8WFLazVbdQwfDpQ+vf39lqTGPa9IhWW0roTA==", - "license": "MIT" - }, "node_modules/color": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", @@ -5595,24 +5549,6 @@ "node": ">=8" } }, - "node_modules/dashjs": { - "version": "4.7.4", - "resolved": "https://registry.npmjs.org/dashjs/-/dashjs-4.7.4.tgz", - "integrity": "sha512-+hldo25QPP3H/NOwqUrvt4uKdMse60/Gsz9AUAnoYfhga8qHWq4nWiojUosOiigbigkDTCAn9ORcvUaKCvmfCA==", - "license": "BSD-3-Clause", - "dependencies": { - "bcp-47-match": "^1.0.3", - "bcp-47-normalize": "^1.1.1", - "codem-isoboxer": "0.3.9", - "es6-promise": "^4.2.8", - "fast-deep-equal": "2.0.1", - "html-entities": "^1.2.1", - "imsc": "^1.1.5", - "localforage": "^1.7.1", - "path-browserify": "^1.0.1", - "ua-parser-js": "^1.0.37" - } - }, "node_modules/data-urls": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", @@ -6360,12 +6296,6 @@ "es6-symbol": "^3.1.1" } }, - "node_modules/es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "license": "MIT" - }, "node_modules/es6-symbol": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.4.tgz", @@ -6778,12 +6708,6 @@ "type": "^2.7.2" } }, - "node_modules/fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha512-bCK/2Z4zLidyB4ReuIsvALH6w31YfAQDmXMqMx6FyfHqvBxtjC0eRumeSu4Bs3XtXwpyIywtSTrVT99BxY1f9w==", - "license": "MIT" - }, "node_modules/fast-fifo": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", @@ -7822,12 +7746,6 @@ "node": ">=18" } }, - "node_modules/html-entities": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.4.0.tgz", - "integrity": "sha512-8nxjcBcd8wovbeKx7h3wTji4e6+rhaVuPNpMqwWgnHh+N9ToqsCs6XztWRBPQ+UtzsoMAdKZtUENoVzU/EMtZA==", - "license": "MIT" - }, "node_modules/http-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", @@ -7919,12 +7837,6 @@ "node": ">= 4" } }, - "node_modules/immediate": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", - "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", - "license": "MIT" - }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", @@ -7953,15 +7865,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/imsc": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/imsc/-/imsc-1.1.5.tgz", - "integrity": "sha512-V8je+CGkcvGhgl2C1GlhqFFiUOIEdwXbXLiu1Fcubvvbo+g9inauqT3l0pNYXGoLPBj3jxtZz9t+wCopMkwadQ==", - "license": "BSD-2-Clause", - "dependencies": { - "sax": "1.2.1" - } - }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -8038,30 +7941,6 @@ "tslib": "2" } }, - "node_modules/is-alphabetical": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.4.tgz", - "integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/is-alphanumerical": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz", - "integrity": "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==", - "license": "MIT", - "dependencies": { - "is-alphabetical": "^1.0.0", - "is-decimal": "^1.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/is-array-buffer": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", @@ -8211,16 +8090,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-decimal": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.4.tgz", - "integrity": "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/is-docker": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", @@ -9026,15 +8895,6 @@ "node": ">= 0.8.0" } }, - "node_modules/lie": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", - "integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==", - "license": "MIT", - "dependencies": { - "immediate": "~3.0.5" - } - }, "node_modules/lilconfig": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", @@ -9078,15 +8938,6 @@ "node": ">=4" } }, - "node_modules/localforage": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz", - "integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==", - "license": "Apache-2.0", - "dependencies": { - "lie": "3.1.1" - } - }, "node_modules/locate-character": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", @@ -10328,12 +10179,6 @@ "node": ">=0.6.0" } }, - "node_modules/path-browserify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", - "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", - "license": "MIT" - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -13263,32 +13108,6 @@ "node": ">=14.17" } }, - "node_modules/ua-parser-js": { - "version": "1.0.40", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.40.tgz", - "integrity": "sha512-z6PJ8Lml+v3ichVojCiB8toQJBuwR42ySM4ezjXIqXK3M0HczmKQ3LF4rhU55PfD99KEEXQG6yb7iOMyvYuHew==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/ua-parser-js" - }, - { - "type": "paypal", - "url": "https://paypal.me/faisalman" - }, - { - "type": "github", - "url": "https://github.com/sponsors/faisalman" - } - ], - "license": "MIT", - "bin": { - "ua-parser-js": "script/cli.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/uglify-js": { "version": "3.19.3", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", diff --git a/materialious/package.json b/materialious/package.json index 3ede2e8f..56cceed8 100644 --- a/materialious/package.json +++ b/materialious/package.json @@ -56,7 +56,6 @@ "beercss": "^3.8.0", "bgutils-js": "^3.1.3", "capacitor-nodejs": "https://github.com/EdenwareApps/Capacitor-NodeJS/releases/download/v1.0.0-beta.7/capacitor6-nodejs.tgz", - "dashjs": "^4.7.4", "fuse.js": "^7.0.0", "googlevideo": "^2.0.0", "he": "^1.2.0", @@ -76,4 +75,4 @@ "terser": "^5.34.1", "youtubei.js": "^13.1.0" } -} \ No newline at end of file +} diff --git a/materialious/src/lib/api/index.ts b/materialious/src/lib/api/index.ts index 859da2b9..40b6c905 100644 --- a/materialious/src/lib/api/index.ts +++ b/materialious/src/lib/api/index.ts @@ -79,10 +79,13 @@ export async function getResolveUrl(url: string): Promise { } export async function getVideo(videoId: string, local: boolean = false, fetchOptions?: RequestInit): Promise { + if (get(playerYouTubeJsAlways) && Capacitor.isNativePlatform()) { + return await patchYoutubeJs(videoId); + } + const resp = await fetch(setRegion(buildPath(`videos/${videoId}?local=${local}`)), fetchOptions); - if ( - (get(playerYouTubeJsAlways) && Capacitor.isNativePlatform()) || - (!resp.ok && get(playerYouTubeJsFallback) && Capacitor.isNativePlatform())) { + + if (!resp.ok && get(playerYouTubeJsFallback) && Capacitor.isNativePlatform()) { return await patchYoutubeJs(videoId); } else { await fetchErrorHandle(resp); diff --git a/materialious/src/lib/components/Player.svelte b/materialious/src/lib/components/Player.svelte index d159d365..7a1fe94f 100644 --- a/materialious/src/lib/components/Player.svelte +++ b/materialious/src/lib/components/Player.svelte @@ -47,13 +47,13 @@ let snackBarAlert = $state(''); let playerPosSet = false; let originalOrigination: ScreenOrientationResult | undefined; - let sponsorBlockElements: Element[] = []; let watchProgressTimeout: NodeJS.Timeout; const HTTP_IN_HEX = 0x68747470; let player: shaka.Player; let playerElement: HTMLMediaElement; + let shakaUi: shaka.ui.Overlay; function loadTimeFromUrl(page: Page): boolean { if (player) { @@ -81,6 +81,23 @@ playerElement = document.getElementById('player') as HTMLMediaElement; await player.attach(playerElement); + shakaUi = new shaka.ui.Overlay( + player, + document.getElementById('shaka-container') as HTMLElement, + playerElement + ); + + shakaUi.configure({ + controlPanelElements: [ + 'play_pause', + 'spacer', + Capacitor.getPlatform() === 'electron' ? 'volume' : '', + 'chapter', + 'time_and_duration', + 'overflow_menu' + ], + overflowMenuButtons: ['cast', 'airplay', 'captions', 'quality', 'loop', 'language'] + }); player.configure({ streaming: { @@ -96,9 +113,7 @@ enabled: false, restrictToElementSize: true }, - autoShowText: shaka.config.AutoShowText.NEVER, - - preferredDecodingAttributes: !data.video.hlsUrl ? ['smooth', 'powerEfficient'] : [] + autoShowText: shaka.config.AutoShowText.NEVER }); if (data.video.fallbackPatch === 'youtubejs') { @@ -121,6 +136,7 @@ url.searchParams.set('range', headers.Range.split('=')[1]); url.searchParams.set('ump', '1'); url.searchParams.set('srfvp', '1'); + url.searchParams.set('mpd_version', '7'); url.searchParams.set('pot', get(poTokenCacheStore)); delete headers.Range; } @@ -178,24 +194,6 @@ }); } - const shakaUi = new shaka.ui.Overlay( - player, - document.getElementById('shaka-container') as HTMLElement, - playerElement - ); - - shakaUi.configure({ - controlPanelElements: [ - 'play_pause', - 'spacer', - Capacitor.getPlatform() === 'electron' ? 'volume' : '', - 'chapter', - 'time_and_duration', - 'overflow_menu' - ], - overflowMenuButtons: ['cast', 'airplay', 'captions', 'quality', 'loop', 'language'] - }); - if (!data.video.hlsUrl) { let dashUrl = data.video.dashUrl; @@ -418,8 +416,8 @@ savePlayerPos(); } catch (error) {} await playerElement.pause(); - player.destroy(); - playerElement.remove(); + await player.destroy(); + await shakaUi.destroy(); playerPosSet = false; }); diff --git a/materialious/src/lib/patches/youtubejs.ts b/materialious/src/lib/patches/youtubejs.ts index 9388e268..12240ede 100644 --- a/materialious/src/lib/patches/youtubejs.ts +++ b/materialious/src/lib/patches/youtubejs.ts @@ -92,7 +92,7 @@ export async function patchYoutubeJs(videoId: string): Promise { const youtube = await Innertube.create({ fetch: fetchClient, - generate_session_locally: true, + generate_session_locally: false, cache: new UniversalCache(false), location: get(interfaceRegionStore) });