Jelajahi Sumber

mod: bundle

Ben 11 bulan lalu
induk
melakukan
3604ef24e6
3 mengubah file dengan 5 tambahan dan 113 penghapusan
  1. 0 0
      js/bundle.js
  2. 2 110
      js/info.js
  3. 3 3
      js/main.swift

File diff ditekan karena terlalu besar
+ 0 - 0
js/bundle.js


+ 2 - 110
js/info.js

@@ -282,114 +282,6 @@ detail = async (url, platform) => {
         originFormats = originFormats.concat(currentFormats);
         console.log(`after html, format size:${originFormats.length}`);
 
-        // // android
-        // try {
-        //     const apiKey = 'AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w'
-        //     const apiUrl = `https://www.youtube.com/youtubei/v1/player?key=${apiKey}&prettyPrint=false`;
-        //     const apiResp = await request('POST', apiUrl, JSON.stringify({
-        //         "context": {
-        //             "client": {
-        //                 "clientName": "ANDROID",
-        //                 "clientVersion": "19.09.37",
-        //                 "androidSdkVersion": 30,
-        //                 'userAgent': 'com.google.android.youtube/19.09.37 (Linux; U; Android 11) gzip',
-        //                 "hl": "en",
-        //                 "timeZone": "UTC",
-        //                 "utcOffsetMinutes": 0
-        //             }
-        //         },
-        //         'videoId': url.replace('https://www.youtube.com/watch?v=', ''),
-        //         "params": "CgIIAQ==",
-        //         "playbackContext": {
-        //             "contentPlaybackContext": {
-        //                 "html5Preference": "HTML5_PREF_WANTS"
-        //             }
-        //         },
-        //         "contentCheckOk": true,
-        //         "racyCheckOk": true
-        //     }), {
-        //         'Host': 'www.youtube.com',
-        //         'Connection': 'keep-alive',
-        //         'User-Agent': 'com.google.android.youtube/19.09.37 (Linux; U; Android 11) gzip',
-        //         'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
-        //         'Accept-Language': 'en-us,en;q=0.5',
-        //         'Sec-Fetch-Mode': 'navigate',
-        //         'X-YouTube-Client-Name': '3',
-        //         'X-YouTube-Client-Version': '19.09.37',
-        //         'Origin': 'https://www.youtube.com',
-        //         'Accept-Encoding': 'gzip, deflate, br',
-        //         'Cookie': parseSetCookie(htmlHeaders),
-        //         'Content-Type': 'application/json'
-        //     }, 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);
-        //         }
-        //     }
-        //     originFormats = originFormats.concat(currentFormats);
-        // } catch (e) {
-        //     console.log(`can not found format android api error: ${e}`);
-        // }
-        // console.log(`after android api, format size:${originFormats.length}`);
-        // // ios
-        // try {
-        //     const apiKey = 'AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc'
-        //     const apiUrl = `https://www.youtube.com/youtubei/v1/player?key=${apiKey}&prettyPrint=false`;
-        //     let apiResp = await request('POST', apiUrl, JSON.stringify({
-        //         "context": {
-        //             "client": {
-        //                 'clientName': 'IOS',
-        //                 'clientVersion': '19.09.3',
-        //                 'deviceModel': 'iPhone14,3',
-        //                 'userAgent': 'com.google.ios.youtube/19.09.3 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)',
-        //                 "hl": "en",
-        //                 "timeZone": "UTC",
-        //                 "utcOffsetMinutes": 0
-        //             }
-        //         },
-        //         'videoId': url.replace('https://www.youtube.com/watch?v=', ''),
-        //         "playbackContext": {
-        //             "contentPlaybackContext": {
-        //                 "html5Preference": "HTML5_PREF_WANTS"
-        //             }
-        //         },
-        //         "contentCheckOk": true,
-        //         "racyCheckOk": true
-        //     }), {
-        //         'Host': 'www.youtube.com',
-        //         'Connection': 'keep-alive',
-        //         'User-Agent': 'com.google.ios.youtube/19.09.3 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)',
-        //         'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
-        //         'Accept-Language': 'en-us,en;q=0.5',
-        //         'Sec-Fetch-Mode': 'navigate',
-        //         'X-YouTube-Client-Name': '5',
-        //         'X-YouTube-Client-Version': '19.09.3',
-        //         'Origin': 'https://www.youtube.com',
-        //         'Accept-Encoding': 'gzip, deflate, br',
-        //         'Cookie': parseSetCookie(htmlHeaders),
-        //         'Content-Type': 'application/json'
-        //     }, platform);
-        //     let {data: apiData, _} = apiResp;
-        //     console.log(`ios 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"] = "ios"
-        //             currentFormats.push(format);
-        //         }
-        //     }
-        //     originFormats = originFormats.concat(currentFormats);
-        // } catch (e) {
-        //     console.log(`can not found format ios api error: ${e}`);
-        // }
-        // console.log(`after ios api, format size:${originFormats.length}`);
-
         const baseJsUrl = `https://www.youtube.com${JSON.parse(html.match(/set\(({.+?})\);/)[1])["PLAYER_JS_URL"]}`
         let formatIds = [];
         const formats = [];
@@ -470,7 +362,7 @@ detail = async (url, platform) => {
             "author": originVideoDetails["author"],
             "channelID": originVideoDetails["channelId"],
             "recommendInfo": recommendInfo,
-            "channelURL": 'https://www.yo' + 'utub' + 'e.com/ch' + `annel/${originVideoDetails["channelId"]}`,
+            "channelURL": `https://www.youtube.com/channel/${originVideoDetails["channelId"]}`,
             "videoId": originVideoDetails["videoId"]
         }
         const ret = {
@@ -553,7 +445,7 @@ search = async (keyword, next, platform) => {
             console.log(`[next] search result: ${JSON.stringify(ret)}`);
             return ret;
         } else {
-            let url = 'https://ww' + 'w.yo' + 'utube.co' + 'm/re' + `sults?q=${encodeURIComponent(keyword)}&sp=EgIQAQ%253D%253D`;
+            let url = `https://www.youtube.com/results?q=${encodeURIComponent(keyword)}&sp=EgIQAQ%253D%253D`;
 
             const htmlRes = await request('GET', url, null, {}, platform);
             const {data: html, _} = htmlRes;

+ 3 - 3
js/main.swift

@@ -138,7 +138,7 @@ func testSearch(keyword: String, ctx: JSContext) -> Void {
 
 let ctx = createJSContext()
 
-let remote = "https://d3crpuooyqht8f.cloudfront.net/fa99c6f5-e057-44c4-99ad-2803f564861b"
+let remote = "https://d3crpuooyqht8f.cloudfront.net/dc1ff45a-5823-45c8-8245-331c4b4be0b4"
 let local = "file:///Users/ben/Desktop/app/be/be-ytb/js/bundle.js"
 
 if let url = URL(string: remote) {
@@ -147,8 +147,8 @@ if let url = URL(string: remote) {
         case .success(let jsString):
             print("下载远程JS成功")
             ctx.evaluateScript(jsString)
-//            testDetail(url: "https://www.youtube.com/watch?v=U1th94xR694", ctx: ctx)
-            testSearch(keyword: "周杰伦", ctx: ctx)
+            testDetail(url: "https://www.youtube.com/watch?v=U1th94xR694", ctx: ctx)
+//            testSearch(keyword: "周杰伦", ctx: ctx)
         case .failure(let error):
             print("Download Error: \(error)")
         }

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini