diff --git a/.github/workflows/company-export.yml b/.github/workflows/company-export.yml index 6076bdc43..a9d101edb 100644 --- a/.github/workflows/company-export.yml +++ b/.github/workflows/company-export.yml @@ -98,13 +98,13 @@ jobs: env: COMPANY_PROV_UUID: ${{ secrets.COMPANY_PROV_UUID }} COMPANY_P12_NAME: ${{ secrets.COMPANY_P12_NAME }} - run: | - xcodebuild archive -project ./DarockBili.xcodeproj -scheme 'DarockBili Watch App' -archivePath ./build.xcarchive -IDEPostProgressNotifications=YES CODE_SIGN_IDENTITY=- AD_HOC_CODE_SIGNING_ALLOWED=YES CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=H5SM6ZV38F COMPILER_INDEX_STORE_ENABLE=NO + run: xcodebuild archive -project ./DarockBili.xcodeproj -scheme 'DarockBili Watch App' -archivePath ./build.xcarchive -IDEPostProgressNotifications=YES CODE_SIGN_IDENTITY=- AD_HOC_CODE_SIGNING_ALLOWED=YES CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=H5SM6ZV38F COMPILER_INDEX_STORE_ENABLE=NO -quiet - name: Export IPA File run: | xcodebuild -exportArchive -archivePath ./build.xcarchive -exportPath ./ -exportOptionsPlist ./ExportOptions/ad-hoc.plist -DVTProvisioningIsManaged=YES -DVTSkipCertificateValidityCheck=YES mv '喵哩喵哩.ipa' DarockBili_Company.ipa + echo "FIN_STATUS=success" >> $GITHUB_ENV - name: Upload IPA File uses: actions/upload-artifact@v3 diff --git a/DarockBili Watch App/DarockBiliApp.swift b/DarockBili Watch App/DarockBiliApp.swift index 91fdb3db1..139ef8a2b 100644 --- a/DarockBili Watch App/DarockBiliApp.swift +++ b/DarockBili Watch App/DarockBiliApp.swift @@ -325,3 +325,6 @@ public func updateBuvid() { } } } + + + diff --git a/DarockBili Watch App/Errors/NetworkFixView.swift b/DarockBili Watch App/Errors/NetworkFixView.swift index 52914bcee..4e33fb338 100644 --- a/DarockBili Watch App/Errors/NetworkFixView.swift +++ b/DarockBili Watch App/Errors/NetworkFixView.swift @@ -444,18 +444,14 @@ let errorCodeTextDic = [ -8888: "对不起,服务器开小差了~" ] -public func CheckBApiError(from input: JSON) -> Bool { +public func CheckBApiError(from input: JSON, noTip: Bool = false) -> Bool { let code = input["code"].int ?? 0 if code == 0 { return true } let msg = errorCodeTextDic[code] ?? (input["message"].string ?? "") - tipWithText(msg, symbol: "xmark.circle.fill") - let headers: HTTPHeaders = [ - "User-Agent": "Mozilla/5.0" - ] - DarockKit.Network.shared.requestString("https://api.bilibili.com/x/web-interface/zone", headers: headers) { respStr, _ in - DarockKit.Network.shared.requestString("https://api.darock.top/bili/error/upload/\("Code: \(code)|Message: \(msg)|Build: \(Bundle.main.infoDictionary?["CFBundleVersion"] as! String)|IsLoggedIn: \((UserDefaults.standard.string(forKey: "DedeUserID") ?? "") == "" ? "Yes" : "No")|Loc: \(respStr)".base64Encoded().replacingOccurrences(of: "/", with: "{slash}"))") { _, _ in return} + if !noTip { + tipWithText(msg, symbol: "xmark.circle.fill") } return false } diff --git a/DarockBili Watch App/Extension/CodeExt.swift b/DarockBili Watch App/Extension/CodeExt.swift index 34ad643ad..308fe1e12 100644 --- a/DarockBili Watch App/Extension/CodeExt.swift +++ b/DarockBili Watch App/Extension/CodeExt.swift @@ -138,6 +138,31 @@ public func hideDigitalTime(_ b: Bool) { app._setStatusBarTimeHidden(b, animated: true, completion: nil) } +// MARK: Networking +public func autoRetryRequestApi(_ url: String, headers: HTTPHeaders?, maxReqCount: Int = 10, callback: @escaping (JSON, Bool) -> Void) { + var retryCount = 0 + DispatchQueue.global().async { + sigReq(url, headers: headers, maxReqCount: maxReqCount, callback: callback) + } + + func sigReq(_ url: String, headers: HTTPHeaders?, maxReqCount: Int = 10, callback: @escaping (JSON, Bool) -> Void) { + DarockKit.Network.shared.requestJSON(url, headers: headers) { respJson, isSuccess in + if isSuccess { + if CheckBApiError(from: respJson, noTip: true) { // Requesting succeed + callback(respJson, true) + } else if retryCount < maxReqCount { // Failed but can retry + retryCount++ + sigReq(url, headers: headers, maxReqCount: maxReqCount, callback: callback) + } else { // Failed and not able to retry, callback json for next level code processing error. + callback(respJson, true) + } + } else { + callback(respJson, isSuccess) + } + } + } +} + func biliWbiSign(paramEncoded: String, completion: @escaping (String?) -> Void) { func getMixinKey(orig: String) -> String { return String(mixinKeyEncTab.map { orig[orig.index(orig.startIndex, offsetBy: $0)] }.prefix(32)) @@ -267,6 +292,333 @@ func bv2av(bvid: String) -> UInt64 { return (tmp & MASK_CODE) ^ XOR_CODE } +// MARK: Get buvid_fp cookie +enum BuvidFpError: Error { + case readError +} + +struct BuvidFp { + static func gen(key: String, seed: UInt32) throws -> String { + let m = try murmur3_x64_128(key: key, seed: seed) + return String(format: "%016llx%016llx", m.low, m.high) + } + + private static func murmur3_x64_128(key: String, seed: UInt32) throws -> UInt128 { + let C1: UInt64 = 0x87c3_7b91_1142_53d5 + let C2: UInt64 = 0x4cf5_ad43_2745_937f + let C3: UInt64 = 0x52dc_e729 + let C4: UInt64 = 0x3849_5ab5 + let R1: UInt32 = 27 + let R2: UInt32 = 31 + let R3: UInt32 = 33 + let M: UInt64 = 5 + + var h1: UInt64 = UInt64(seed) + var h2: UInt64 = UInt64(seed) + var processed: Int = 0 + var index = key.startIndex + + var buf = [UInt8](repeating: 0, count: 16) + + while index < key.endIndex { + let remaining = key.distance(from: index, to: key.endIndex) + let read = min(remaining, 16) + + _ = key.withCString { cString in + // Using withCString to convert the Swift String to a C-style string + memcpy(&buf, cString + index.utf16Offset(in: key), read) + } + + processed += read + if read == 16 { + let k1 = UInt64(bitPattern: Int64(littleEndianBytes: buf[0..<8])) + let k2 = UInt64(bitPattern: Int64(littleEndianBytes: buf[8..<16])) + + h1 ^= k1.multipliedFullWidth(by: C1).high &<< R2 + h1 = h1 &<< R1 &+ h2 &* M &+ C3 + h2 ^= k2.multipliedFullWidth(by: C2).high &<< R3 + h2 = h2 &<< R2 &+ h1 &* M &+ C4 + } else if read == 0 { + h1 ^= UInt64(processed) + h2 ^= UInt64(processed) + h1 = h1 &+ h2 + h2 = h2 &+ h1 + h1 = fmix64(k: h1) + h2 = fmix64(k: h2) + h1 = h1 &+ h2 + h2 = h2 &+ h1 + + let x: UInt128 = UInt128(high: h2, low: h1) + return x + } else { + var k1: UInt64 = 0 + var k2: UInt64 = 0 + + if read >= 15 { k2 ^= UInt64(buf[14]) &<< 48 } + if read >= 14 { k2 ^= UInt64(buf[13]) &<< 40 } + if read >= 13 { k2 ^= UInt64(buf[12]) &<< 32 } + if read >= 12 { k2 ^= UInt64(buf[11]) &<< 24 } + if read >= 11 { k2 ^= UInt64(buf[10]) &<< 16 } + if read >= 10 { k2 ^= UInt64(buf[9]) &<< 8 } + if read >= 9 { + k2 ^= UInt64(buf[8]) + k2 = k2.multipliedFullWidth(by: C2).high &<< 33 + k2 = k2.multipliedFullWidth(by: C1).high &<< 32 + h2 ^= k2 + } + if read >= 8 { k1 ^= UInt64(buf[7]) &<< 56 } + if read >= 7 { k1 ^= UInt64(buf[6]) &<< 48 } + if read >= 6 { k1 ^= UInt64(buf[5]) &<< 40 } + if read >= 5 { k1 ^= UInt64(buf[4]) &<< 32 } + if read >= 4 { k1 ^= UInt64(buf[3]) &<< 24 } + if read >= 3 { k1 ^= UInt64(buf[2]) &<< 16 } + if read >= 2 { k1 ^= UInt64(buf[1]) &<< 8 } + if read >= 1 { k1 ^= UInt64(buf[0]) } + + k1 = k1.multipliedFullWidth(by: C1).high &<< 31 + k1 = k1.multipliedFullWidth(by: C2).high &<< 32 + h1 ^= k1 + } + + index = key.index(index, offsetBy: read) + } + + throw BuvidFpError.readError + } + + private static func fmix64(k: UInt64) -> UInt64 { + let C1: UInt64 = 0xff51_afd7_ed55_8ccd + let C2: UInt64 = 0xc4ce_b9fe_1a85_ec53 + let R: UInt32 = 33 + var tmp = k + tmp ^= tmp &>> R + tmp = tmp.multipliedFullWidth(by: C1).high + tmp ^= tmp &>> R + tmp = tmp.multipliedFullWidth(by: C2).high + tmp ^= tmp &>> R + return tmp + } +} + +extension Int64 { + init(littleEndianBytes bytes: ArraySlice) { + self = Int64(bitPattern: UInt64(littleEndianBytes: bytes)) + } +} + +extension UInt64 { + init(littleEndianBytes bytes: ArraySlice) { + var value: UInt64 = 0 + withUnsafeMutableBytes(of: &value) { buffer in + for (index, byte) in bytes.enumerated() { + buffer[index] = byte + } + } + self = UInt64(littleEndian: value) + } +} + +struct UInt128 { + let low: UInt64 + let high: UInt64 + + init(high: UInt64, low: UInt64) { + self.high = high + self.low = low + } + + static func &<< (lhs: UInt128, rhs: UInt64) -> UInt128 { + if rhs == 0 { + return lhs + } else if rhs < 64 { + return UInt128(high: lhs.high << rhs | lhs.low >> (64 - rhs), low: lhs.low << rhs) + } else if rhs < 128 { + return UInt128(high: lhs.low << (rhs - 64), low: 0) + } else { + return UInt128(high: 0, low: 0) + } + } +} + +// MARK: Get _uuid cookie +struct UuidInfoc { + static func gen() -> String { + let digitMap: [String] = [ + "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "10" + ] + let t = Int64(Date().timeIntervalSince1970 * 1000) % 100_000 + + return randomChoice(range: [8, 4, 4, 4, 12], separator: "-", choices: digitMap) + String(format: "%05d", t) + "infoc" + } +} + +func randomChoice(range: [Int], separator: String, choices: [String]) -> String { + var result = "" + + for r in range { + for _ in 0.. Void) { + let _uuid = UuidInfoc.gen() + let postParams: [String: Any] = [ + "3064":1, // ptype, mobile => 2, others => 1 + "5062":Date.now.milliStamp, // timestamp + "03bf":url, // url accessed + "39c8":"333.1007.fp.risk", // spm_id, + "34f1":"", // target_url, default empty now + "d402":"", // screenx, default empty + "654a":"", // screeny, default empty + "6e7c":"3440x1440", // browser_resolution, window.innerWidth || document.body && document.body.clientWidth + "x" + window.innerHeight || document.body && document.body.clientHeight + "3c43":[ // 3c43 => msg + "2673":1, // hasLiedResolution, window.screen.width < window.screen.availWidth || window.screen.height < window.screen.availHeight + "5766":24, // colorDepth, window.screen.colorDepth + "6527":0, // addBehavior, !!window.HTMLElement.prototype.addBehavior, html5 api + "7003":1, // indexedDb, !!window.indexedDB, html5 api + "807e":1, // cookieEnabled, navigator.cookieEnabled + "b8ce":"Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebK…KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", // ua + "641c":0, // webdriver, navigator.webdriver, like Selenium + "07a4":"zh-CN", // language + "1c57":4, // deviceMemory in GB, navigator.deviceMemory + "0bd0":4, // hardwareConcurrency, navigator.hardwareConcurrency + "748e":[ + 3440, // window.screen.width + 1440 // window.screen.height + ], // screenResolution + "d61f":[ + 3440, // window.screen.availWidth + 1440 // window.screen.availHeight + ], // availableScreenResolution + "fc9d":-480, // timezoneOffset, (new Date).getTimezoneOffset() + "6aa9":"Asia/Shanghai", // timezone, (new window.Intl.DateTimeFormat).resolvedOptions().timeZone + "75b8":1, // sessionStorage, window.sessionStorage, html5 api + "3b21":1, // localStorage, window.localStorage, html5 api + "8a1c":0, // openDatabase, window.openDatabase, html5 api + "d52f":"not available", // cpuClass, navigator.cpuClass + "adca":"Win32", // platform, navigator.platform + "80c9":[ + [ + "PDF Viewer", + "Portable Document Format", + [ + [ + "application/pdf", + "pdf" + ], + [ + "text/pdf", + "pdf" + ] + ] + ], + [ + "Chrome PDF Viewer", + "Portable Document Format", + [ + [ + "application/pdf", + "pdf" + ], + [ + "text/pdf", + "pdf" + ] + ] + ], + [ + "Chromium PDF Viewer", + "Portable Document Format", + [ + [ + "application/pdf", + "pdf" + ], + [ + "text/pdf", + "pdf" + ] + ] + ], + [ + "Microsoft Edge PDF Viewer", + "Portable Document Format", + [ + [ + "application/pdf", + "pdf" + ], + [ + "text/pdf", + "pdf" + ] + ] + ], + [ + "WebKit built-in PDF", + "Portable Document Format", + [ + [ + "application/pdf", + "pdf" + ], + [ + "text/pdf", + "pdf" + ] + ] + ] + ], // plugins + "13ab":"mTUAAAAASUVORK5CYII=", // canvas fingerprint + "bfe9":"aTot0S1jJ7Ws0JC6QkvAL/A4H1PbV+/QA3AAAAAElFTkSuQmCC", // webgl_str + "a3c1":[], // webgl_params, cab be set to [] if webgl is not supported + "6bc5":"Broadcom~V3D 4.2", // webglVendorAndRenderer + "ed31":0, // hasLiedLanguages + "72bd":0, // hasLiedOs + "097b":0, // hasLiedBrowser + "52cd":[ + 0, // void 0 !== navigator.maxTouchPoints ? t = navigator.maxTouchPoints : void 0 !== navigator.msMaxTouchPoints && (t = navigator.msMaxTouchPoints); + 0, // document.createEvent("TouchEvent"), if succeed 1 else 0 + 0 // "ontouchstart" in window ? 1 : 0 + ], // touch support + "a658":[ + "Arial", + "Courier", + "Courier New", + "Helvetica", + "Times", + "Times New Roman" + ], // font details. see https://github.com/fingerprintjs/fingerprintjs for implementation details + "d02f":"124.04347527516074" // audio fingerprint. see https://github.com/fingerprintjs/fingerprintjs for implementation details + ], + "54ef":"{\"b_ut\":\"7\",\"home_version\":\"V8\",\"i-wanna-go-back\":\"-1\",\"in_new_ab\":true,\"ab_version\":{\"for_ai_home_version\":\"V8\",\"tianma_banner_inline\":\"CONTROL\",\"enable_web_push\":\"DISABLE\"},\"ab_split_num\":{\"for_ai_home_version\":54,\"tianma_banner_inline\":54,\"enable_web_push\":10}}", // abtest info, embedded in html + "8b94":"", // refer_url, document.referrer ? encodeURIComponent(document.referrer).substr(0, 1e3) : "" + "df35":_uuid, // _uuid, set from cookie, generated by client side(algorithm remains unknown) + "07a4":"zh-CN", // language + "5f45":0, // laboratory, set from cookie, null if empty, source remains unknown + "db46":0 // is_selfdef, default 0 + ] + DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/frontend/finger/spi") { respJson, isSuccess in + if isSuccess { + let buvid3 = respJson["data"]["b_3"].string ?? "" + let buvid4 = respJson["data"]["b_4"].string ?? "" + let postHeaders: HTTPHeaders = [ + "cookie": "innersign=0; buvid3=\(buvid3); b_nut=\(Date.now.timeStamp); i-wanna-go-back=-1; b_ut=7; b_lsid=9910433CB_18CF260AB89; _uuid=\(_uuid); enable_web_push=DISABLE; header_theme_version=undefined; home_feed_column=4; browser_resolution=3440-1440; buvid4=\(buvid4); buvid_fp=e651c1a382430ea93631e09474e0b395" + ] + AF.request("https://api.bilibili.com/x/internal/gaia-gateway/ExClimbWuzhi", method: .post, parameters: postParams, encoding: JSONEncoding.default, headers: postHeaders).response { response in + callback(buvid3, buvid4, _uuid, response.debugDescription) + } + } + } +} + postfix operator ++ postfix operator -- prefix operator ++ diff --git a/DarockBili Watch App/InMain/MainView.swift b/DarockBili Watch App/InMain/MainView.swift index 42d6e7c77..7371a4272 100644 --- a/DarockBili Watch App/InMain/MainView.swift +++ b/DarockBili Watch App/InMain/MainView.swift @@ -67,8 +67,6 @@ struct MainView: View { List { Section { if debug { - Text("Debug Version. DO NOT Release!!") - .bold() Button(action: { tipWithText("Test") // Dynamic.PUICApplication.sharedPUICApplication._setStatusBarTimeHidden(true, animated: false, completion: nil) diff --git a/DarockBili Watch App/Others/AboutView.swift b/DarockBili Watch App/Others/AboutView.swift index 27a355d8d..28ba610f3 100644 --- a/DarockBili Watch App/Others/AboutView.swift +++ b/DarockBili Watch App/Others/AboutView.swift @@ -25,6 +25,10 @@ struct AboutView: View { Section { Text("喵哩喵哩 v\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String) Build \(Bundle.main.infoDictionary?["CFBundleVersion"] as! String)") Text("编译时间: \(CodingTime.getCodingTime())") + .onTapGesture(count: 9) { + debug = true + tipWithText("You're now in Developer Mode", symbol: "hammer.circle.fill") + } Text("遇到问题?在设置页面点击“反馈问题”进行反馈,感谢您的支持!") } Section(header: Text("Credits")) { @@ -32,7 +36,6 @@ struct AboutView: View { Text("Darock Studio") Label("来自 \(Text("Darock Studio").bold()) 的消息:欢迎加群 248036605 获取最新消息谢谢喵!", systemImage: "arrowshape.up") } - Text("ThreeManager785") Text("Lightning-Lion") Text("Linecom") Text("-- And You --") @@ -42,11 +45,6 @@ struct AboutView: View { Text("开源组件许可") }) } - //Section { - // NavigationLink(destination: {DebugUITestView()}, label: { - // Text("调试") - // }) - //} } .bold() } @@ -109,16 +107,6 @@ struct AboutView: View { } } -struct DebugUITestView: View { - var body: some View { - List { - NavigationLink(destination: {UserDetailView(uid: "3546572635768935")}, label: { - Text("LongUIDUserTest") - }) - } - } -} - struct AboutView_Previews: PreviewProvider { static var previews: some View { AboutView() diff --git a/DarockBili Watch App/Others/SettingsView.swift b/DarockBili Watch App/Others/SettingsView.swift index 8d3a25f69..af6969c5d 100644 --- a/DarockBili Watch App/Others/SettingsView.swift +++ b/DarockBili Watch App/Others/SettingsView.swift @@ -93,7 +93,22 @@ struct SettingsView: View { }) } - + if debug { + Section { + NavigationLink(destination: {DebugMenuView()}, label: { + HStack { + ZStack { + Color.blue + .frame(width: 20, height: 20) + .clipShape(Circle()) + Image(systemName: "hammer.fill") + .font(.system(size: 12)) + } + Text("开发者") + } + }) + } + } } .navigationTitle("设置") .navigationBarTitleDisplayMode(.large) @@ -299,6 +314,86 @@ struct SettingsView: View { } } } + struct DebugMenuView: View { + var body: some View { + List { + NavigationLink(destination: {UserDetailView(uid: "3546572635768935")}, label: { + Text("LongUIDUserTest") + }) + NavigationLink(destination: {BuvidFpDebug()}, label: { + Text("buvid_fpTest") + }) + NavigationLink(destination: {UuidDebug()}, label: { + Text("_uuid_Gen") + }) + NavigationLink(destination: {Buvid34Debug()}, label: { + Text("buvid3_4_actived") + }) + } + } + + struct BuvidFpDebug: View { + @State var fp = "" + @State var resu = "" + var body: some View { + List { + TextField("fp", text: $fp) + Button(action: { + do { + resu = try BuvidFp.gen(key: fp, seed: 31) + } catch { + resu = "Failed: \(error)" + } + }, label: { + Text("Gen") + }) + Text(resu) + } + } + } + struct UuidDebug: View { + @State var uuid = "" + var body: some View { + List { + Button(action: { + uuid = UuidInfoc.gen() + }, label: { + Text("Gen") + }) + Text(uuid) + } + } + } + struct Buvid34Debug: View { + @State var activeBdUrl = "https://www.bilibili.com/" + @State var locBuvid3 = "" + @State var locBuvid4 = "" + @State var locUplResp = "" + var body: some View { + List { + Section { + Text("Current Global Buvid3: \(globalBuvid3)") + Text("Current Global Buvid4: \(globalBuvid4)") + } + Section { + TextField("activeBdUrl", text: $activeBdUrl) + Button(action: { + getBuvid(url: activeBdUrl.urlEncoded()) { buvid3, buvid4, _, resp in + locBuvid3 = buvid3 + locBuvid4 = buvid4 + locUplResp = resp + } + }, label: { + Text("Get new & active") + }) + Text(locBuvid3) + Text(locBuvid4) + Text(locUplResp) + } + } + } + } + } } } diff --git a/DarockBili Watch App/PersonalCenter/PersonAccountView.swift b/DarockBili Watch App/PersonalCenter/PersonAccountView.swift index 2b2de4ce1..3c39a0211 100644 --- a/DarockBili Watch App/PersonalCenter/PersonAccountView.swift +++ b/DarockBili Watch App/PersonalCenter/PersonAccountView.swift @@ -223,33 +223,28 @@ struct PersonAccountView: View { .navigationTitle("我的") .navigationBarTitleDisplayMode(.large) .onAppear { - let headers: HTTPHeaders = [ - "cookie": "SESSDATA=\(sessdata);", - "User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" - ] - DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/member/web/account", headers: headers) { respJson, isSuccess in - if isSuccess { - if !CheckBApiError(from: respJson) { return } - username = respJson["data"]["uname"].string ?? "" - userSign = respJson["data"]["sign"].string ?? "" - } else { - isNetworkFixPresented = true - } - } - biliWbiSign(paramEncoded: "mid=\(dedeUserID)".base64Encoded()) { signed in - if let signed { - debugPrint(signed) - DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/acc/info?\(signed)", headers: headers) { respJson, isSuccess in - if isSuccess { - debugPrint(respJson) - if !CheckBApiError(from: respJson) { return } - userFaceUrl = respJson["data"]["face"].string ?? "E" - } else { - isNetworkFixPresented = true + if username == "" { + getBuvid(url: "https://api.bilibili.com/x/space/wbi/acc/info".urlEncoded()) { buvid3, buvid4, _uuid, resp in + let headers: HTTPHeaders = [ + "cookie": "SESSDATA=\(sessdata); innersign=0; buvid3=\(buvid3); b_nut=1704873471; i-wanna-go-back=-1; b_ut=7; b_lsid=9910433CB_18CF260AB89; _uuid=\(_uuid); enable_web_push=DISABLE; header_theme_version=undefined; home_feed_column=4; browser_resolution=3440-1440; buvid4=\(buvid4);", + "User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" + ] + biliWbiSign(paramEncoded: "mid=\(dedeUserID)".base64Encoded()) { signed in + if let signed { + debugPrint(signed) + autoRetryRequestApi("https://api.bilibili.com/x/space/wbi/acc/info?\(signed)", headers: headers) { respJson, isSuccess in + if isSuccess { + debugPrint(respJson) + if !CheckBApiError(from: respJson) { return } + username = respJson["data"]["name"].string ?? "" + userSign = respJson["data"]["sign"].string ?? "" + userFaceUrl = respJson["data"]["face"].string ?? "E" + } else { + isNetworkFixPresented = true + } + } } } - } else { - isNetworkFixPresented = true } } } diff --git a/DarockBili Watch App/PersonalCenter/UserDetailView.swift b/DarockBili Watch App/PersonalCenter/UserDetailView.swift index 03453221d..09d6a2d6d 100644 --- a/DarockBili Watch App/PersonalCenter/UserDetailView.swift +++ b/DarockBili Watch App/PersonalCenter/UserDetailView.swift @@ -151,7 +151,7 @@ struct UserDetailView: View { biliWbiSign(paramEncoded: "mid=\(uid)".base64Encoded()) { signed in if let signed { debugPrint(signed) - DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/acc/info?\(signed)", headers: headers) { respJson, isSuccess in + autoRetryRequestApi("https://api.bilibili.com/x/space/wbi/acc/info?\(signed)", headers: headers) { respJson, isSuccess in if isSuccess { //debugPrint(respJson) if !CheckBApiError(from: respJson) { return } @@ -584,16 +584,17 @@ struct UserDetailView: View { //"accept-encoding": "gzip, deflate, br", //"accept-language": "zh-CN,zh;q=0.9", //"cookie": "\(sessdata == "" ? "" : "SESSDATA=\(sessdata); ")buvid3=\(globalBuvid3); b_nut=\(Date.now.timeStamp); buvid4=\(globalBuvid4);", - "cookie": "SESSDATA=\(sessdata);" + "cookie": "SESSDATA=\(sessdata); buvid_fp=e651c1a382430ea93631e09474e0b395", //"origin": "https://space.bilibili.com", //"referer": "https://space.bilibili.com/\(uid)/video", //"User-Agent": "Mozilla/5.0" // Bypass? drdar://gh/SocialSisterYi/bilibili-API-collect/issues/868/1859065874 + "User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebK…KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", ] // FIXME: Official Wbi crypto logic for this request seems different from other APIs, some IP can get but some can't. It's hard to fix ~_~ biliWbiSign(paramEncoded: "mid=\(uid)&ps=50&pn=\(videoNowPage)".base64Encoded()) { signed in if let signed { debugPrint(signed) - DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/arc/search?\(signed)", headers: headers) { respJson, isSuccess in + autoRetryRequestApi("https://api.bilibili.com/x/space/wbi/arc/search?\(signed)", headers: headers) { respJson, isSuccess in if isSuccess { debugPrint(respJson) if !CheckBApiError(from: respJson) { return } diff --git a/DarockBili.xcodeproj/project.pbxproj b/DarockBili.xcodeproj/project.pbxproj index 19d322a2d..cd9eb5a1e 100644 --- a/DarockBili.xcodeproj/project.pbxproj +++ b/DarockBili.xcodeproj/project.pbxproj @@ -800,6 +800,7 @@ INFOPLIST_FILE = "DarockBili-Watch-App-Info.plist"; INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; INFOPLIST_KEY_WKWatchOnly = YES; + INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -831,6 +832,7 @@ INFOPLIST_FILE = "DarockBili-Watch-App-Info.plist"; INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; INFOPLIST_KEY_WKWatchOnly = YES; + INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks",