Skip to content

Commit

Permalink
修复视频操作无效问题 (#56)
Browse files Browse the repository at this point in the history
* Fixing - Favorite

* Fix build issue
  • Loading branch information
WindowsMEMZ authored Jan 5, 2024
1 parent f7b95bc commit 0585313
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions DarockBili Watch App/Video/VideoDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,10 @@ struct VideoDetailView: View {
HStack {
Button(action: {
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata)",
"cookie": "SESSDATA=\(sessdata); buvid3=\(globalBuvid3)",
"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/archive/like", method: .post, parameters: BiliVideoLike(bvid: videoDetails["BV"]!, like: isLiked ? 2 : 1, csrf: biliJct), headers: headers).response { response in
AF.request("https://api.bilibili.com/x/web-interface/archive/like", method: .post, parameters: ["bvid": videoDetails["BV"]!, "like": isLiked ? 2 : 1, "eab_x": 2, "ramval": 0, "source": "web_normal", "ga": 1, "csrf": biliJct], headers: headers).response { response in
debugPrint(response)
isLiked ? tipWithText("取消成功", symbol: "checkmark.circle.fill") : tipWithText("点赞成功", symbol: "checkmark.circle.fill")
isLiked.toggle()
Expand Down Expand Up @@ -690,15 +690,18 @@ struct VideoDetailView: View {
.sheet(isPresented: $isCoinViewPresented, content: {VideoThrowCoinView(bvid: videoDetails["BV"]!)})
Button(action: {
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata)",
"referer": "bilibili.com/video/\(videoDetails["BV"]!)",
"cookie": "SESSDATA=\(sessdata); buvid3=\(globalBuvid3)",
"referer": "https://www.bilibili.com/video/\(videoDetails["BV"]!)/",
"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"
]
let avid = bv2av(bvid: videoDetails["BV"]!)
AF.request("https://api.bilibili.com/medialist/gateway/coll/resource/deal", method: .post, parameters: BiliVideoFavourite(rid: avid, csrf: biliJct), headers: headers).response { response in
AF.request("https://api.bilibili.com/x/v3/fav/resource/deal", method: .post, parameters: BiliVideoFavourite(rid: avid, csrf: biliJct), headers: headers).response { response in
debugPrint(response)
isLiked ? tipWithText("取消成功", symbol: "checkmark.circle.fill") : tipWithText("收藏成功", symbol: "checkmark.circle.fill")
isFavoured.toggle()
if let rpd = response.data {
if !CheckBApiError(from: try! JSON(data: rpd)) { return }
isLiked ? tipWithText("取消成功", symbol: "checkmark.circle.fill") : tipWithText("收藏成功", symbol: "checkmark.circle.fill")
isFavoured.toggle()
}
}
}, label: {
VStack {
Expand Down

0 comments on commit 0585313

Please sign in to comment.