From f7c13803ba38f5a0b74ea5f516d97ff6ce378fa5 Mon Sep 17 00:00:00 2001 From: Mark Chan <45706356+WindowsMEMZ@users.noreply.github.com> Date: Sat, 6 Jan 2024 17:26:34 +0800 Subject: [PATCH] Fix user videos `no access` issue (#57) * Update UserDetailView.swift * Trying to fix issue * Trying to fix issue * Trying to fix issue * Trying to fix issue * Trying to fix issue * Trying to fix issue * Trying to fix issue * Trying to fix issue * Trying to fix issue * Update NetworkFixView.swift * Updated UserDetailView.swift --- .../DarockBili_Watch_App_UI_Tests.swift | 4 +++- DarockBili Watch App/Errors/NetworkFixView.swift | 1 + .../PersonalCenter/UserDetailView.swift | 14 +++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/DarockBili Watch App UI Tests/DarockBili_Watch_App_UI_Tests.swift b/DarockBili Watch App UI Tests/DarockBili_Watch_App_UI_Tests.swift index da9853b8e..a2b694295 100644 --- a/DarockBili Watch App UI Tests/DarockBili_Watch_App_UI_Tests.swift +++ b/DarockBili Watch App UI Tests/DarockBili_Watch_App_UI_Tests.swift @@ -49,8 +49,10 @@ final class DarockBili_Watch_App_UI_Tests: XCTestCase { sleep(1) takeScreenshot(of: app, named: "RMVideoAuthor") app.swipeLeft() - sleep(2) + sleep(1) takeScreenshot(of: app, named: "RMVideoAuthorVideos") + sleep(5) + takeScreenshot(of: app, named: "RMVideoAuthorVideos-Waited") app.navigationBars.buttons.element(boundBy: 0).tap() sleep(1) app.swipeLeft() diff --git a/DarockBili Watch App/Errors/NetworkFixView.swift b/DarockBili Watch App/Errors/NetworkFixView.swift index 4d4b94ea0..b2d9d4bc3 100644 --- a/DarockBili Watch App/Errors/NetworkFixView.swift +++ b/DarockBili Watch App/Errors/NetworkFixView.swift @@ -447,6 +447,7 @@ public func CheckBApiError(from input: JSON) -> Bool { } let msg = errorCodeTextDic[code] ?? (input["message"].string ?? "") tipWithText(msg, symbol: "xmark.circle.fill") + 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")".base64Encoded().replacingOccurrences(of: "/", with: "{slash}"))") { _, _ in return} return false } diff --git a/DarockBili Watch App/PersonalCenter/UserDetailView.swift b/DarockBili Watch App/PersonalCenter/UserDetailView.swift index af1e89b92..aa803dc41 100644 --- a/DarockBili Watch App/PersonalCenter/UserDetailView.swift +++ b/DarockBili Watch App/PersonalCenter/UserDetailView.swift @@ -564,12 +564,16 @@ struct UserDetailView: View { func RefreshVideos() { videos = [[String: String]]() let headers: HTTPHeaders = [ - // "accept-language": "zh-CN,zh;q=0.9", - "cookie": "SESSDATA=\(sessdata);", // buvid3=\(globalBuvid3);buvid4=\(globalBuvid4); - //"User-Agent": "Mozilla/5.0" // Bypass? drdar://gh/SocialSisterYi/bilibili-API-collect/issues/868/1859065874 + "accept": "*/*", + "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);", + "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 ] - // FIXME: Apply changes to RefreshArticles method after checking ability. - biliWbiSign(paramEncoded: "mid=\(uid)&ps=50&pn=\(videoNowPage)".base64Encoded()) { signed in + // 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&tid=0&pn=\(videoNowPage)&keyword=&order=pubdate&platform=web&web_location=1550101&order_avoided=true&dm_img_list=[]&dm_img_str=V2ViR0wgMS4wIChPcGVuR0wgRVMgMi4wIENocm9taXVtKQ&dm_cover_img_str=VjNEIDQuMkJyb2FkY2".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