1
0

3 Ревизии 7ffad33874 ... a9d59be7d0

Автор SHA1 Съобщение Дата
  yemingfeng a9d59be7d0 Fix преди 2 месеца
  yemingfeng 1fbd2bcc66 Mod: format преди 2 месеца
  yemingfeng e5d2226b47 Add: fallback преди 2 месеца
променени са 6 файла, в които са добавени 102 реда и са изтрити 10 реда
  1. 0 0
      js/pornhub.bundle.js
  2. 0 0
      js/tiktok.bundle.js
  3. 0 0
      js/xvideos.bundle.js
  4. 0 0
      js/youtube.bundle.js
  5. 51 5
      js/youtube/youtubev1.js
  6. 51 5
      js/youtube/youtubev2.js

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
js/pornhub.bundle.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
js/tiktok.bundle.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
js/xvideos.bundle.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
js/youtube.bundle.js


+ 51 - 5
js/youtube/youtubev1.js

@@ -179,12 +179,12 @@ detail = async (url, requestId, platform) => {
             const apiResp = await request('POST', apiUrl, JSON.stringify({
                 "context": {
                     "client": {
-                        "clientVersion": "19.29.37",
+                        "clientVersion": "19.50.40",
                         "androidSdkVersion": 30,
                         "clientName": "ANDROID",
                         "osName": "android",
                         "osVersion": "11",
-                        "userAgent": "com.google.android.youtube/19.29.37 (Linux; U; Android 11) gzip"
+                        "userAgent": "com.google.android.youtube/19.50.40 (Linux; U; Android 11) gzip"
                     }
                 },
                 "videoId": url.replace('https://www.youtube.com/watch?v=', ''),
@@ -196,8 +196,8 @@ detail = async (url, requestId, platform) => {
                 "params": "2AMB"
             }), {
                 'Origin': "https://www.youtube.com",
-                'X-YouTube-Client-Version': '19.29.37',
-                'User-Agent': 'com.google.android.youtube/19.29.37 (Linux; U; Android 11) gzip',
+                'X-YouTube-Client-Version': '19.50.40',
+                'User-Agent': 'com.google.android.youtube/19.50.40 (Linux; U; Android 11) gzip',
                 'Content-Type': 'application/json'
             }, requestId, platform);
             let {data: apiData, _} = apiResp;
@@ -225,8 +225,54 @@ detail = async (url, requestId, platform) => {
         }
         console.log(`after android api, format size:${originFormats.length}`);
 
+        // fallback
+        let fallbackFormats = []
+        try {
+            const apiUrl = `https://www.youtube.com/youtubei/v1/player`;
+            const apiResp = await request('POST', apiUrl, JSON.stringify({
+                "contentCheckOk": true,
+                "context": {
+                    "client": {
+                        "clientName": "IOS",
+                        "clientVersion": "19.47.7",
+                        "deviceMake": "Apple",
+                        "deviceModel": "iPhone16,2",
+                        "hl": "en",
+                        "osName": "iPhone",
+                        "osVersion": "17.5.1.21F90",
+                        "timeZone": "UTC",
+                        "userAgent": "com.google.ios.youtube/19.47.7 (iPhone16,2; U; CPU iOS 17_5_1 like Mac OS X;)",
+                        "gl": "US",
+                        "utcOffsetMinutes": 0
+                    }
+                },
+                "videoId": url.replace('https://www.youtube.com/watch?v=', '')
+            }), {
+                'User-Agent': 'com.google.ios.youtube/19.47.7 (iPhone16,2; U; CPU iOS 17_5_1 like Mac OS X;)',
+                'Content-Type': 'application/json'
+            }, requestId, 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);
+                }
+            }
+            fallbackFormats = fallbackFormats.concat(currentFormats);
+        } catch (e) {
+            console.log(`can not found format android fallback api error: ${e}`);
+            // const ret = {
+            //     "code": -1, "msg": e.toString(), "requestId": requestId
+            // }
+            // console.log(`detail2 fallback result error: ${JSON.stringify(ret)}`);
+            // return ret;
+        }
+
         let audioUrl = ""
