🐛 fix: Temporary patched to iOS client
This commit is contained in:
parent
6a8569feb8
commit
2bfbfe6dec
@ -297,15 +297,17 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
|||||||
});
|
});
|
||||||
let format = [];
|
let format = [];
|
||||||
if (!upcoming) {
|
if (!upcoming) {
|
||||||
format.push(...(player_response.streamingData.formats ?? []));
|
// TODO: Properly handle the formats, for now ignore and use iOS formats
|
||||||
format.push(...(player_response.streamingData.adaptiveFormats ?? []));
|
//format.push(...(player_response.streamingData.formats ?? []));
|
||||||
|
//format.push(...(player_response.streamingData.adaptiveFormats ?? []));
|
||||||
|
|
||||||
// get the formats for the android player for legacy videos
|
// get the formats for the android player for legacy videos
|
||||||
// fixes the stream being closed because not enough data
|
// fixes the stream being closed because not enough data
|
||||||
// arrived in time for ffmpeg to be able to extract audio data
|
// arrived in time for ffmpeg to be able to extract audio data
|
||||||
if (parseAudioFormats(format).length === 0 && !options.htmldata) {
|
//if (parseAudioFormats(format).length === 0 && !options.htmldata) {
|
||||||
format = await getAndroidFormats(vid.videoId, cookieJar, body);
|
// format = await getAndroidFormats(vid.videoId, cookieJar, body);
|
||||||
}
|
//}
|
||||||
|
format = await getIosFormats(vid.videoId, cookieJar, body);
|
||||||
}
|
}
|
||||||
const LiveStreamData = {
|
const LiveStreamData = {
|
||||||
isLive: video_details.live,
|
isLive: video_details.live,
|
||||||
@ -404,15 +406,17 @@ export async function video_stream_info(url: string, options: InfoOptions = {}):
|
|||||||
};
|
};
|
||||||
let format = [];
|
let format = [];
|
||||||
if (!upcoming) {
|
if (!upcoming) {
|
||||||
format.push(...(player_response.streamingData.formats ?? []));
|
// TODO: Properly handle the formats, for now ignore and use iOS formats
|
||||||
format.push(...(player_response.streamingData.adaptiveFormats ?? []));
|
//format.push(...(player_response.streamingData.formats ?? []));
|
||||||
|
//format.push(...(player_response.streamingData.adaptiveFormats ?? []));
|
||||||
|
|
||||||
// get the formats for the android player for legacy videos
|
// get the formats for the android player for legacy videos
|
||||||
// fixes the stream being closed because not enough data
|
// fixes the stream being closed because not enough data
|
||||||
// arrived in time for ffmpeg to be able to extract audio data
|
// arrived in time for ffmpeg to be able to extract audio data
|
||||||
if (parseAudioFormats(format).length === 0 && !options.htmldata) {
|
//if (parseAudioFormats(format).length === 0 && !options.htmldata) {
|
||||||
format = await getAndroidFormats(player_response.videoDetails.videoId, cookieJar, body);
|
// format = await getAndroidFormats(player_response.videoDetails.videoId, cookieJar, body);
|
||||||
}
|
//}
|
||||||
|
format = await getIosFormats(player_response.videoDetails.videoId, cookieJar, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
const LiveStreamData = {
|
const LiveStreamData = {
|
||||||
@ -680,7 +684,7 @@ async function acceptViewerDiscretion(
|
|||||||
return { streamingData };
|
return { streamingData };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAndroidFormats(videoId: string, cookieJar: { [key: string]: string }, body: string): Promise<any[]> {
|
async function getIosFormats(videoId: string, cookieJar: { [key: string]: string }, body: string): Promise<any[]> {
|
||||||
const apiKey =
|
const apiKey =
|
||||||
body.split('INNERTUBE_API_KEY":"')[1]?.split('"')[0] ??
|
body.split('INNERTUBE_API_KEY":"')[1]?.split('"')[0] ??
|
||||||
body.split('innertubeApiKey":"')[1]?.split('"')[0] ??
|
body.split('innertubeApiKey":"')[1]?.split('"')[0] ??
|
||||||
@ -691,8 +695,10 @@ async function getAndroidFormats(videoId: string, cookieJar: { [key: string]: st
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
context: {
|
context: {
|
||||||
client: {
|
client: {
|
||||||
clientName: 'ANDROID',
|
clientName: 'IOS',
|
||||||
clientVersion: '16.49',
|
clientVersion: '19.09.3',
|
||||||
|
deviceModel: 'iPhone16,1',
|
||||||
|
userAgent: 'com.google.ios.youtube/19.09.3 (iPhone; CPU iPhone OS 17_5 like Mac OS X)',
|
||||||
hl: 'en',
|
hl: 'en',
|
||||||
timeZone: 'UTC',
|
timeZone: 'UTC',
|
||||||
utcOffsetMinutes: 0
|
utcOffsetMinutes: 0
|
||||||
@ -707,7 +713,8 @@ async function getAndroidFormats(videoId: string, cookieJar: { [key: string]: st
|
|||||||
cookieJar
|
cookieJar
|
||||||
});
|
});
|
||||||
|
|
||||||
return JSON.parse(response).streamingData.formats;
|
return JSON.parse(response).streamingData.adaptiveFormats;
|
||||||
|
//return JSON.parse(response).streamingData.formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWatchPlaylist(response: any, body: any, url: string): YouTubePlayList {
|
function getWatchPlaylist(response: any, body: any, url: string): YouTubePlayList {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user