Ben 11 luni în urmă
părinte
comite
4537fcb350
2 a modificat fișierele cu 26 adăugiri și 21 ștergeri
  1. 25 19
      js/info.js
  2. 1 2
      js/test.js

+ 25 - 19
js/info.js

@@ -86,6 +86,7 @@ getUrlFromSignature = (signatureCipher, baseContent) => {
     const decipher = getDecipherFunction(baseContent);
     const searchParams = new URLSearchParams(signatureCipher);
     const [url, signature, sp] = [searchParams.get("url"), searchParams.get("s"), searchParams.get("sp")];
+    console.log(signatureCipher, url, signature, sp);
     return `${url}&${sp}=${decipher(signature)}`;
 }
 
@@ -95,6 +96,7 @@ getDecipherFunction = (string) => {
     const beginningOfFunction =
         "var " + getStringBetween(top, `a=a.split("")`, "(", 10, 1).split(".")[0] + "=";
     const side = getStringBetween(js, beginningOfFunction, "};", 2, -beginningOfFunction.length);
+    console.log(side + top);
     return eval(side + top);
 };
 
@@ -136,25 +138,29 @@ detail = async (url, local) => {
     const formats = []
     for (let format of [].concat(ytInitialPlayerResponse["streamingData"]["formats"]).concat(ytInitialPlayerResponse["streamingData"]["adaptiveFormats"])) {
         console.log(format);
-        format.url = getUrlFromSignature(format["signatureCipher"], baseContent);
-        const {vcodec, acodec} = parseCodecs(format)
-        if (vcodec && acodec) {
-            formats.push({
-                "width": format["width"] + "",
-                "height": format["height"] + "",
-                "type": format["mimeType"],
-                "quality": format["quality"],
-                "itag": format["itag"],
-                "fps": format["fps"] + "",
-                "bitrate": format["bitrate"] + "",
-                "url": format["url"],
-                "ext": "mp4",
-                "vcodec": vcodec,
-                "acodec": acodec,
-                "vbr": "0",
-                "abr": "0",
-                "container": "mp4_dash"
-            })
+        if (!format["url"]) {
+            format["url"] = getUrlFromSignature(format["signatureCipher"], baseContent);
+        }
+        if (format["url"]) {
+            const {vcodec, acodec} = parseCodecs(format)
+            if (vcodec && acodec) {
+                formats.push({
+                    "width": format["width"] + "",
+                    "height": format["height"] + "",
+                    "type": format["mimeType"],
+                    "quality": format["quality"],
+                    "itag": format["itag"],
+                    "fps": format["fps"] + "",
+                    "bitrate": format["bitrate"] + "",
+                    "url": format["url"],
+                    "ext": "mp4",
+                    "vcodec": vcodec,
+                    "acodec": acodec,
+                    "vbr": "0",
+                    "abr": "0",
+                    "container": "mp4_dash"
+                })
+            }
         }
     }
 

+ 1 - 2
js/test.js

@@ -1,5 +1,4 @@
-const id = "7wNb0pHyGuI"
-const url = `https://www.youtube.com/watch?v=${id}`
+const url = `https://www.youtube.com/watch?v=qrGRv0uMuag`
 detail(url, true)
     .then(res => {
         console.log(res);