|
@@ -282,114 +282,6 @@ detail = async (url, platform) => {
|
|
originFormats = originFormats.concat(currentFormats);
|
|
originFormats = originFormats.concat(currentFormats);
|
|
console.log(`after html, format size:${originFormats.length}`);
|
|
console.log(`after html, format size:${originFormats.length}`);
|
|
|
|
|
|
- // // android
|
|
|
|
- // try {
|
|
|
|
- // const apiKey = 'AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w'
|
|
|
|
- // const apiUrl = `https://www.youtube.com/youtubei/v1/player?key=${apiKey}&prettyPrint=false`;
|
|
|
|
- // const apiResp = await request('POST', apiUrl, JSON.stringify({
|
|
|
|
- // "context": {
|
|
|
|
- // "client": {
|
|
|
|
- // "clientName": "ANDROID",
|
|
|
|
- // "clientVersion": "19.09.37",
|
|
|
|
- // "androidSdkVersion": 30,
|
|
|
|
- // 'userAgent': 'com.google.android.youtube/19.09.37 (Linux; U; Android 11) gzip',
|
|
|
|
- // "hl": "en",
|
|
|
|
- // "timeZone": "UTC",
|
|
|
|
- // "utcOffsetMinutes": 0
|
|
|
|
- // }
|
|
|
|
- // },
|
|
|
|
- // 'videoId': url.replace('https://www.youtube.com/watch?v=', ''),
|
|
|
|
- // "params": "CgIIAQ==",
|
|
|
|
- // "playbackContext": {
|
|
|
|
- // "contentPlaybackContext": {
|
|
|
|
- // "html5Preference": "HTML5_PREF_WANTS"
|
|
|
|
- // }
|
|
|
|
- // },
|
|
|
|
- // "contentCheckOk": true,
|
|
|
|
- // "racyCheckOk": true
|
|
|
|
- // }), {
|
|
|
|
- // 'Host': 'www.youtube.com',
|
|
|
|
- // 'Connection': 'keep-alive',
|
|
|
|
- // 'User-Agent': 'com.google.android.youtube/19.09.37 (Linux; U; Android 11) gzip',
|
|
|
|
- // 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
|
|
- // 'Accept-Language': 'en-us,en;q=0.5',
|
|
|
|
- // 'Sec-Fetch-Mode': 'navigate',
|
|
|
|
- // 'X-YouTube-Client-Name': '3',
|
|
|
|
- // 'X-YouTube-Client-Version': '19.09.37',
|
|
|
|
- // 'Origin': 'https://www.youtube.com',
|
|
|
|
- // 'Accept-Encoding': 'gzip, deflate, br',
|
|
|
|
- // '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}`);
|
|
|
|
- // // ios
|
|
|
|
- // try {
|
|
|
|
- // const apiKey = 'AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc'
|
|
|
|
- // const apiUrl = `https://www.youtube.com/youtubei/v1/player?key=${apiKey}&prettyPrint=false`;
|
|
|
|
- // let apiResp = await request('POST', apiUrl, JSON.stringify({
|
|
|
|
- // "context": {
|
|
|
|
- // "client": {
|
|
|
|
- // 'clientName': 'IOS',
|
|
|
|
- // 'clientVersion': '19.09.3',
|
|
|
|
- // 'deviceModel': 'iPhone14,3',
|
|
|
|
- // 'userAgent': 'com.google.ios.youtube/19.09.3 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)',
|
|
|
|
- // "hl": "en",
|
|
|
|
- // "timeZone": "UTC",
|
|
|
|
- // "utcOffsetMinutes": 0
|
|
|
|
- // }
|
|
|
|
- // },
|
|
|
|
- // 'videoId': url.replace('https://www.youtube.com/watch?v=', ''),
|
|
|
|
- // "playbackContext": {
|
|
|
|
- // "contentPlaybackContext": {
|
|
|
|
- // "html5Preference": "HTML5_PREF_WANTS"
|
|
|
|
- // }
|
|
|
|
- // },
|
|
|
|
- // "contentCheckOk": true,
|
|
|
|
- // "racyCheckOk": true
|
|
|
|
- // }), {
|
|
|
|
- // 'Host': 'www.youtube.com',
|
|
|
|
- // 'Connection': 'keep-alive',
|
|
|
|
- // 'User-Agent': 'com.google.ios.youtube/19.09.3 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)',
|
|
|
|
- // 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
|
|
- // 'Accept-Language': 'en-us,en;q=0.5',
|
|
|
|
- // 'Sec-Fetch-Mode': 'navigate',
|
|
|
|
- // 'X-YouTube-Client-Name': '5',
|
|
|
|
- // 'X-YouTube-Client-Version': '19.09.3',
|
|
|
|
- // 'Origin': 'https://www.youtube.com',
|
|
|
|
- // 'Accept-Encoding': 'gzip, deflate, br',
|
|
|
|
- // 'Cookie': parseSetCookie(htmlHeaders),
|
|
|
|
- // 'Content-Type': 'application/json'
|
|
|
|
- // }, platform);
|
|
|
|
- // let {data: apiData, _} = apiResp;
|
|
|
|
- // console.log(`ios 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"] = "ios"
|
|
|
|
- // currentFormats.push(format);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // originFormats = originFormats.concat(currentFormats);
|
|
|
|
- // } catch (e) {
|
|
|
|
- // console.log(`can not found format ios api error: ${e}`);
|
|
|
|
- // }
|
|
|
|
- // console.log(`after ios api, format size:${originFormats.length}`);
|
|
|
|
-
|
|
|
|
const baseJsUrl = `https://www.youtube.com${JSON.parse(html.match(/set\(({.+?})\);/)[1])["PLAYER_JS_URL"]}`
|
|
const baseJsUrl = `https://www.youtube.com${JSON.parse(html.match(/set\(({.+?})\);/)[1])["PLAYER_JS_URL"]}`
|
|
let formatIds = [];
|
|
let formatIds = [];
|
|
const formats = [];
|
|
const formats = [];
|
|
@@ -470,7 +362,7 @@ detail = async (url, platform) => {
|
|
"author": originVideoDetails["author"],
|
|
"author": originVideoDetails["author"],
|
|
"channelID": originVideoDetails["channelId"],
|
|
"channelID": originVideoDetails["channelId"],
|
|
"recommendInfo": recommendInfo,
|
|
"recommendInfo": recommendInfo,
|
|
- "channelURL": 'https://www.yo' + 'utub' + 'e.com/ch' + `annel/${originVideoDetails["channelId"]}`,
|
|
|
|
|
|
+ "channelURL": `https://www.youtube.com/channel/${originVideoDetails["channelId"]}`,
|
|
"videoId": originVideoDetails["videoId"]
|
|
"videoId": originVideoDetails["videoId"]
|
|
}
|
|
}
|
|
const ret = {
|
|
const ret = {
|
|
@@ -553,7 +445,7 @@ search = async (keyword, next, platform) => {
|
|
console.log(`[next] search result: ${JSON.stringify(ret)}`);
|
|
console.log(`[next] search result: ${JSON.stringify(ret)}`);
|
|
return ret;
|
|
return ret;
|
|
} else {
|
|
} else {
|
|
- let url = 'https://ww' + 'w.yo' + 'utube.co' + 'm/re' + `sults?q=${encodeURIComponent(keyword)}&sp=EgIQAQ%253D%253D`;
|
|
|
|
|
|
+ let url = `https://www.youtube.com/results?q=${encodeURIComponent(keyword)}&sp=EgIQAQ%253D%253D`;
|
|
|
|
|
|
const htmlRes = await request('GET', url, null, {}, platform);
|
|
const htmlRes = await request('GET', url, null, {}, platform);
|
|
const {data: html, _} = htmlRes;
|
|
const {data: html, _} = htmlRes;
|