Skip to content

Commit

Permalink
Final apply
Browse files Browse the repository at this point in the history
  • Loading branch information
WindowsMEMZ committed Jan 13, 2024
1 parent 4a26937 commit 6838671
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions DarockBili Watch App/Video/VideoDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,19 @@ struct VideoDetailView: View {
"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"
]
AF.request("https://api.bilibili.com/x/web-interface/view?bvid=\(videoDetails["BV"]!)", headers: headers).response { response in
let cid = Int((String(data: response.data!, encoding: .utf8)?.components(separatedBy: "\"pages\":[{\"cid\":")[1].components(separatedBy: ",")[0])!)!
VideoDetailView.willPlayVideoCID = String(cid)
AF.request("https://api.bilibili.com/x/player/playurl?platform=html5&bvid=\(videoDetails["BV"]!)&cid=\(cid)", headers: headers).response { response in
VideoDetailView.willPlayVideoLink = (String(data: response.data!, encoding: .utf8)?.components(separatedBy: ",\"url\":\"")[1].components(separatedBy: "\",")[0])!.replacingOccurrences(of: "\\u0026", with: "&")
VideoDetailView.willPlayVideoBV = videoDetails["BV"]!
isNowPlayingPresented = true
isLoading = false
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/web-interface/view?bvid=\(videoDetails["BV"]!)", headers: headers) { respJson, isSuccess in
if !CheckBApiError(from: respJson) { return }
let cid = respJson["data"]["pages"][0]["cid"].int!
VideoDetailView.willPlayVideoCID = String(cid)
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/player/playurl?platform=html5&bvid=\(videoDetails["BV"]!)&cid=\(cid)", headers: headers) { respJson, isSuccess in
if !CheckBApiError(from: respJson) { return }
VideoDetailView.willPlayVideoLink = respJson["data"]["durl"][0]["url"].string!.replacingOccurrences(of: "\\u0026", with: "&")
//debugPrint(response)
VideoDetailView.willPlayVideoBV = videoDetails["BV"]!
isVideoPlayerPresented = true
isLoading = false
}
}
}
} else if videoGetterSource == "injahow" {
DarockKit.Network.shared.requestString("https://api.injahow.cn/bparse/?bv=\(videoDetails["BV"]!.dropFirst().dropFirst())&p=1&type=video&q=32&format=mp4&otype=url") { respStr, isSuccess in
if isSuccess {
Expand Down Expand Up @@ -485,11 +488,13 @@ struct VideoDetailView: View {
"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"
]
AF.request("https://api.bilibili.com/x/web-interface/view?bvid=\(videoDetails["BV"]!)", headers: headers).response { response in
let cid = Int((String(data: response.data!, encoding: .utf8)?.components(separatedBy: "\"pages\":[{\"cid\":")[1].components(separatedBy: ",")[0])!)!
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/web-interface/view?bvid=\(videoDetails["BV"]!)", headers: headers) { respJson, isSuccess in
if !CheckBApiError(from: respJson) { return }
let cid = respJson["data"]["pages"][0]["cid"].int!
VideoDetailView.willPlayVideoCID = String(cid)
AF.request("https://api.bilibili.com/x/player/playurl?platform=html5&bvid=\(videoDetails["BV"]!)&cid=\(cid)", headers: headers).response { response in
VideoDetailView.willPlayVideoLink = (String(data: response.data!, encoding: .utf8)?.components(separatedBy: ",\"url\":\"")[1].components(separatedBy: "\",")[0])!.replacingOccurrences(of: "\\u0026", with: "&")
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/player/playurl?platform=html5&bvid=\(videoDetails["BV"]!)&cid=\(cid)", headers: headers) { respJson, isSuccess in
if !CheckBApiError(from: respJson) { return }
VideoDetailView.willPlayVideoLink = respJson["data"]["durl"][0]["url"].string!.replacingOccurrences(of: "\\u0026", with: "&")
//debugPrint(response)
VideoDetailView.willPlayVideoBV = videoDetails["BV"]!
isVideoPlayerPresented = true
Expand Down Expand Up @@ -923,8 +928,9 @@ struct VideoDetailView: View {
]
let cid = videoPages[i]["CID"]!
VideoDetailView.willPlayVideoCID = cid
AF.request("https://api.bilibili.com/x/player/playurl?platform=html5&bvid=\(videoDetails["BV"]!)&cid=\(cid)", headers: headers).response { response in
VideoDetailView.willPlayVideoLink = (String(data: response.data!, encoding: .utf8)?.components(separatedBy: ",\"url\":\"")[1].components(separatedBy: "\",")[0])!.replacingOccurrences(of: "\\u0026", with: "&")
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/player/playurl?platform=html5&bvid=\(videoDetails["BV"]!)&cid=\(cid)", headers: headers) { respJson, isSuccess in
if !CheckBApiError(from: respJson) { return }
VideoDetailView.willPlayVideoLink = respJson["data"]["durl"][0]["url"].string!.replacingOccurrences(of: "\\u0026", with: "&")
VideoDetailView.willPlayVideoBV = videoDetails["BV"]!
isVideoPlayerPresented = true
isLoading = false
Expand Down

0 comments on commit 6838671

Please sign in to comment.