From f0fb301465ef89c2c5192663f68df7cf377ad8b9 Mon Sep 17 00:00:00 2001 From: Mark Chan <45706356+WindowsMEMZ@users.noreply.github.com> Date: Tue, 2 Jan 2024 22:21:56 +0800 Subject: [PATCH] Update VideoDetailView.swift --- DarockBili Watch App/Video/VideoDetailView.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DarockBili Watch App/Video/VideoDetailView.swift b/DarockBili Watch App/Video/VideoDetailView.swift index 5bfbf6907..59472a278 100644 --- a/DarockBili Watch App/Video/VideoDetailView.swift +++ b/DarockBili Watch App/Video/VideoDetailView.swift @@ -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 @@ -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