|
@@ -271,6 +271,46 @@ detail = async (url, platform) => {
|
|
|
|
|
|
let originFormats = [];
|
|
|
|
|
|
+ // android
|
|
|
+ try {
|
|
|
+ const apiKey = 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'
|
|
|
+ const apiUrl = `https://www.youtube.com/youtubei/v1/player?key=${apiKey}`;
|
|
|
+ const apiResp = await request('POST', apiUrl, JSON.stringify({
|
|
|
+ "videoId": url.replace('https://www.youtube.com/watch?v=', ''),
|
|
|
+ "contentCheckOk": true,
|
|
|
+ "params": "8AEB",
|
|
|
+ "context": {
|
|
|
+ "client": {
|
|
|
+ "clientName": "ANDROID_MUSIC",
|
|
|
+ "clientVersion": "5.16.51",
|
|
|
+ "androidSdkVersion": 30
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "racyCheckOk": true
|
|
|
+ }), {
|
|
|
+ 'Host': 'www.youtube.com',
|
|
|
+ 'Connection': 'keep-alive',
|
|
|
+ 'User-Agent': 'com.google.android.apps.youtube.music/17.31.35 (Linux; U; Android 11) gzip',
|
|
|
+ 'Accept-Language': 'en-US,en',
|
|
|
+ 'Cookie': parseSetCookie(htmlHeaders),
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ }, platform);
|
|
|
+ let {data: apiData, _} = apiResp;
|
|
|
+ console.log(`android api result: ${JSON.stringify(apiResp)}`);
|
|
|
+ const res = JSON.parse(apiData);
|
|
|
+ const currentFormats = [];
|
|
|
+ for (const format of [].concat(res["streamingData"]["formats"]).concat(res["streamingData"]["adaptiveFormats"])) {
|
|
|
+ if (format) {
|
|
|
+ format["from"] = "android"
|
|
|
+ currentFormats.push(format);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ originFormats = originFormats.concat(currentFormats);
|
|
|
+ } catch (e) {
|
|
|
+ console.log(`can not found format android api error: ${e}`);
|
|
|
+ }
|
|
|
+ console.log(`after android api, format size:${originFormats.length}`);
|
|
|
+
|
|
|
const currentFormats = [];
|
|
|
for (const format of ytInitialPlayerResponse["streamingData"]["formats"].concat(ytInitialPlayerResponse["streamingData"]["adaptiveFormats"])) {
|
|
|
if (format) {
|
|
@@ -278,7 +318,6 @@ detail = async (url, platform) => {
|
|
|
currentFormats.push(format);
|
|
|
}
|
|
|
}
|
|
|
- currentFormats.reverse()
|
|
|
originFormats = originFormats.concat(currentFormats);
|
|
|
console.log(`after html, format size:${originFormats.length}`);
|
|
|
|