Browse Source

fix: extract

Ben 9 months ago
parent
commit
1bba3436b9

File diff suppressed because it is too large
+ 0 - 0
js/pornhub.bundle.js


File diff suppressed because it is too large
+ 0 - 0
js/tiktok.bundle.js


File diff suppressed because it is too large
+ 0 - 0
js/xvideos.bundle.js


File diff suppressed because it is too large
+ 0 - 0
js/youtube.bundle.js


File diff suppressed because it is too large
+ 4 - 8693
js/youtube/base.js


+ 4 - 4
js/youtube/extract_function.js

@@ -6,15 +6,15 @@ extractFunction = (jsCode, regexp) => {
         return null;
     }
     let result = "";
-    const dependencyMatchs = match[0].match(/([$a-zA-Z0-9]+\.[$a-zA-Z0-9]+)/g)
+    const dependencyMatches = match[0].match(/([$a-zA-Z0-9]+\.[$a-zA-Z0-9]+)/g)
     const existDependencies = [];
-    if (dependencyMatchs && dependencyMatchs.length >= 1) {
-        for (let currentMatch of dependencyMatchs) {
+    if (dependencyMatches && dependencyMatches.length >= 1) {
+        for (let currentMatch of dependencyMatches) {
             const varName = currentMatch.split('.')[0];
             if (existDependencies.includes(varName)) {
                 continue
             }
-            if (!/^[$A-Z]+$/.test(varName)) {
+            if (!/^[$A-Z][A-Z|a-z]+$/.test(varName)) {
                 continue
             }
             let reg = "var (\$)?" + varName + "={(.|\\n)*?};"

+ 17 - 17
js/youtube/test.js

@@ -1,23 +1,23 @@
-// detail(`https://www.youtube.com/watch?v=DYptgVvkVLQ`, 'WEB')
-//     .then(res => {
-//         console.log(res);
-//     })
-//     .catch(e => {
-//         console.log(e);
-//     })
-
-search("billboard pop songs 2024", null, "WEB")
+detail(`https://www.youtube.com/watch?v=DYptgVvkVLQ`, 'WEB')
     .then(res => {
         console.log(res);
-
-        search("trump gets mercilessly booed at speech", res["data"]["next"], "WEB")
-            .then(res => {
-                console.log(res);
-            })
-            .catch(e => {
-                console.log(e);
-            })
     })
     .catch(e => {
         console.log(e);
     })
+
+// search("billboard pop songs 2024", null, "WEB")
+//     .then(res => {
+//         console.log(res);
+//
+//         search("trump gets mercilessly booed at speech", res["data"]["next"], "WEB")
+//             .then(res => {
+//                 console.log(res);
+//             })
+//             .catch(e => {
+//                 console.log(e);
+//             })
+//     })
+//     .catch(e => {
+//         console.log(e);
+//     })

+ 17 - 2
js/youtube/youtube.js

@@ -141,7 +141,7 @@ findFunction = (jsCode, regexp, platform) => {
             if (existDependencies.includes(varName)) {
                 continue
             }
-            if (!/^[$A-Z]+$/.test(varName)) {
+            if (!/^[$A-Z][A-Z|a-z]+$/.test(varName)) {
                 continue
             }
             let reg = "var (\$)?" + varName + "={(.|\\n)*?};"
@@ -326,6 +326,20 @@ detail = async (url, platform) => {
         console.log(`after html, format size:${originFormats.length}`);
 
         const baseJsUrl = `https://www.youtube.com${JSON.parse(html.match(/set\(({.+?})\);/)[1])["PLAYER_JS_URL"]}`
+        let audioUrl = ""
+        for (let format of originFormats) {
+            if (!format["url"]) {
+                format["url"] = await signUrl(format["signatureCipher"], baseJsUrl, platform);
+            }
+            if (format["url"]) {
+                const {vcodec, acodec} = parseCodecs(format)
+                if (!vcodec && acodec) {
+                    audioUrl = format["url"]
+                    break
+                }
+            }
+        }
+
         let formatIds = [];
         const formats = [];
         for (let format of originFormats) {
@@ -354,7 +368,8 @@ detail = async (url, platform) => {
                             "vbr": "0",
                             "abr": "0",
                             "container": "mp4_dash",
-                            "from": format["from"]
+                            "from": format["from"],
+                            "audioUrl": audioUrl
                         }
                         if (platform === "WEB") {
                             current["source"] = format

Some files were not shown because too many files changed in this diff