-        for (let format of [...originFormats].reverse()) {
+        for (let format of fallbackFormats) {
             if (format["url"]) {
                 const {vcodec, acodec} = parseCodecs(format)
                 if (!vcodec && acodec) {

+ 51 - 5
js/youtube/youtubev2.js

@@ -162,12 +162,12 @@ detail = async (url, requestId, platform) => {
             const apiResp = await request('POST', apiUrl, JSON.stringify({
                 "context": {
                     "client": {
-                        "clientVersion": "19.29.37",
+                        "clientVersion": "19.50.40",
                         "androidSdkVersion": 30,
                         "clientName": "ANDROID",
                         "osName": "android",
                         "osVersion": "11",
-                        "userAgent": "com.google.android.youtube/19.29.37 (Linux; U; Android 11) gzip"
+                        "userAgent": "com.google.android.youtube/19.50.40 (Linux; U; Android 11) gzip"
                     }
                 },
                 "videoId": url.replace('https://www.youtube.com/watch?v=', ''),
@@ -179,8 +179,8 @@ detail = async (url, requestId, platform) => {
                 "params": "2AMB"
             }), {
                 'Origin': "https://www.youtube.com",
-                'X-YouTube-Client-Version': '19.29.37',
-                'User-Agent': 'com.google.android.youtube/19.29.37 (Linux; U; Android 11) gzip',
+                'X-YouTube-Client-Version': '19.50.40',
+                'User-Agent': 'com.google.android.youtube/19.50.40 (Linux; U; Android 11) gzip',
                 'Content-Type': 'application/json'
             }, requestId, platform);
             let {data: apiData, _} = apiResp;
@@ -205,8 +205,54 @@ detail = async (url, requestId, platform) => {
         }
         console.log(`after android api, format size:${originFormats.length}`);
 
+        // fallback
+        let fallbackFormats = []
+        try {
+            const apiUrl = `https://www.youtube.com/youtubei/v1/player`;
+            const apiResp = await request('POST', apiUrl, JSON.stringify({
+                "contentCheckOk": true,
+                "context": {
+                    "client": {
+                        "clientName": "IOS",
+                        "clientVersion": "19.47.7",
+                        "deviceMake": "Apple",
+                        "deviceModel": "iPhone16,2",
+                        "hl": "en",
+                        "osName": "iPhone",
+                        "osVersion": "17.5.1.21F90",
+                        "timeZone": "UTC",
+                        "userAgent": "com.google.ios.youtube/19.47.7 (iPhone16,2; U; CPU iOS 17_5_1 like Mac OS X;)",
+                        "gl": "US",
+                        "utcOffsetMinutes": 0
+                    }
+                },
+                "videoId": url.replace('https://www.youtube.com/watch?v=', '')
+            }), {
+                'User-Agent': 'com.google.ios.youtube/19.47.7 (iPhone16,2; U; CPU iOS 17_5_1 like Mac OS X;)',
+                'Content-Type': 'application/json'
+            }, requestId, 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);
+                }
+            }
+            fallbackFormats = fallbackFormats.concat(currentFormats);
+        } catch (e) {
+            console.log(`can not found format android fallback api error: ${e}`);
+            // const ret = {
+            //     "code": -1, "msg": e.toString()
+            // }
+            // console.log(`detail2 fallback result error: ${JSON.stringify(ret)}`);
+            return ret;
+        }
+
         let audioUrl = ""
-        for (let format of originFormats) {
+        for (let format of fallbackFormats) {
             if (format["url"]) {
                 const {vcodec, acodec} = parseCodecs(format)
                 if (!vcodec && acodec) {

Някои файлове не бяха показани, защото твърде много файлове са промени