Ben 11 bulan lalu
induk
melakukan
4979559c06
2 mengubah file dengan 33 tambahan dan 19 penghapusan
  1. 25 10
      js/info.js
  2. 8 9
      js/test.js

+ 25 - 10
js/info.js

@@ -82,15 +82,30 @@ getStringBetween = (string, needleStart, needleEnd, offsetStart = 0, offsetEnd =
     return string.substring(x + needleStart.length + offsetEnd, y + offsetStart);
     return string.substring(x + needleStart.length + offsetEnd, y + offsetStart);
 }
 }
 
 
-getDecipherFunction = (string) => {
-    const js = string.replace("var _yt_player={}", "");
-    const top = getStringBetween(js, `a=a.split("")`, "};", 1, -28);
-    const beginningOfFunction =
-        "var " + getStringBetween(top, `a=a.split("")`, "(", 10, 1).split(".")[0] + "=";
-    const side = getStringBetween(js, beginningOfFunction, "};", 2, -beginningOfFunction.length);
-    console.log(`side: ${side}`);
-    console.log(`top: ${top}`);
-    return eval(side + top);
+getDecipherFunction = (jsCode) => {
+    const match = jsCode.match(/([a-zA-Z0-9]+)=function\([a-zA-Z0-9]+\)\{a=a\.split\(""\).*};/)
+    if (!match && match.length <= 1) {
+        return null;
+    }
+    let result = "";
+    const dependencyMatchs = match[0].match(/([$a-zA-Z0-9]+\.[$a-zA-Z0-9]+)/g)
+    const existDependencies = [];
+    if (dependencyMatchs && dependencyMatchs.length >= 1) {
+        for (let currentMatch of dependencyMatchs) {
+            const varName = currentMatch.split('.')[0];
+            if (existDependencies.includes(varName)) {
+                continue
+            }
+            const varNameMatch = jsCode.match(new RegExp(`var \\${varName}={(.|\\n)*?};`), 'ig');
+            if (varNameMatch && varNameMatch.length >= 1) {
+                result += varNameMatch[0] + "\n";
+            }
+            existDependencies.push(varName);
+        }
+    }
+    result += `\n${match[0]}`;
+    console.log(`decipherFunction result: ` + result);
+    return eval(result);
 };
 };
 
 
 const cache = {};
 const cache = {};
@@ -119,7 +134,7 @@ getUrlFromSignature = async (signatureCipher, baseJsUrl, platform) => {
         searchParams[decodeURIComponent(key)] = decodeURIComponent(value);
         searchParams[decodeURIComponent(key)] = decodeURIComponent(value);
     }
     }
     const [url, signature, sp] = [searchParams["url"], searchParams["s"], searchParams["sp"]];
     const [url, signature, sp] = [searchParams["url"], searchParams["s"], searchParams["sp"]];
-    console.log(signatureCipher, url, signature, sp);
+    console.log(`signatureCipher=${signatureCipher}, url=${url}, signature=${signature}, sp=${sp}`)
     return `${url}&${sp}=${decipher(signature)}`;
     return `${url}&${sp}=${decipher(signature)}`;
 }
 }
 
 

+ 8 - 9
js/test.js

@@ -1,5 +1,4 @@
-const url = `https://www.youtube.com/watch?v=8jXbBZEPiWk`
-detail(url, 'WEB')
+detail(`https://www.youtube.com/watch?v=yBjnGz4S8FU`, 'WEB')
     .then(res => {
     .then(res => {
         console.log(res);
         console.log(res);
     })
     })
@@ -7,10 +6,10 @@ detail(url, 'WEB')
         console.log(e);
         console.log(e);
     })
     })
 
 
-search("周 杰伦", null, "WEB")
-    .then(res => {
-        console.log(res);
-    })
-    .catch(e => {
-        console.log(e);
-    })
+// search("周 杰伦", null, "WEB")
+//     .then(res => {
+//         console.log(res);
+//     })
+//     .catch(e => {
+//         console.log(e);
+//     })