Fix formatting of adaptive_formats
This commit is contained in:
@@ -174,8 +174,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
let dashUrl: string | undefined = undefined;
|
||||
|
||||
player = new shaka.Player();
|
||||
playerElement = document.getElementById('player') as HTMLMediaElement;
|
||||
|
||||
@@ -221,11 +219,7 @@
|
||||
|
||||
player.configure({
|
||||
abr: {
|
||||
enabled: true,
|
||||
restrictions: {
|
||||
maxWidth: 1920,
|
||||
maxHeight: 1080
|
||||
}
|
||||
enabled: true
|
||||
},
|
||||
streaming: {
|
||||
bufferingGoal: 120,
|
||||
@@ -267,13 +261,7 @@
|
||||
.media_ustreamer_request_config?.video_playback_ustreamer_config;
|
||||
|
||||
if (data.video.ytjs.video.streaming_data) {
|
||||
formatList = data.video.ytjs.video.streaming_data.adaptive_formats.map((format) => {
|
||||
const formatKey = fromFormat(format) || '';
|
||||
format.url = `https://sabr?___key=${formatKey}`;
|
||||
format.signature_cipher = undefined;
|
||||
format.decipher = () => format.url || '';
|
||||
return format;
|
||||
});
|
||||
formatList = data.video.ytjs.video.streaming_data.adaptive_formats;
|
||||
}
|
||||
|
||||
if (data.video.ytjs.video.streaming_data?.server_abr_streaming_url)
|
||||
@@ -283,20 +271,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
if (data.video.ytjs.video.streaming_data) {
|
||||
if (isLive) {
|
||||
dashUrl = data.video.ytjs.video.streaming_data.dash_manifest_url
|
||||
? `${data.video.ytjs.video.streaming_data.dash_manifest_url}/mpd_version/7`
|
||||
: data.video.ytjs.video.streaming_data.hls_manifest_url;
|
||||
} else if (data.video.ytjs.video.streaming_data.dash_manifest_url && isPostLiveDVR) {
|
||||
dashUrl = data.video.ytjs.video.streaming_data.hls_manifest_url
|
||||
? data.video.ytjs.video.streaming_data.hls_manifest_url // HLS is preferred for DVR streams.
|
||||
: `${data.video.ytjs.video.streaming_data.dash_manifest_url}/mpd_version/7`;
|
||||
} else {
|
||||
dashUrl = `data:application/dash+xml;base64,${btoa(await data.video.ytjs.video.toDash(undefined, undefined, { captions_format: 'vtt' }))}`;
|
||||
}
|
||||
}
|
||||
|
||||
playerElement.addEventListener('seeked', () => (lastSeekMs = Date.now()));
|
||||
|
||||
player.addEventListener('variantchanged', (event) => {
|
||||
@@ -526,7 +500,7 @@
|
||||
}
|
||||
}
|
||||
} else if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
|
||||
const innertube = await Innertube.create({ fetch: fetch });
|
||||
const innertube = await Innertube.create({ fetch: window.fetch });
|
||||
const wrapped = {} as Record<string, any>;
|
||||
wrapped.context = innertube.session.context;
|
||||
wrapped.cpn = data.video.ytjs?.clientPlaybackNonce;
|
||||
@@ -635,9 +609,7 @@
|
||||
}
|
||||
|
||||
if (!data.video.hlsUrl) {
|
||||
if (!dashUrl) {
|
||||
dashUrl = data.video.dashUrl;
|
||||
}
|
||||
let dashUrl = data.video.dashUrl;
|
||||
|
||||
if (!data.video.fallbackPatch && (!Capacitor.isNativePlatform() || proxyVideos)) {
|
||||
dashUrl += '?local=true';
|
||||
@@ -771,7 +743,11 @@
|
||||
});
|
||||
}
|
||||
} else {
|
||||
await player.load(data.video.hlsUrl + '?local=true');
|
||||
if (data.video.fallbackPatch === 'youtubejs') {
|
||||
await player.load(data.video.dashUrl);
|
||||
} else {
|
||||
await player.load(data.video.hlsUrl + '?local=true');
|
||||
}
|
||||
}
|
||||
|
||||
if (data.video.fallbackPatch === 'youtubejs') {
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
VideoPlay
|
||||
} from '$lib/api/model';
|
||||
import { numberWithCommas } from '$lib/numbers';
|
||||
import { fromFormat } from '$lib/sabr/formatKeyUtils';
|
||||
import { interfaceRegionStore, poTokenCacheStore } from '$lib/store';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { USER_AGENT } from 'bgutils-js';
|
||||
@@ -76,12 +77,11 @@ export async function patchYoutubeJs(videoId: string): Promise<VideoPlay> {
|
||||
const rawNextResponse = await watchEndpoint.call(youtube.actions, {
|
||||
override_endpoint: '/next',
|
||||
racyCheckOk: true,
|
||||
contentCheckOk: true,
|
||||
parse: false
|
||||
contentCheckOk: true
|
||||
});
|
||||
const video = new YT.VideoInfo(
|
||||
[rawPlayerResponse, rawNextResponse],
|
||||
youtube!.actions,
|
||||
youtube.actions,
|
||||
clientPlaybackNonce
|
||||
);
|
||||
|
||||
@@ -89,13 +89,33 @@ export async function patchYoutubeJs(videoId: string): Promise<VideoPlay> {
|
||||
throw new Error('Unable to pull video info from youtube.js');
|
||||
}
|
||||
|
||||
let dashUri: string = '';
|
||||
let dashUri: string | undefined;
|
||||
|
||||
if (!video.basic_info.is_live) {
|
||||
const manifest = await video.toDash();
|
||||
dashUri = `data:application/dash+xml;charset=utf-8;base64,${Buffer.from(manifest).toString('base64')}`;
|
||||
if (video.streaming_data) {
|
||||
video.streaming_data.adaptive_formats = video.streaming_data.adaptive_formats.map((format) => {
|
||||
const formatKey = fromFormat(format) || '';
|
||||
format.url = `https://sabr?___key=${formatKey}`;
|
||||
format.signature_cipher = undefined;
|
||||
format.decipher = () => format.url || '';
|
||||
|
||||
return format;
|
||||
});
|
||||
|
||||
if (video.basic_info.is_live) {
|
||||
dashUri = video.streaming_data.dash_manifest_url
|
||||
? `${video.streaming_data.dash_manifest_url}/mpd_version/7`
|
||||
: video.streaming_data.hls_manifest_url;
|
||||
} else if (video.streaming_data.dash_manifest_url && video.basic_info.is_post_live_dvr) {
|
||||
dashUri = video.streaming_data.hls_manifest_url
|
||||
? video.streaming_data.hls_manifest_url // HLS is preferred for DVR streams.
|
||||
: `${video.streaming_data.dash_manifest_url}/mpd_version/7`;
|
||||
} else {
|
||||
dashUri = `data:application/dash+xml;base64,${btoa(await video.toDash(undefined, undefined, { captions_format: 'vtt' }))}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dashUri) throw Error('Unable to find suitable dash manifest');
|
||||
|
||||
const descString = video.secondary_info.description?.toString() || '';
|
||||
|
||||
let authorThumbnails: Image[];
|
||||
@@ -207,7 +227,7 @@ export async function patchYoutubeJs(videoId: string): Promise<VideoPlay> {
|
||||
innertube: youtube,
|
||||
video: video,
|
||||
clientPlaybackNonce: clientPlaybackNonce,
|
||||
rawApiResponse: rawResponse
|
||||
rawApiResponse: rawPlayerResponse
|
||||
},
|
||||
fallbackPatch: 'youtubejs'
|
||||
};
|
||||
|
||||
@@ -63,7 +63,6 @@ export function phaseDescription(
|
||||
/<a href="([^"]+)"/,
|
||||
'<a href="$1" target="_blank" rel="noopener noreferrer" class="link"'
|
||||
);
|
||||
console.log(modifiedLine);
|
||||
filteredLines.push(modifiedLine);
|
||||
} else if (timestampMatch !== null) {
|
||||
// If line contains a timestamp, extract details and push into timestamps array
|
||||
|
||||
@@ -192,11 +192,9 @@
|
||||
|
||||
const link = (event.target as HTMLElement).closest('a');
|
||||
|
||||
if (link && link.href) {
|
||||
if (link.href && link.href.startsWith('http') && link.target === '_blank') {
|
||||
event.preventDefault();
|
||||
Browser.open({ url: link.href });
|
||||
}
|
||||
if (link && link.href && link.href.startsWith('http') && link.target === '_blank') {
|
||||
event.preventDefault();
|
||||
Browser.open({ url: link.href });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user