Implemented isUnrestrictedPlatform check
This commit is contained in:
@@ -33,7 +33,7 @@ import type {
|
||||
} from './model';
|
||||
import { commentsSetDefaults, searchSetDefaults, useEngineFallback } from './misc';
|
||||
import { getSearchYTjs } from './youtubejs/search';
|
||||
import { isYTBackend } from '$lib/misc';
|
||||
import { isUnrestrictedPlatform, isYTBackend } from '$lib/misc';
|
||||
import { getSearchSuggestionsYTjs } from './youtubejs/searchSuggestions';
|
||||
import { getResolveUrlYTjs } from './youtubejs/misc';
|
||||
import { getCommentsYTjs } from './youtubejs/comments';
|
||||
@@ -110,7 +110,7 @@ export async function getVideo(
|
||||
fetchOptions?: RequestInit
|
||||
): Promise<VideoPlay> {
|
||||
if (
|
||||
(get(playerYouTubeJsAlways) && Capacitor.isNativePlatform()) ||
|
||||
(get(playerYouTubeJsAlways) && isUnrestrictedPlatform()) ||
|
||||
isYTBackend() ||
|
||||
useEngineFallback('Video')
|
||||
) {
|
||||
@@ -119,7 +119,7 @@ export async function getVideo(
|
||||
|
||||
const resp = await fetch(setRegion(buildPath(`videos/${videoId}?local=${local}`)), fetchOptions);
|
||||
|
||||
if (!resp.ok && get(playerYouTubeJsFallback) && Capacitor.isNativePlatform()) {
|
||||
if (!resp.ok && get(playerYouTubeJsFallback) && isUnrestrictedPlatform()) {
|
||||
return await getVideoYTjs(videoId);
|
||||
} else {
|
||||
await fetchErrorHandle(resp);
|
||||
|
||||
@@ -2,6 +2,7 @@ import { get } from 'svelte/store';
|
||||
import type { CommentsOptions, SearchOptions } from './model';
|
||||
import { engineFallbacksStore } from '$lib/store';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { isUnrestrictedPlatform } from '$lib/misc';
|
||||
|
||||
export function searchSetDefaults(options: SearchOptions) {
|
||||
if (typeof options.sort_by === 'undefined') {
|
||||
@@ -34,5 +35,5 @@ export type EngineFallback =
|
||||
| 'Playlist';
|
||||
|
||||
export function useEngineFallback(fallback: EngineFallback): boolean {
|
||||
return get(engineFallbacksStore).includes(fallback) && Capacitor.isNativePlatform();
|
||||
return get(engineFallbacksStore).includes(fallback) && isUnrestrictedPlatform();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { get } from 'svelte/store';
|
||||
import type { Types } from 'youtubei.js';
|
||||
import { Utils, YT, YTNodes, Platform } from 'youtubei.js';
|
||||
import { getInnertube } from '.';
|
||||
import { isUnrestrictedPlatform } from '$lib/misc';
|
||||
|
||||
Platform.shim.eval = async (
|
||||
data: Types.BuildScriptResult,
|
||||
@@ -36,7 +37,7 @@ Platform.shim.eval = async (
|
||||
};
|
||||
|
||||
export async function getVideoYTjs(videoId: string): Promise<VideoPlay> {
|
||||
if (!Capacitor.isNativePlatform()) {
|
||||
if (!isUnrestrictedPlatform()) {
|
||||
throw new Error('Platform not supported');
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
import { Network, type ConnectionStatus } from '@capacitor/network';
|
||||
import { fade } from 'svelte/transition';
|
||||
import { addToast } from './Toast.svelte';
|
||||
import { isMobile, isYTBackend, truncate } from '$lib/misc';
|
||||
import { isMobile, isUnrestrictedPlatform, isYTBackend, truncate } from '$lib/misc';
|
||||
import {
|
||||
generateThumbnailWebVTT,
|
||||
drawTimelineThumbnail,
|
||||
@@ -524,7 +524,7 @@
|
||||
dashUrl = data.video.dashUrl;
|
||||
}
|
||||
|
||||
if (!data.video.fallbackPatch && (!Capacitor.isNativePlatform() || $playerProxyVideosStore)) {
|
||||
if (!data.video.fallbackPatch && (!isUnrestrictedPlatform() || $playerProxyVideosStore)) {
|
||||
dashUrl += '?local=true';
|
||||
}
|
||||
|
||||
@@ -1035,7 +1035,7 @@
|
||||
console.error(error);
|
||||
|
||||
if (
|
||||
!Capacitor.isNativePlatform() ||
|
||||
!isUnrestrictedPlatform() ||
|
||||
data.video.fallbackPatch === 'youtubejs' ||
|
||||
(error as shaka.extern.Error).code !== 1001
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { _ } from '$lib/i18n';
|
||||
import { get } from 'svelte/store';
|
||||
import type { Notification, PlaylistPageVideo, Video, VideoBase } from '../api/model';
|
||||
import { shareURL } from '$lib/misc';
|
||||
import { isUnrestrictedPlatform, shareURL } from '$lib/misc';
|
||||
import { addToast } from './Toast.svelte';
|
||||
|
||||
interface Props {
|
||||
@@ -45,7 +45,7 @@
|
||||
class="row"
|
||||
role="presentation"
|
||||
onclick={async () => {
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
if (isUnrestrictedPlatform()) {
|
||||
shareVideo(`${get(instanceStore)}/watch/${video.videoId}`);
|
||||
} else {
|
||||
shareVideo(
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import type { RgbaColor, HsvaColor, Colord } from 'colord';
|
||||
import { _ } from '$lib/i18n';
|
||||
import { get } from 'svelte/store';
|
||||
import { ensureNoTrailingSlash, isMobile, clearCaches } from '../../misc';
|
||||
import { ensureNoTrailingSlash, isMobile, clearCaches, isUnrestrictedPlatform } from '../../misc';
|
||||
import { getPages, type Pages } from '../../navPages';
|
||||
import ColorPicker from 'svelte-awesome-color-picker';
|
||||
import {
|
||||
@@ -153,7 +153,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if Capacitor.isNativePlatform()}
|
||||
{#if isUnrestrictedPlatform()}
|
||||
<div class="field label suffix border">
|
||||
<select name="backend-in-use" onchange={setBackend}>
|
||||
<option selected={$backendInUseStore === 'ivg'} value="ivg">Invidious</option>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
playerYouTubeJsFallback
|
||||
} from '../../store';
|
||||
import { playbackRates } from '$lib/player';
|
||||
import { isYTBackend } from '$lib/misc';
|
||||
import { isUnrestrictedPlatform, isYTBackend } from '$lib/misc';
|
||||
|
||||
let defaultLanguage = $state(get(playerDefaultLanguage));
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
<i>arrow_drop_down</i>
|
||||
</div>
|
||||
|
||||
{#if Capacitor.isNativePlatform() && !isYTBackend()}
|
||||
{#if isUnrestrictedPlatform() && !isYTBackend()}
|
||||
<div class="field suffix border label">
|
||||
<select
|
||||
tabindex="0"
|
||||
@@ -243,7 +243,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if Capacitor.isNativePlatform()}
|
||||
{#if isUnrestrictedPlatform()}
|
||||
<div class="field no-margin">
|
||||
<nav class="no-padding">
|
||||
<div class="max">
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import About from './About.svelte';
|
||||
import Engine from './Engine.svelte';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { isUnrestrictedPlatform } from '$lib/misc';
|
||||
|
||||
let activeTab = $state('interface');
|
||||
const isActive = (id: string) => activeTab === id;
|
||||
@@ -35,7 +36,7 @@
|
||||
}
|
||||
];
|
||||
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
if (isUnrestrictedPlatform()) {
|
||||
tabs.splice(1, 0, {
|
||||
id: 'engine',
|
||||
label: $_('layout.engine'),
|
||||
|
||||
@@ -229,8 +229,12 @@ export function findElementForTime<T>(
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isUnrestrictedPlatform(): boolean {
|
||||
return import.meta.env.VITE_BUILD_WITH_BACKEND === 'true' || Capacitor.isNativePlatform();
|
||||
}
|
||||
|
||||
export function isYTBackend(): boolean {
|
||||
return get(backendInUseStore) === 'yt' && Capacitor.isNativePlatform();
|
||||
return get(backendInUseStore) === 'yt' && isUnrestrictedPlatform();
|
||||
}
|
||||
|
||||
export function clearCaches() {
|
||||
|
||||
@@ -7,12 +7,13 @@ import { Constants, YT } from 'youtubei.js';
|
||||
import { get } from 'svelte/store';
|
||||
import { poTokenCacheStore } from '$lib/store';
|
||||
import { buildSabrFormat } from 'googlevideo/utils';
|
||||
import { isUnrestrictedPlatform } from '$lib/misc';
|
||||
|
||||
export async function injectSabr(
|
||||
video: VideoPlay,
|
||||
player: shaka.Player
|
||||
): Promise<SabrStreamingAdapter | null> {
|
||||
if (!video.ytjs || !Capacitor.isNativePlatform()) return null;
|
||||
if (!video.ytjs || !isUnrestrictedPlatform()) return null;
|
||||
|
||||
const sabrAdapter = new SabrStreamingAdapter({
|
||||
playerAdapter: new ShakaPlayerAdapter(),
|
||||
|
||||
Reference in New Issue
Block a user