|
@@ -85,9 +85,9 @@ parseSetCookie = (headers) => {
|
|
|
}
|
|
|
|
|
|
request = async (method, url, data = null, headers = {}, platform) => {
|
|
|
- // if (platform === "WEB") {
|
|
|
- // url = url.replace("https://www.youtube.com", "http://127.0.0.1");
|
|
|
- // }
|
|
|
+ if (platform === "WEB") {
|
|
|
+ url = url.replace("https://www.youtube.com", "http://127.0.0.1");
|
|
|
+ }
|
|
|
console.log(`request url:${url}`)
|
|
|
console.log(`request data:${data}`)
|
|
|
console.log(`request method:${method}`)
|
|
@@ -152,7 +152,7 @@ findFunction = (jsCode, regexp, platform) => {
|
|
|
}
|
|
|
result += `\n${match[0]}`;
|
|
|
if (printable(platform)) {
|
|
|
- console.log(`decipherFunction result: ` + result);
|
|
|
+ console.log(`findFunction result: ` + result);
|
|
|
}
|
|
|
return eval(result);
|
|
|
};
|
|
@@ -274,6 +274,17 @@ detail = async (url, platform) => {
|
|
|
|
|
|
let originFormats = [];
|
|
|
|
|
|
+ // // web
|
|
|
+ // const currentFormats = [];
|
|
|
+ // for (const format of ytInitialPlayerResponse["streamingData"]["formats"].concat(ytInitialPlayerResponse["streamingData"]["adaptiveFormats"])) {
|
|
|
+ // if (format) {
|
|
|
+ // format["from"] = "web"
|
|
|
+ // currentFormats.push(format);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // originFormats = originFormats.concat(currentFormats);
|
|
|
+ // console.log(`after html, format size:${originFormats.length}`);
|
|
|
+
|
|
|
// android
|
|
|
try {
|
|
|
const apiKey = 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'
|
|
@@ -314,16 +325,6 @@ detail = async (url, platform) => {
|
|
|
}
|
|
|
console.log(`after android api, format size:${originFormats.length}`);
|
|
|
|
|
|
- const currentFormats = [];
|
|
|
- for (const format of ytInitialPlayerResponse["streamingData"]["formats"].concat(ytInitialPlayerResponse["streamingData"]["adaptiveFormats"])) {
|
|
|
- if (format) {
|
|
|
- format["from"] = "web"
|
|
|
- currentFormats.push(format);
|
|
|
- }
|
|
|
- }
|
|
|
- originFormats = originFormats.concat(currentFormats);
|
|
|
- console.log(`after html, format size:${originFormats.length}`);
|
|
|
-
|
|
|
const baseJsUrl = `https://www.youtube.com${JSON.parse(html.match(/set\(({.+?})\);/)[1])["PLAYER_JS_URL"]}`
|
|
|
let formatIds = [];
|
|
|
const formats = [];
|
|
@@ -332,9 +333,9 @@ detail = async (url, platform) => {
|
|
|
console.log(format);
|
|
|
}
|
|
|
if (format && formatIds.indexOf(format['itag']) === -1) {
|
|
|
- // if (!format["url"]) {
|
|
|
- // format["url"] = await signUrl(format["signatureCipher"], baseJsUrl, platform);
|
|
|
- // }
|
|
|
+ if (!format["url"]) {
|
|
|
+ format["url"] = await signUrl(format["signatureCipher"], baseJsUrl, platform);
|
|
|
+ }
|
|
|
if (format["url"]) {
|
|
|
const {vcodec, acodec} = parseCodecs(format)
|
|
|
if (vcodec && acodec) {
|