Steps towards using local video fallback on android

This commit is contained in:
WardPearce
2024-09-21 03:29:41 +12:00
parent 04c4efb9a2
commit 0f3803c038
6 changed files with 44 additions and 22 deletions
+4 -1
View File
@@ -7,6 +7,7 @@ import {
deArrowThumbnailInstanceStore,
instanceStore,
interfaceRegionStore,
playerYouTubeJsAlways,
playerYouTubeJsFallback,
returnYTDislikesInstanceStore,
synciousInstanceStore
@@ -72,7 +73,9 @@ export async function getPopular(fetchOptions?: RequestInit): Promise<Video[]> {
export async function getVideo(videoId: string, local: boolean = false, fetchOptions?: RequestInit): Promise<VideoPlay> {
const resp = await fetch(setRegion(buildPath(`videos/${videoId}?local=${local}`)), fetchOptions);
if (!resp.ok && Capacitor.isNativePlatform() && get(playerYouTubeJsFallback)) {
if (
(get(playerYouTubeJsAlways) && Capacitor.isNativePlatform()) ||
(!resp.ok && get(playerYouTubeJsFallback) && Capacitor.isNativePlatform())) {
return await patchYoutubeJs(videoId);
} else {
await fetchErrorHandle(resp);
+1 -1
View File
@@ -326,7 +326,7 @@
src = [{ src: data.video.dashUrl, type: 'application/dash+xml' }];
if (!data.video.fallbackPatch) {
if (Capacitor.getPlatform() !== 'electron' || proxyVideos) {
if (!Capacitor.isNativePlatform() || proxyVideos) {
(src[0] as { src: string }).src += '?local=true';
}
}
+35 -18
View File
@@ -29,6 +29,7 @@
playerProxyVideosStore,
playerSavePlaybackPositionStore,
playerTheatreModeByDefaultStore,
playerYouTubeJsAlways,
playerYouTubeJsFallback,
returnYTDislikesInstanceStore,
returnYtDislikesStore,
@@ -258,6 +259,40 @@
<div class="settings">
<h6>{$_('layout.player.title')}</h6>
{#if Capacitor.isNativePlatform()}
<div class="field no-margin">
<nav class="no-padding">
<div class="max">
<div>{$_('layout.player.youtubeJsAlways')}</div>
</div>
<label class="switch">
<input
type="checkbox"
bind:checked={$playerYouTubeJsAlways}
on:click={() => playerYouTubeJsAlways.set(!$playerYouTubeJsAlways)}
/>
<span></span>
</label>
</nav>
</div>
<div class="field no-margin">
<nav class="no-padding">
<div class="max">
<div>{$_('layout.player.youtubeJsFallback')}</div>
</div>
<label class="switch">
<input
type="checkbox"
bind:checked={$playerYouTubeJsFallback}
on:click={() => playerYouTubeJsFallback.set(!$playerYouTubeJsFallback)}
/>
<span></span>
</label>
</nav>
</div>
{/if}
<div class="field no-margin">
<nav class="no-padding">
<div class="max">
@@ -404,24 +439,6 @@
</label>
</nav>
</div>
{#if Capacitor.isNativePlatform()}
<div class="field no-margin">
<nav class="no-padding">
<div class="max">
<div>{$_('layout.player.youtubeJsFallback')}</div>
</div>
<label class="switch">
<input
type="checkbox"
bind:checked={$playerYouTubeJsFallback}
on:click={() => playerYouTubeJsFallback.set(!$playerYouTubeJsFallback)}
/>
<span></span>
</label>
</nav>
</div>
{/if}
</div>
<div class="settings">
+2 -1
View File
@@ -125,7 +125,8 @@
"backgroundPlay": "Play audio in background",
"dash": "Dash",
"silenceSkipper": "Silence skipper (Experimental)",
"youtubeJsFallback": "Local video processing fallback"
"youtubeJsFallback": "Local video processing fallback",
"youtubeJsAlways": "Always use local video processing"
},
"bookmarklet": "Bookmarklet",
"instanceUrl": "Instance URL",
@@ -14,7 +14,7 @@ if (Capacitor.getPlatform() === 'android') {
typeof requestInput === 'string' ? requestInput : requestInput.toString();
// Check if the URL is already proxied, to avoid double proxying
if (!requestUrl.startsWith(corsAnywhereProxyUrl) && !requestUrl.startsWith('/')) {
if (!requestUrl.startsWith(corsAnywhereProxyUrl) && !requestUrl.startsWith('/') && !requestUrl.startsWith('blob:') && !requestUrl.startsWith('/')) {
requestInput = corsAnywhereProxyUrl + requestUrl;
}
+1
View File
@@ -39,6 +39,7 @@ export const playerTheatreModeByDefaultStore = persisted('theatreModeByDefault',
export const playerAutoplayNextByDefaultStore = persisted('autoplayNextByDefault', false);
export const playerMiniPlayerStore = persisted('miniPlayer', true);
export const playerYouTubeJsFallback = persisted('youTubeJsFallback', true);
export const playerYouTubeJsAlways = persisted('youTubeJsAlways', false);
export const returnYtDislikesStore = persisted('returnYtDislikes', false);
export const returnYTDislikesInstanceStore: Writable<string | null | undefined> = persisted(