fix: bangumi

This commit is contained in:
bggRGjQaUbCoE
2024-10-01 22:49:17 +08:00
parent 015edd26a3
commit 9d816d1b96
3 changed files with 55 additions and 9 deletions

View File

@@ -92,6 +92,8 @@ class Api {
// https://api.bilibili.com/x/v3/fav/resource/deal
static const String favVideo = '/x/v3/fav/resource/deal';
static const String favBangumi = '/x/v3/fav/resource/batch-deal';
// 判断视频是否被收藏双端GET
/// aid
// https://api.bilibili.com/x/v2/fav/video/favoured

View File

@@ -524,10 +524,47 @@ class VideoHttp {
}
}
// (取消)收藏 bangumi
static Future favBangumi({
required dynamic epId,
String? addIds,
String? delIds,
}) async {
var res = await Request().post(
Api.favBangumi,
data: {
'resources': '$epId:24',
'add_media_ids': addIds ?? '',
'del_media_ids': delIds ?? '',
'csrf': await Request.getCsrf(),
},
options: Options(
headers: {
'Content-Type': Headers.formUrlEncodedContentType,
},
),
);
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
// 查看视频被收藏在哪个文件夹
static Future videoInFolder({required int mid, required int rid}) async {
var res = await Request()
.get(Api.videoInFolder, data: {'up_mid': mid, 'rid': rid});
static Future videoInFolder({
dynamic mid,
dynamic rid,
dynamic type,
}) async {
var res = await Request().get(
Api.videoInFolder,
data: {
'up_mid': mid,
'rid': rid,
if (type != null) 'type': type,
},
);
if (res.data['code'] == 0) {
FavFolderData data = FavFolderData.fromJson(res.data['data']);
return {'status': true, 'data': data};

View File

@@ -226,7 +226,7 @@ class BangumiIntroController extends CommonController {
});
}
// (取消)收藏
// (取消)收藏 bangumi
Future actionFavVideo() async {
try {
for (var i in favFolderData.value.list!.toList()) {
@@ -237,10 +237,11 @@ class BangumiIntroController extends CommonController {
}
}
} catch (_) {}
var result = await VideoHttp.favVideo(
aid: IdUtils.bv2av(bvid),
var result = await VideoHttp.favBangumi(
epId: epId,
addIds: addMediaIdsNew.join(','),
delIds: delMediaIdsNew.join(','));
delIds: delMediaIdsNew.join(','),
);
if (result['status']) {
addMediaIdsNew = [];
delMediaIdsNew = [];
@@ -248,6 +249,8 @@ class BangumiIntroController extends CommonController {
queryHasFavVideo();
SmartDialog.showToast('操作成功');
Get.back();
} else {
SmartDialog.showToast(result['msg']);
}
}
@@ -322,6 +325,7 @@ class BangumiIntroController extends CommonController {
VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
this.epId = epId;
this.bvid = bvid;
videoDetailCtr.bvid = bvid;
videoDetailCtr.cid.value = cid;
videoDetailCtr.danmakuCid.value = cid;
@@ -358,7 +362,10 @@ class BangumiIntroController extends CommonController {
Future queryVideoInFolder() async {
var result = await VideoHttp.videoInFolder(
mid: userInfo.mid, rid: IdUtils.bv2av(bvid));
mid: userInfo.mid,
rid: epId, // bangumi
type: 24, // bangumi
);
if (result['status']) {
favFolderData.value = result['data'];
}