|
@@ -164,42 +164,42 @@ detail = async (url, platform) => {
|
|
|
}
|
|
|
|
|
|
let originFormats = [];
|
|
|
- // // android
|
|
|
- // try {
|
|
|
- // const apiKey = 'AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39'
|
|
|
- // const data = {
|
|
|
- // "context": {
|
|
|
- // "client": {
|
|
|
- // "clientName": "ANDROID",
|
|
|
- // "clientVersion": "19.09.37",
|
|
|
- // "androidSdkVersion": 30,
|
|
|
- // "userAgent": "com.google.android.youtube/19.09.37 (Linux; U; Android 11) gzip",
|
|
|
- // }
|
|
|
- // },
|
|
|
- // 'videoId': url.replace('https://www.youtube.com/watch?v=', ''),
|
|
|
- // "playbackContext": {
|
|
|
- // "contentPlaybackContext": {
|
|
|
- // "html5Preference": "HTML5_PREF_WANTS"
|
|
|
- // }
|
|
|
- // },
|
|
|
- // "params": "CgIIAQ==",
|
|
|
- // "contentCheckOk": true,
|
|
|
- // "racyCheckOk": true
|
|
|
- // }
|
|
|
- // const apiUrl = `https://www.youtube.com/youtubei/v1/player?key=${apiKey}&prettyPrint=false`;
|
|
|
- // let apiResp = await request('POST', apiUrl, JSON.stringify(data), {
|
|
|
- // 'X-YouTube-Client-Name': '5',
|
|
|
- // 'X-YouTube-Client-Version': '19.09.3',
|
|
|
- // 'User-Agent': 'com.google.ios.youtube/19.09.3 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)',
|
|
|
- // 'Content-Type': 'application/json'
|
|
|
- // }, platform);
|
|
|
- // console.log(`android api result: ${JSON.stringify(apiResp)}`);
|
|
|
- // const res = JSON.parse(apiResp);
|
|
|
- // originFormats = originFormats.concat([].concat(res["streamingData"]["formats"]).concat(res["streamingData"]["adaptiveFormats"]));
|
|
|
- // } catch (e) {
|
|
|
- // console.log(`can not found format android api error: ${e}`);
|
|
|
- // }
|
|
|
- // console.log(`after android api, format size:${originFormats.length}`);
|
|
|
+ // android
|
|
|
+ try {
|
|
|
+ const apiKey = 'AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39'
|
|
|
+ const data = {
|
|
|
+ "context": {
|
|
|
+ "client": {
|
|
|
+ "clientName": "ANDROID",
|
|
|
+ "clientVersion": "19.09.37",
|
|
|
+ "androidSdkVersion": 30,
|
|
|
+ "userAgent": "com.google.android.youtube/19.09.37 (Linux; U; Android 11) gzip",
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'videoId': url.replace('https://www.youtube.com/watch?v=', ''),
|
|
|
+ "playbackContext": {
|
|
|
+ "contentPlaybackContext": {
|
|
|
+ "html5Preference": "HTML5_PREF_WANTS"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "params": "CgIIAQ==",
|
|
|
+ "contentCheckOk": true,
|
|
|
+ "racyCheckOk": true
|
|
|
+ }
|
|
|
+ const apiUrl = `https://www.youtube.com/youtubei/v1/player?key=${apiKey}&prettyPrint=false`;
|
|
|
+ let apiResp = await request('POST', apiUrl, JSON.stringify(data), {
|
|
|
+ 'X-YouTube-Client-Name': '5',
|
|
|
+ 'X-YouTube-Client-Version': '19.09.3',
|
|
|
+ 'User-Agent': 'com.google.ios.youtube/19.09.3 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)',
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ }, platform);
|
|
|
+ console.log(`android api result: ${JSON.stringify(apiResp)}`);
|
|
|
+ const res = JSON.parse(apiResp);
|
|
|
+ originFormats = originFormats.concat([].concat(res["streamingData"]["formats"]).concat(res["streamingData"]["adaptiveFormats"]));
|
|
|
+ } catch (e) {
|
|
|
+ console.log(`can not found format android api error: ${e}`);
|
|
|
+ }
|
|
|
+ console.log(`after android api, format size:${originFormats.length}`);
|
|
|
// ios
|
|
|
try {
|
|
|
const apiKey = 'AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc'
|