feat: sort fav

Closes #530

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-26 16:20:40 +08:00
parent aa378d924b
commit becb566ca8
5 changed files with 273 additions and 70 deletions

View File

@@ -81,6 +81,18 @@ class Api {
/// https://api.bilibili.com/x/web-interface/archive/coins
static const String hasCoinVideo = '/x/web-interface/archive/coins';
/// 收藏夹 详情
/// media_id 当前收藏夹id 搜索全部时为默认收藏夹id
/// pn int 当前页
/// ps int pageSize
/// keyword String 搜索词
/// order String 排序方式 view 最多播放 mtime 最近收藏 pubtime 最近投稿
/// tid int 分区id
/// platform web
/// type 0 当前收藏夹 1 全部收藏夹
// https://api.bilibili.com/x/v3/fav/resource/list?media_id=76614671&pn=1&ps=20&keyword=&order=mtime&type=0&tid=0
static const String favResourceList = '/x/v3/fav/resource/list';
// 收藏视频双端POST
// access_key str APP登录Token APP方式必要
/// rid num 稿件avid 必要
@@ -96,6 +108,14 @@ class Api {
static const String delFav = '/x/v3/fav/resource/batch-del';
static const String copyFav = '/x/v3/fav/resource/copy';
static const String moveFav = '/x/v3/fav/resource/move';
static const String cleanFav = '/x/v3/fav/resource/clean';
static const String sortFav = '/x/v3/fav/resource/sort';
// 判断视频是否被收藏双端GET
/// aid
// https://api.bilibili.com/x/v2/fav/video/favoured
@@ -123,10 +143,6 @@ class Api {
// rid num 目标 视频稿件avid
static const String favFolder = '/x/v3/fav/folder/created/list-all';
static const String copyFav = '/x/v3/fav/resource/copy';
static const String moveFav = '/x/v3/fav/resource/move';
static const String copyToview = '/x/v2/history/toview/copy';
static const String moveToview = '/x/v2/history/toview/move';
@@ -192,20 +208,6 @@ class Api {
static const String deleteFolder = '/x/v3/fav/folder/del';
static const String cleanFav = '/x/v3/fav/resource/clean';
/// 收藏夹 详情
/// media_id 当前收藏夹id 搜索全部时为默认收藏夹id
/// pn int 当前页
/// ps int pageSize
/// keyword String 搜索词
/// order String 排序方式 view 最多播放 mtime 最近收藏 pubtime 最近投稿
/// tid int 分区id
/// platform web
/// type 0 当前收藏夹 1 全部收藏夹
// https://api.bilibili.com/x/v3/fav/resource/list?media_id=76614671&pn=1&ps=20&keyword=&order=mtime&type=0&tid=0
static const String userFavFolderDetail = '/x/v3/fav/resource/list';
// 正在直播的up & 关注的up
// https://api.bilibili.com/x/polymer/web-dynamic/v1/portal
static const String followUp = '/x/polymer/web-dynamic/v1/portal';
@@ -674,9 +676,6 @@ class Api {
/// 我的订阅-合集详情
static const favSeasonList = '/x/space/fav/season/list';
/// 我的订阅-播单详情
static const favResourceList = '/x/v3/fav/resource/list';
/// 发送私信
static const String sendMsg = '${HttpString.tUrl}/web_im/v1/web_im/send_msg';

View File

@@ -1,5 +1,6 @@
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/video/later.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import '../common/constants.dart';
@@ -62,6 +63,30 @@ class UserHttp {
}
}
static Future sortFav({
required dynamic mediaId,
required List<String> sort,
}) async {
Map<String, dynamic> data = {
'media_id': mediaId,
'sort': sort.join(','),
'csrf': await Request.getCsrf(),
};
Utils.appSign(data);
var res = await Request().post(
Api.sortFav,
data: data,
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
static Future cleanFav({
required dynamic mediaId,
}) async {
@@ -152,7 +177,7 @@ class UserHttp {
String keyword = '',
String order = 'mtime',
int type = 0}) async {
var res = await Request().get(Api.userFavFolderDetail, queryParameters: {
var res = await Request().get(Api.favResourceList, queryParameters: {
'media_id': mediaId,
'pn': pn,
'ps': ps,