feat: 一键三连、视频页(取消)收藏
This commit is contained in:
@ -55,7 +55,7 @@ class Api {
|
||||
// csrf str CSRF Token(位于cookie) Cookie方式必要
|
||||
// https://api.bilibili.com/medialist/gateway/coll/resource/deal
|
||||
// https://api.bilibili.com/x/v3/fav/resource/deal
|
||||
static const String favVideo = '/medialist/gateway/coll/resource/deal';
|
||||
static const String favVideo = '/x/v3/fav/resource/deal';
|
||||
|
||||
// 判断视频是否被收藏(双端)GET
|
||||
/// aid
|
||||
@ -68,6 +68,20 @@ class Api {
|
||||
// bvid str 稿件bvid 必要(可选) avid与bvid任选一个
|
||||
// csrf str CSRF Token(位于cookie) 必要
|
||||
|
||||
// 一键三连
|
||||
// https://api.bilibili.com/x/web-interface/archive/like/triple
|
||||
// aid num 稿件avid 必要(可选) avid与bvid任选一个
|
||||
// bvid str 稿件bvid 必要(可选) avid与bvid任选一个
|
||||
// csrf str CSRF Token(位于cookie) 必要
|
||||
static const String oneThree = '/x/web-interface/archive/like/triple';
|
||||
|
||||
// 获取指定用户创建的所有收藏夹信息
|
||||
// 该接口也能查询目标内容id存在于那些收藏夹中
|
||||
// up_mid num 目标用户mid 必要
|
||||
// type num 目标内容属性 非必要 默认为全部 0:全部 2:视频稿件
|
||||
// rid num 目标 视频稿件avid
|
||||
static const String videoInFolder = '/x/v3/fav/folder/created/list-all';
|
||||
|
||||
// 视频详情页 相关视频
|
||||
static const String relatedList = '/x/web-interface/archive/related';
|
||||
|
||||
|
||||
@ -138,13 +138,14 @@ class Request {
|
||||
/*
|
||||
* post请求
|
||||
*/
|
||||
post(url, {data, options, cancelToken, extra}) async {
|
||||
post(url, {data, queryParameters, options, cancelToken, extra}) async {
|
||||
print('post-data: $data');
|
||||
Response response;
|
||||
try {
|
||||
response = await dio.post(
|
||||
url,
|
||||
data: data,
|
||||
queryParameters: queryParameters,
|
||||
options: options,
|
||||
cancelToken: cancelToken,
|
||||
);
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:pilipala/http/api.dart';
|
||||
import 'package:pilipala/http/init.dart';
|
||||
import 'package:pilipala/models/model_hot_video_item.dart';
|
||||
import 'package:pilipala/models/model_rec_video_item.dart';
|
||||
import 'package:pilipala/models/user/fav_folder.dart';
|
||||
import 'package:pilipala/models/video_detail_res.dart';
|
||||
|
||||
/// res.data['code'] == 0 请求正常返回结果
|
||||
@ -122,11 +123,26 @@ class VideoHttp {
|
||||
}
|
||||
|
||||
// 一键三连
|
||||
static Future oneThree({required String aid}) async {
|
||||
var res = await Request().post(
|
||||
Api.oneThree,
|
||||
queryParameters: {
|
||||
'aid': aid,
|
||||
'csrf': await Request.getCsrf(),
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'data': [], 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
// (取消)点赞
|
||||
static Future likeVideo({required String aid, required bool type}) async {
|
||||
var res = await Request().post(
|
||||
Api.likeVideo,
|
||||
data: {
|
||||
queryParameters: {
|
||||
'aid': aid,
|
||||
'like': type ? 1 : 2,
|
||||
'csrf': await Request.getCsrf(),
|
||||
@ -141,20 +157,33 @@ class VideoHttp {
|
||||
|
||||
// (取消)收藏
|
||||
static Future favVideo(
|
||||
{required String aid, required bool type, required String ids}) async {
|
||||
Map data = {'rid': aid, 'type': 2};
|
||||
// type true 添加收藏 false 取消收藏
|
||||
if (type) {
|
||||
data['add_media_ids'] = ids;
|
||||
} else {
|
||||
data['del_media_ids'] = ids;
|
||||
}
|
||||
var res = await Request()
|
||||
.post(Api.favVideo, data: {'aid': aid, 'like': type ? 1 : 2});
|
||||
{required String aid,
|
||||
required bool type,
|
||||
required String addIds,
|
||||
required String delIds}) async {
|
||||
var res = await Request().post(Api.favVideo, queryParameters: {
|
||||
'rid': aid,
|
||||
'type': 2,
|
||||
'add_media_ids': addIds,
|
||||
'del_media_ids': delIds,
|
||||
'csrf': await Request.getCsrf(),
|
||||
});
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'data': []};
|
||||
}
|
||||
}
|
||||
|
||||
// 查看视频被收藏在哪个文件夹
|
||||
static Future videoInFolder({required int mid, required String rid}) async {
|
||||
var res = await Request()
|
||||
.get(Api.videoInFolder, data: {'up_mid': mid, 'rid': rid});
|
||||
if (res.data['code'] == 0) {
|
||||
FavFolderData data = FavFolderData.fromJson(res.data['data']);
|
||||
return {'status': true, 'data': data};
|
||||
} else {
|
||||
return {'status': false, 'data': []};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user