Skip to content

Commit

Permalink
Merge pull request #49 from Darock-Studio/fix/decode-video-crash
Browse files Browse the repository at this point in the history
修复解析视频时崩溃问题
  • Loading branch information
WindowsMEMZ authored Jan 2, 2024
2 parents 0a15f3c + f0fb301 commit 470c554
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions DarockBili Watch App/Video/VideoDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ 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"]!)").response { response in
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
Expand Down Expand Up @@ -152,9 +152,10 @@ struct VideoDetailView: View {
debugPrint(videoDetails["BV"]!)
if videoGetterSource == "official" {
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata)"
"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"]!)").response { response in
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
Expand Down

0 comments on commit 470c554

Please sign in to comment.