Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-23 16:47:11 +08:00
parent 148e0872b4
commit 418a1e8d39
821 changed files with 29467 additions and 25520 deletions

View File

@@ -5,8 +5,10 @@ import 'package:PiliPlus/models_new/blacklist/data.dart';
import 'package:PiliPlus/utils/accounts.dart';
class BlackHttp {
static Future<LoadingState<BlackListData>> blackList(
{required int pn, int? ps}) async {
static Future<LoadingState<BlackListData>> blackList({
required int pn,
int? ps,
}) async {
var res = await Request().get(
Api.blackLst,
queryParameters: {

View File

@@ -3,15 +3,18 @@ import 'package:PiliPlus/http/init.dart';
class CommonHttp {
static Future unReadDynamic() async {
var res = await Request().get(Api.getUnreadDynamic, queryParameters: {
'alltype_offset': 0,
'video_offset': 0,
'article_offset': 0,
});
var res = await Request().get(
Api.getUnreadDynamic,
queryParameters: {
'alltype_offset': 0,
'video_offset': 0,
'article_offset': 0,
},
);
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data']['update_info']['item']['count']
'data': res.data['data']['update_info']['item']['count'],
};
} else {
return {

View File

@@ -9,7 +9,7 @@ class DanmakuFilterHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': DanmakuBlockDataModel.fromJson(res.data['data'])
'data': DanmakuBlockDataModel.fromJson(res.data['data']),
};
} else {
return {
@@ -37,8 +37,10 @@ class DanmakuFilterHttp {
}
}
static Future danmakuFilterAdd(
{required String filter, required int type}) async {
static Future danmakuFilterAdd({
required String filter,
required int type,
}) async {
var res = await Request().post(
Api.danmakuFilterAdd,
queryParameters: {

View File

@@ -168,16 +168,16 @@ class DynamicsHttp {
"scene": rid != null
? 5
: dynIdStr != null
? 4
: pics != null
? 2
: 1,
? 4
: pics != null
? 2
: 1,
'pics': ?pics,
"attach_card": attachCard,
"upload_id":
"${rid != null ? 0 : mid}_${DateTime.now().millisecondsSinceEpoch ~/ 1000}_${Utils.random.nextInt(9000) + 1000}",
"meta": {
"app_meta": {"from": "create.dynamic.web", "mobi_app": "web"}
"app_meta": {"from": "create.dynamic.web", "mobi_app": "web"},
},
if (topic != null)
"topic": {
@@ -185,7 +185,7 @@ class DynamicsHttp {
"name": topic.second,
"from_source": "dyn.web.list",
"from_topic_id": 0,
}
},
},
if (dynIdStr != null || rid != null)
"web_repost_src": {
@@ -194,8 +194,8 @@ class DynamicsHttp {
"revs_id": {
"dyn_type": dynType,
"rid": rid,
}
}
},
},
},
);
if (res.data['code'] == 0) {
@@ -309,15 +309,16 @@ class DynamicsHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': ArticleInfoData.fromJson(res.data['data'])
'data': ArticleInfoData.fromJson(res.data['data']),
};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
static Future<LoadingState<ArticleViewData>> articleView(
{required dynamic cvId}) async {
static Future<LoadingState<ArticleViewData>> articleView({
required dynamic cvId,
}) async {
final res = await Request().get(
Api.articleView,
queryParameters: await WbiSign.makSign({
@@ -333,8 +334,9 @@ class DynamicsHttp {
}
}
static Future<LoadingState<DynamicItemModel>> opusDetail(
{required dynamic opusId}) async {
static Future<LoadingState<DynamicItemModel>> opusDetail({
required dynamic opusId,
}) async {
final res = await Request().get(
Api.opusDetail,
queryParameters: await WbiSign.makSign({
@@ -351,8 +353,10 @@ class DynamicsHttp {
}
static Future<LoadingState<VoteInfo>> voteInfo(dynamic voteId) async {
final res =
await Request().get(Api.voteInfo, queryParameters: {'vote_id': voteId});
final res = await Request().get(
Api.voteInfo,
queryParameters: {'vote_id': voteId},
);
if (res.data['code'] == 0) {
return Success(VoteInfo.fromSeparatedJson(res.data['data']));
} else {
@@ -375,12 +379,14 @@ class DynamicsHttp {
'op_bit': 0,
'dynamic_id': dynamicId ?? 0,
'csrf_token': csrf,
'csrf': csrf
'csrf': csrf,
};
final res = await Request().post(Api.doVote,
queryParameters: {'csrf': csrf},
data: data,
options: Options(contentType: Headers.jsonContentType));
final res = await Request().post(
Api.doVote,
queryParameters: {'csrf': csrf},
data: data,
options: Options(contentType: Headers.jsonContentType),
);
if (res.data['code'] == 0) {
return Success(VoteInfo.fromJson(res.data['data']['vote_info']));
} else {
@@ -471,15 +477,16 @@ class DynamicsHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': DynReserveData.fromJson(res.data['data'])
'data': DynReserveData.fromJson(res.data['data']),
};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
static Future<LoadingState<List<TopicItem>?>> dynTopicRcmd(
{int ps = 25}) async {
static Future<LoadingState<List<TopicItem>?>> dynTopicRcmd({
int ps = 25,
}) async {
final res = await Request().get(
Api.dynTopicRcmd,
queryParameters: {
@@ -489,9 +496,11 @@ class DynamicsHttp {
},
);
if (res.data['code'] == 0) {
return Success((res.data['data']?['topic_items'] as List?)
?.map((e) => TopicItem.fromJson(e))
.toList());
return Success(
(res.data['data']?['topic_items'] as List?)
?.map((e) => TopicItem.fromJson(e))
.toList(),
);
} else {
return Error(res.data['message']);
}
@@ -506,16 +515,19 @@ class DynamicsHttp {
},
);
if (res.data['code'] == 0) {
return Success((res.data['data'] as List?)
?.map((e) => OpusPicModel.fromJson(e))
.toList());
return Success(
(res.data['data'] as List?)
?.map((e) => OpusPicModel.fromJson(e))
.toList(),
);
} else {
return Error(res.data['message']);
}
}
static Future<LoadingState<List<MentionGroup>?>> dynMention(
{String? keyword}) async {
static Future<LoadingState<List<MentionGroup>?>> dynMention({
String? keyword,
}) async {
final res = await Request().get(
Api.dynMention,
queryParameters: {

View File

@@ -4,15 +4,22 @@ import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models_new/fans/data.dart';
class FanHttp {
static Future<LoadingState<FansData>> fans(
{int? vmid, int? pn, int? ps, String? orderType}) async {
var res = await Request().get(Api.fans, queryParameters: {
'vmid': vmid,
'pn': pn,
'ps': ps,
'order': 'desc',
'order_type': orderType,
});
static Future<LoadingState<FansData>> fans({
int? vmid,
int? pn,
int? ps,
String? orderType,
}) async {
var res = await Request().get(
Api.fans,
queryParameters: {
'vmid': vmid,
'pn': pn,
'ps': ps,
'order': 'desc',
'order_type': orderType,
},
);
if (res.data['code'] == 0) {
return Success(FansData.fromJson(res.data['data']));
} else {

View File

@@ -67,7 +67,7 @@ class FavHttp {
'order': order.name,
'type': type,
'tid': 0,
'platform': 'web'
'platform': 'web',
},
);
if (res.data['code'] == 0) {
@@ -444,15 +444,17 @@ class FavHttp {
static Future deleteFolder({
required List<dynamic> mediaIds,
}) async {
var res = await Request().post(Api.deleteFolder,
data: {
'media_ids': mediaIds.join(','),
'platform': 'web',
'csrf': Accounts.main.csrf,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
));
var res = await Request().post(
Api.deleteFolder,
data: {
'media_ids': mediaIds.join(','),
'platform': 'web',
'csrf': Accounts.main.csrf,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
@@ -468,18 +470,20 @@ class FavHttp {
required String cover,
required String intro,
}) async {
var res = await Request().post(isAdd ? Api.addFolder : Api.editFolder,
data: {
'title': title,
'intro': intro,
'privacy': privacy,
'cover': cover.isNotEmpty ? Uri.encodeFull(cover) : cover,
'csrf': Accounts.main.csrf,
'media_id': ?mediaId,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
));
var res = await Request().post(
isAdd ? Api.addFolder : Api.editFolder,
data: {
'title': title,
'intro': intro,
'privacy': privacy,
'cover': cover.isNotEmpty ? Uri.encodeFull(cover) : cover,
'csrf': Accounts.main.csrf,
'media_id': ?mediaId,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (res.data['code'] == 0) {
return {'status': true, 'data': FavFolderInfo.fromJson(res.data['data'])};
} else {
@@ -554,9 +558,11 @@ class FavHttp {
),
);
if (res.data['code'] == 0) {
return Success((res.data['data'] as List?)
?.map((e) => SpaceFavData.fromJson(e))
.toList());
return Success(
(res.data['data'] as List?)
?.map((e) => SpaceFavData.fromJson(e))
.toList(),
);
} else {
return Error(res.data['message']);
}
@@ -574,7 +580,7 @@ class FavHttp {
data: {
"entity": {
"object_id_str": opusId,
"type": {"biz": 2}
"type": {"biz": 2},
},
"action": action, // 3 fav, 4 unfav
},
@@ -644,11 +650,11 @@ class FavHttp {
var res = await Request().post(
isFav
? isCopy
? Api.copyFav
: Api.moveFav
? Api.copyFav
: Api.moveFav
: isCopy
? Api.copyToview
: Api.moveToview,
? Api.copyToview
: Api.moveToview,
data: {
'src_media_id': ?srcMediaId,
'tar_media_id': tarMediaId,

View File

@@ -10,13 +10,16 @@ class FollowHttp {
int? ps,
String orderType = '',
}) async {
var res = await Request().get(Api.followings, queryParameters: {
'vmid': vmid,
'pn': pn,
'ps': ps,
'order': 'desc',
'order_type': orderType,
});
var res = await Request().get(
Api.followings,
queryParameters: {
'vmid': vmid,
'pn': pn,
'ps': ps,
'order': 'desc',
'order_type': orderType,
},
);
if (res.data['code'] == 0) {
return Success(
FollowData.fromJson(res.data['data']),
@@ -32,13 +35,16 @@ class FollowHttp {
int? ps,
String orderType = '', // ''=>最近关注,'attention'=>最常访问
}) async {
var res = await Request().get(Api.followings, queryParameters: {
'vmid': vmid,
'pn': pn,
'ps': ps,
'order': 'desc',
'order_type': orderType,
});
var res = await Request().get(
Api.followings,
queryParameters: {
'vmid': vmid,
'pn': pn,
'ps': ps,
'order': 'desc',
'order_type': orderType,
},
);
if (res.data['code'] == 0) {
return Success(

View File

@@ -37,7 +37,9 @@ class Request {
Accounts.refresh();
final List<Cookie> cookies = Accounts.main.cookieJar.toList();
final webManager = web.CookieManager();
await Future.wait(cookies.map((item) => webManager.setCookie(
await Future.wait(
cookies.map(
(item) => webManager.setCookie(
url: web.WebUri(item.domain ?? ''),
name: item.name,
value: item.value,
@@ -45,7 +47,9 @@ class Request {
domain: item.domain,
isSecure: item.secure,
isHttpOnly: item.httpOnly,
)));
),
),
);
if (Accounts.main.isLogin) {
final coin = GStorage.userInfo.get('userInfoCache')?.money;
@@ -73,10 +77,11 @@ class Request {
// options: Options(extra: {'account': account}));
// final String spmPrefix = _spmPrefixExp.firstMatch(html.data)!.group(1)!;
final String randPngEnd = base64.encode(
List<int>.generate(32, (_) => Utils.random.nextInt(256)) +
List<int>.filled(4, 0) +
[73, 69, 78, 68] +
List<int>.generate(4, (_) => Utils.random.nextInt(256)));
List<int>.generate(32, (_) => Utils.random.nextInt(256)) +
List<int>.filled(4, 0) +
[73, 69, 78, 68] +
List<int>.generate(4, (_) => Utils.random.nextInt(256)),
);
String jsonData = json.encode({
'3064': 1,
@@ -88,9 +93,11 @@ class Request {
},
});
await Request().post(Api.activateBuvidApi,
data: {'payload': jsonData},
options: Options(contentType: Headers.jsonContentType));
await Request().post(
Api.activateBuvidApi,
data: {'payload': jsonData},
options: Options(contentType: Headers.jsonContentType),
);
} catch (_) {}
}
@@ -100,68 +107,74 @@ class Request {
Request._internal() {
//BaseOptions、Options、RequestOptions 都可以配置参数,优先级别依次递增,且可以根据优先级别覆盖参数
BaseOptions options = BaseOptions(
//请求基地址,可以包含子路径
baseUrl: HttpString.apiBaseUrl,
//连接服务器超时时间,单位是毫秒.
connectTimeout: const Duration(milliseconds: 10000),
//响应流上前后两次接受到数据的间隔,单位为毫秒。
receiveTimeout: const Duration(milliseconds: 10000),
//Http请求头.
headers: {
'connection': 'keep-alive',
'accept-encoding': 'br,gzip',
'user-agent': 'Dart/3.6 (dart:io)', // Http2Adapter不会自动添加标头
'referer': HttpString.baseUrl,
'env': 'prod',
'app-key': 'android64',
'x-bili-aurora-zone': 'sh001',
},
responseDecoder: responseDecoder, // Http2Adapter没有自动解压
persistentConnection: true);
//请求基地址,可以包含子路径
baseUrl: HttpString.apiBaseUrl,
//连接服务器超时时间,单位是毫秒.
connectTimeout: const Duration(milliseconds: 10000),
//响应流上前后两次接受到数据的间隔,单位为毫秒。
receiveTimeout: const Duration(milliseconds: 10000),
//Http请求头.
headers: {
'connection': 'keep-alive',
'accept-encoding': 'br,gzip',
'user-agent': 'Dart/3.6 (dart:io)', // Http2Adapter不会自动添加标头
'referer': HttpString.baseUrl,
'env': 'prod',
'app-key': 'android64',
'x-bili-aurora-zone': 'sh001',
},
responseDecoder: responseDecoder, // Http2Adapter没有自动解压
persistentConnection: true,
);
final bool enableSystemProxy = Pref.enableSystemProxy;
final String systemProxyHost = Pref.systemProxyHost;
final String systemProxyPort = Pref.systemProxyPort;
final http11Adapter = IOHttpClientAdapter(createHttpClient: () {
final client = HttpClient()
..idleTimeout = const Duration(seconds: 15)
..autoUncompress = false; // Http2Adapter没有自动解压, 统一行为
// 设置代理
if (enableSystemProxy) {
client
..findProxy = ((_) => 'PROXY $systemProxyHost:$systemProxyPort')
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
return client;
});
final http11Adapter = IOHttpClientAdapter(
createHttpClient: () {
final client = HttpClient()
..idleTimeout = const Duration(seconds: 15)
..autoUncompress = false; // Http2Adapter没有自动解压, 统一行为
// 设置代理
if (enableSystemProxy) {
client
..findProxy = ((_) => 'PROXY $systemProxyHost:$systemProxyPort')
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
return client;
},
);
late Uri proxy;
if (enableSystemProxy) {
proxy = Uri(
scheme: 'http',
host: systemProxyHost,
port: int.parse(systemProxyPort));
scheme: 'http',
host: systemProxyHost,
port: int.parse(systemProxyPort),
);
}
dio = Dio(options)
..httpClientAdapter = Pref.enableHttp2
? Http2Adapter(
ConnectionManager(
idleTimeout: const Duration(seconds: 15),
onClientCreate: enableSystemProxy
? (_, config) {
config
..proxy = proxy
..onBadCertificate = (_) => true;
}
: Pref.badCertificateCallback
? (_, config) {
config.onBadCertificate = (_) => true;
}
: null),
fallbackAdapter: http11Adapter)
idleTimeout: const Duration(seconds: 15),
onClientCreate: enableSystemProxy
? (_, config) {
config
..proxy = proxy
..onBadCertificate = (_) => true;
}
: Pref.badCertificateCallback
? (_, config) {
config.onBadCertificate = (_) => true;
}
: null,
),
fallbackAdapter: http11Adapter,
)
: http11Adapter;
// 先于其他Interceptor
@@ -169,11 +182,13 @@ class Request {
// 日志拦截器 输出请求、响应内容
if (kDebugMode) {
dio.interceptors.add(LogInterceptor(
request: false,
requestHeader: false,
responseHeader: false,
));
dio.interceptors.add(
LogInterceptor(
request: false,
requestHeader: false,
responseHeader: false,
),
);
}
dio.transformer = BackgroundTransformer();
@@ -208,7 +223,7 @@ class Request {
} on DioException catch (e) {
return Response(
data: {
'message': await AccountManager.dioError(e)
'message': await AccountManager.dioError(e),
}, // 将自定义 Map 数据赋值给 Response 的 data 属性
statusCode: e.response?.statusCode ?? -1,
requestOptions: e.requestOptions,
@@ -239,7 +254,7 @@ class Request {
AccountManager.toast(e);
return Response(
data: {
'message': await AccountManager.dioError(e)
'message': await AccountManager.dioError(e),
}, // 将自定义 Map 数据赋值给 Response 的 data 属性
statusCode: e.response?.statusCode ?? -1,
requestOptions: e.requestOptions,
@@ -250,8 +265,11 @@ class Request {
/*
* 下载文件
*/
Future<Response> downloadFile(String urlPath, String savePath,
{CancelToken? cancelToken}) async {
Future<Response> downloadFile(
String urlPath,
String savePath, {
CancelToken? cancelToken,
}) async {
try {
final response = await dio.download(
urlPath,
@@ -291,19 +309,26 @@ class Request {
'mob' =>
'Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Mobile Safari/537.36',
_ =>
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15'
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15',
};
}
static String responseDecoder(List<int> responseBytes, RequestOptions options,
ResponseBody responseBody) {
static String responseDecoder(
List<int> responseBytes,
RequestOptions options,
ResponseBody responseBody,
) {
switch (responseBody.headers['content-encoding']?.firstOrNull) {
case 'gzip':
return utf8.decode(_gzipDecoder.decodeBytes(responseBytes),
allowMalformed: true);
return utf8.decode(
_gzipDecoder.decodeBytes(responseBytes),
allowMalformed: true,
);
case 'br':
return utf8.decode(_brotilDecoder.convert(responseBytes),
allowMalformed: true);
return utf8.decode(
_brotilDecoder.convert(responseBytes),
allowMalformed: true,
);
default:
return utf8.decode(responseBytes, allowMalformed: true);
}

View File

@@ -83,7 +83,7 @@ class LiveHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': RoomPlayInfoData.fromJson(res.data['data'])
'data': RoomPlayInfoData.fromJson(res.data['data']),
};
} else {
return {'status': false, 'msg': res.data['message']};
@@ -91,13 +91,16 @@ class LiveHttp {
}
static Future liveRoomInfoH5({roomId, qn}) async {
var res = await Request().get(Api.liveRoomInfoH5, queryParameters: {
'room_id': roomId,
});
var res = await Request().get(
Api.liveRoomInfoH5,
queryParameters: {
'room_id': roomId,
},
);
if (res.data['code'] == 0) {
return {
'status': true,
'data': RoomInfoH5Data.fromJson(res.data['data'])
'data': RoomInfoH5Data.fromJson(res.data['data']),
};
} else {
return {'status': false, 'msg': res.data['message']};
@@ -133,15 +136,16 @@ class LiveHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': LiveDmInfoData.fromJson(res.data['data'])
'data': LiveDmInfoData.fromJson(res.data['data']),
};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
static Future<LoadingState<List<LiveEmoteDatum>?>> getLiveEmoticons(
{required int roomId}) async {
static Future<LoadingState<List<LiveEmoteDatum>?>> getLiveEmoticons({
required int roomId,
}) async {
var res = await Request().get(
Api.getLiveEmoticons,
queryParameters: {
@@ -295,9 +299,11 @@ class LiveHttp {
queryParameters: params,
);
if (res.data['code'] == 0) {
return Success((res.data['data']?['list'] as List?)
?.map((e) => AreaList.fromJson(e))
.toList());
return Success(
(res.data['data']?['list'] as List?)
?.map((e) => AreaList.fromJson(e))
.toList(),
);
} else {
return Error(res.data['message']);
}
@@ -331,10 +337,12 @@ class LiveHttp {
);
if (res.data['code'] == 0) {
return Success((res.data['data']?['tags'] as List?)
?.map((e) => AreaItem.fromJson(e))
.toList() ??
<AreaItem>[]);
return Success(
(res.data['data']?['tags'] as List?)
?.map((e) => AreaItem.fromJson(e))
.toList() ??
<AreaItem>[],
);
} else {
return Error(res.data['message']);
}
@@ -409,9 +417,9 @@ class LiveHttp {
queryParameters: params,
);
if (res.data['code'] == 0) {
return Success((res.data['data'] as List?)
?.map((e) => AreaItem.fromJson(e))
.toList());
return Success(
(res.data['data'] as List?)?.map((e) => AreaItem.fromJson(e)).toList(),
);
} else {
return Error(res.data['message']);
}
@@ -458,7 +466,8 @@ class LiveHttp {
}
static Future<LoadingState<ShieldInfo?>> getLiveInfoByUser(
dynamic roomId) async {
dynamic roomId,
) async {
var res = await Request().get(
Api.getLiveInfoByUser,
queryParameters: await WbiSign.makSign({

View File

@@ -8,14 +8,14 @@ sealed class LoadingState<T> {
bool get isSuccess => this is Success<T>;
T get data => switch (this) {
Success(:var response) => response,
_ => throw this,
};
Success(:var response) => response,
_ => throw this,
};
T? get dataOrNull => switch (this) {
Success(:var response) => response,
_ => null,
};
Success(:var response) => response,
_ => null,
};
void toast() => SmartDialog.showToast(toString());
}

View File

@@ -57,7 +57,7 @@ class LoginHttp {
'status': res.data['code'] == 0,
'code': res.data['code'],
'data': res.data['data'],
'msg': res.data['message']
'msg': res.data['message'],
};
}
@@ -107,8 +107,9 @@ class LoginHttp {
'gee_validate': ?geeValidate,
'local_id': buvid,
// https://chinggg.github.io/post/appre/
'login_session_id':
md5.convert(utf8.encode(buvid + timestamp.toString())).toString(),
'login_session_id': md5
.convert(utf8.encode(buvid + timestamp.toString()))
.toString(),
'mobi_app': 'android_hd',
'platform': 'android',
'recaptcha_token': ?recaptchaToken,
@@ -135,7 +136,7 @@ class LoginHttp {
'status': false,
'code': res.data['code'],
'msg': res.data['message'],
'data': res.data['data']
'data': res.data['data'],
};
}
}
@@ -191,8 +192,9 @@ class LoginHttp {
String? recaptchaToken,
}) async {
dynamic publicKey = RSAKeyParser().parse(key);
String passwordEncrypted =
Encrypter(RSA(publicKey: publicKey)).encrypt(salt + password).base64;
String passwordEncrypted = Encrypter(
RSA(publicKey: publicKey),
).encrypt(salt + password).base64;
Map<String, String> data = {
'bili_local_id': deviceId,
@@ -206,9 +208,11 @@ class LoginHttp {
'device_name': 'vivo',
'device_platform': 'Android14vivo',
'disable_rcmd': '0',
'dt': Uri.encodeComponent(Encrypter(RSA(publicKey: publicKey))
.encrypt(Utils.generateRandomString(16))
.base64),
'dt': Uri.encodeComponent(
Encrypter(
RSA(publicKey: publicKey),
).encrypt(Utils.generateRandomString(16)).base64,
),
'from_pv': 'main.homepage.avatar-nologin.all.click',
'from_url': Uri.encodeComponent('bilibili://pegasus/promo'),
'gee_challenge': ?geeChallenge,
@@ -247,7 +251,7 @@ class LoginHttp {
'status': false,
'code': res.data['code'],
'msg': res.data['message'],
'data': res.data['data']
'data': res.data['data'],
};
}
}
@@ -277,9 +281,11 @@ class LoginHttp {
'device_platform': 'Android14vivo',
// 'device_tourist_id': '',
'disable_rcmd': '0',
'dt': Uri.encodeComponent(Encrypter(RSA(publicKey: publicKey))
.encrypt(Utils.generateRandomString(16))
.base64),
'dt': Uri.encodeComponent(
Encrypter(
RSA(publicKey: publicKey),
).encrypt(Utils.generateRandomString(16)).base64,
),
'from_pv': 'main.my-information.my-login.0.click',
'from_url': Uri.encodeComponent('bilibili://user_center/mine'),
'local_id': buvid,
@@ -308,7 +314,7 @@ class LoginHttp {
'status': false,
'code': res.data['code'],
'msg': res.data['message'],
'data': res.data['data']
'data': res.data['data'],
};
}
}
@@ -330,7 +336,7 @@ class LoginHttp {
'status': false,
'code': res.data['code'],
'msg': res.data['message'],
'data': res.data['data']
'data': res.data['data'],
};
}
}
@@ -346,7 +352,7 @@ class LoginHttp {
'status': false,
'code': res.data['code'],
'msg': res.data['message'],
'data': res.data['data']
'data': res.data['data'],
};
}
}
@@ -374,10 +380,12 @@ class LoginHttp {
var res = await Request().post(
Api.safeCenterSmsCode,
data: data,
options:
Options(contentType: Headers.formUrlEncodedContentType, headers: {
"Referer": refererUrl,
}),
options: Options(
contentType: Headers.formUrlEncodedContentType,
headers: {
"Referer": refererUrl,
},
),
);
if (res.data['code'] == 0) {
@@ -387,7 +395,7 @@ class LoginHttp {
'status': false,
'code': res.data['code'],
'msg': res.data['message'],
'data': res.data['data']
'data': res.data['data'],
};
}
}
@@ -414,10 +422,12 @@ class LoginHttp {
var res = await Request().post(
Api.safeCenterSmsVerify,
data: data,
options:
Options(contentType: Headers.formUrlEncodedContentType, headers: {
"Referer": refererUrl,
}),
options: Options(
contentType: Headers.formUrlEncodedContentType,
headers: {
"Referer": refererUrl,
},
),
);
if (res.data['code'] == 0) {
@@ -427,7 +437,7 @@ class LoginHttp {
'status': false,
'code': res.data['code'],
'msg': res.data['message'],
'data': res.data['data']
'data': res.data['data'],
};
}
}
@@ -473,7 +483,7 @@ class LoginHttp {
'status': false,
'code': res.data['code'],
'msg': res.data['message'],
'data': res.data['data']
'data': res.data['data'],
};
}
}
@@ -483,8 +493,9 @@ class LoginHttp {
Api.logout,
data: {'biliCSRF': account.csrf},
options: Options(
contentType: Headers.formUrlEncodedContentType,
extra: {'account': account}),
contentType: Headers.formUrlEncodedContentType,
extra: {'account': account},
),
);
return {'status': res.data['code'] == 0, 'msg': res.data['message']};
}

View File

@@ -99,7 +99,8 @@ class MemberHttp {
);
if (res.data['code'] == 0) {
return Success(
SpaceSsData.fromJson(res.data['data']?['items_lists'] ?? {}));
SpaceSsData.fromJson(res.data['data']?['items_lists'] ?? {}),
);
} else {
return Error(res.data['message']);
}
@@ -172,7 +173,7 @@ class MemberHttp {
'ps': 20,
'order': 1,
'uid': mid,
'web_location': 333.1387
'web_location': 333.1387,
},
);
if (res.data['code'] == 0) {
@@ -286,7 +287,7 @@ class MemberHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': MemberInfoModel.fromJson(res.data['data'])
'data': MemberInfoModel.fromJson(res.data['data']),
};
} else {
return {'status': false, 'msg': res.data['message']};
@@ -313,7 +314,7 @@ class MemberHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': MemberCardInfoData.fromJson(res.data['data'])
'data': MemberCardInfoData.fromJson(res.data['data']),
};
} else {
return {'status': false, 'msg': res.data['message']};
@@ -349,11 +350,13 @@ class MemberHttp {
var res = await Request().get(
Api.searchArchive,
queryParameters: params,
options: Options(headers: {
HttpHeaders.userAgentHeader: Request.headerUa(type: 'pc'),
HttpHeaders.refererHeader: '${HttpString.spaceBaseUrl}/$mid',
'origin': HttpString.spaceBaseUrl,
}),
options: Options(
headers: {
HttpHeaders.userAgentHeader: Request.headerUa(type: 'pc'),
HttpHeaders.refererHeader: '${HttpString.spaceBaseUrl}/$mid',
'origin': HttpString.spaceBaseUrl,
},
),
);
if (res.data['code'] == 0) {
return Success(SearchArchiveData.fromJson(res.data['data']));
@@ -465,7 +468,7 @@ class MemberHttp {
'status': true,
'data': res.data['data']
.map<MemberTagItemModel>((e) => MemberTagItemModel.fromJson(e))
.toList()
.toList(),
};
} else {
return {'status': false, 'msg': res.data['message']};
@@ -502,7 +505,7 @@ class MemberHttp {
Api.addUsers,
queryParameters: {
'x-bili-device-req-json':
'{"platform":"web","device":"pc","spmid":"333.1387"}'
'{"platform":"web","device":"pc","spmid":"333.1387"}',
},
data: {
'fids': fids.join(','),
@@ -538,10 +541,13 @@ class MemberHttp {
},
);
if (res.data['code'] == 0) {
return Success(FollowData(
return Success(
FollowData(
list: (res.data['data'] as List?)
?.map<FollowItemModel>((e) => FollowItemModel.fromJson(e))
.toList()));
.toList(),
),
);
} else {
return Error(res.data['message']);
}
@@ -622,7 +628,7 @@ class MemberHttp {
'status': true,
'data': res.data['data']
.map<MemberTagItemModel>((e) => MemberTagItemModel.fromJson(e))
.toList()
.toList(),
};
} else {
return {'status': false, 'msg': res.data['message']};
@@ -631,8 +637,10 @@ class MemberHttp {
// 获取up播放数、点赞数
static Future memberView({required int mid}) async {
var res = await Request()
.get(Api.getMemberViewApi, queryParameters: {'mid': mid});
var res = await Request().get(
Api.getMemberViewApi,
queryParameters: {'mid': mid},
);
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
@@ -658,11 +666,14 @@ class MemberHttp {
'web_location': 333.999,
};
Map params = await WbiSign.makSign(data);
var res = await Request().get(Api.followSearch, queryParameters: {
...data,
'w_rid': params['w_rid'],
'wts': params['wts'],
});
var res = await Request().get(
Api.followSearch,
queryParameters: {
...data,
'w_rid': params['w_rid'],
'wts': params['wts'],
},
);
if (res.data['code'] == 0) {
return Success(FollowData.fromJson(res.data['data']));
} else {

View File

@@ -41,8 +41,10 @@ class MsgHttp {
}
}
static Future<LoadingState<MsgAtData>> msgFeedAtMe(
{int? cursor, int? cursorTime}) async {
static Future<LoadingState<MsgAtData>> msgFeedAtMe({
int? cursor,
int? cursorTime,
}) async {
var res = await Request().get(
Api.msgFeedAt,
queryParameters: {
@@ -61,16 +63,21 @@ class MsgHttp {
}
}
static Future<LoadingState<MsgLikeData>> msgFeedLikeMe(
{int? cursor, int? cursorTime}) async {
var res = await Request().get(Api.msgFeedLike, queryParameters: {
'id': ?cursor,
'like_time': ?cursorTime,
'platform': 'web',
'mobi_app': 'web',
'build': 0,
'web_location': 333.40164,
});
static Future<LoadingState<MsgLikeData>> msgFeedLikeMe({
int? cursor,
int? cursorTime,
}) async {
var res = await Request().get(
Api.msgFeedLike,
queryParameters: {
'id': ?cursor,
'like_time': ?cursorTime,
'platform': 'web',
'mobi_app': 'web',
'build': 0,
'web_location': 333.40164,
},
);
if (res.data['code'] == 0) {
return Success(MsgLikeData.fromJson(res.data['data']));
} else {
@@ -101,8 +108,10 @@ class MsgHttp {
}
}
static Future<LoadingState<List<MsgSysItem>?>> msgFeedNotify(
{int? cursor, int pageSize = 20}) async {
static Future<LoadingState<List<MsgSysItem>?>> msgFeedNotify({
int? cursor,
int pageSize = 20,
}) async {
var res = await Request().get(
Api.msgSysNotify,
queryParameters: {
@@ -114,9 +123,11 @@ class MsgHttp {
},
);
if (res.data['code'] == 0) {
return Success((res.data['data'] as List?)
?.map((e) => MsgSysItem.fromJson(e))
.toList());
return Success(
(res.data['data'] as List?)
?.map((e) => MsgSysItem.fromJson(e))
.toList(),
);
} else {
return Error(res.data['message']);
}
@@ -124,10 +135,13 @@ class MsgHttp {
static Future msgSysUpdateCursor(int cursor) async {
String csrf = Accounts.main.csrf;
var res = await Request().get(Api.msgSysUpdateCursor, queryParameters: {
'csrf': csrf,
'cursor': cursor,
});
var res = await Request().get(
Api.msgSysUpdateCursor,
queryParameters: {
'csrf': csrf,
'cursor': cursor,
},
);
if (res.data['code'] == 0) {
return {
'status': true,
@@ -254,7 +268,7 @@ class MsgHttp {
'build': 0,
'mobi_app': 'web',
'csrf_token': csrf,
'csrf': csrf
'csrf': csrf,
});
var res = await Request().post(
HttpString.tUrl + Api.removeMsg,
@@ -336,10 +350,12 @@ class MsgHttp {
'build': 0,
'mobi_app': 'web',
'csrf_token': csrf,
'csrf': csrf
'csrf': csrf,
});
var res = await Request()
.post(HttpString.tUrl + Api.setTop, data: FormData.fromMap(data));
var res = await Request().post(
HttpString.tUrl + Api.setTop,
data: FormData.fromMap(data),
);
if (res.data['code'] == 0) {
return {'status': true};
} else {
@@ -363,7 +379,7 @@ class MsgHttp {
'build': 0,
'mobi_app': 'web',
'csrf_token': csrf,
'csrf': csrf
'csrf': csrf,
});
var res = await Request().get(Api.ackSessionMsg, queryParameters: params);
if (res.data['code'] == 0) {
@@ -374,7 +390,8 @@ class MsgHttp {
} else {
return {
'status': false,
'msg': "message: ${res.data['message']},"
'msg':
"message: ${res.data['message']},"
" msg: ${res.data['msg']},"
" code: ${res.data['code']}",
};
@@ -530,9 +547,11 @@ class MsgHttp {
},
);
if (res.data['code'] == 0) {
return Success((res.data['data'] as List?)
?.map((e) => ImUserInfosData.fromJson(e))
.toList());
return Success(
(res.data['data'] as List?)
?.map((e) => ImUserInfosData.fromJson(e))
.toList(),
);
} else {
return Error(res.data['message']);
}
@@ -575,9 +594,11 @@ class MsgHttp {
},
);
if (res.data['code'] == 0) {
return Success((res.data['data']?['uid_settings'] as List?)
?.map((e) => UidSetting.fromJson(e))
.toList());
return Success(
(res.data['data']?['uid_settings'] as List?)
?.map((e) => UidSetting.fromJson(e))
.toList(),
);
} else {
return Error(res.data['message']);
}
@@ -596,7 +617,7 @@ class MsgHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': SingleUnreadData.fromJson(res.data['data'])
'data': SingleUnreadData.fromJson(res.data['data']),
};
} else {
return {'status': false, 'data': res.data['message']};
@@ -615,7 +636,7 @@ class MsgHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': MsgFeedUnreadData.fromJson(res.data['data'])
'data': MsgFeedUnreadData.fromJson(res.data['data']),
};
} else {
return {'status': false, 'data': res.data['message']};

View File

@@ -12,8 +12,9 @@ import 'package:PiliPlus/utils/accounts/account.dart';
import 'package:dio/dio.dart';
class ReplyHttp {
static final Options _options =
Options(extra: {'account': AnonymousAccount(), 'checkReply': true});
static final Options _options = Options(
extra: {'account': AnonymousAccount(), 'checkReply': true},
);
static Future<LoadingState> replyList({
required bool isLogin,
@@ -229,12 +230,16 @@ class ReplyHttp {
}
}
static Future<LoadingState<List<Package>?>> getEmoteList(
{String? business}) async {
var res = await Request().get(Api.myEmote, queryParameters: {
'business': business ?? 'reply',
'web_location': '333.1245',
});
static Future<LoadingState<List<Package>?>> getEmoteList({
String? business,
}) async {
var res = await Request().get(
Api.myEmote,
queryParameters: {
'business': business ?? 'reply',
'web_location': '333.1245',
},
);
if (res.data['code'] == 0) {
return Success(EmoteModelData.fromJson(res.data['data']).packages);
} else {

View File

@@ -29,9 +29,15 @@ class RetryInterceptor extends Interceptor {
}
Request.dio
.fetch(options)
.then((i) => handler.resolve(i
..redirects.add(RedirectRecord(status, options.method, uri))
..isRedirect = true))
.then(
(i) => handler.resolve(
i
..redirects.add(
RedirectRecord(status, options.method, uri),
)
..isRedirect = true,
),
)
.onError<DioException>((error, _) => handler.next(error));
return;
}
@@ -46,13 +52,14 @@ class RetryInterceptor extends Interceptor {
case DioExceptionType.unknown:
if ((err.requestOptions.extra['_rt'] ??= 0) < _count) {
Future.delayed(
Duration(
milliseconds: ++err.requestOptions.extra['_rt'] * _delay),
() => Request.dio
.fetch(err.requestOptions)
.then(handler.resolve)
.onError<DioException>(
(error, _) => handler.reject(error)));
Duration(
milliseconds: ++err.requestOptions.extra['_rt'] * _delay,
),
() => Request.dio
.fetch(err.requestOptions)
.then(handler.resolve)
.onError<DioException>((error, _) => handler.reject(error)),
);
} else {
handler.next(err);
}

View File

@@ -175,8 +175,10 @@ class SearchHttp {
}
}
static Future<LoadingState<PgcInfoModel>> pgcInfoNew(
{int? seasonId, int? epId}) async {
static Future<LoadingState<PgcInfoModel>> pgcInfoNew({
int? seasonId,
int? epId,
}) async {
var res = await Request().get(
Api.pgcInfo,
queryParameters: {
@@ -226,8 +228,9 @@ class SearchHttp {
}
}
static Future<LoadingState<SearchTrendingData>> searchTrending(
{int limit = 30}) async {
static Future<LoadingState<SearchTrendingData>> searchTrending({
int limit = 30,
}) async {
final res = await Request().get(
Api.searchTrending,
queryParameters: {

View File

@@ -81,12 +81,15 @@ class UserHttp {
int? max,
int? viewAt,
}) async {
var res = await Request().get(Api.historyList, queryParameters: {
'type': type,
'ps': 20,
'max': max ?? 0,
'view_at': viewAt ?? 0,
});
var res = await Request().get(
Api.historyList,
queryParameters: {
'type': type,
'ps': 20,
'max': max ?? 0,
'view_at': viewAt ?? 0,
},
);
if (res.data['code'] == 0) {
return Success(HistoryData.fromJson(res.data['data']));
} else {
@@ -151,7 +154,7 @@ class UserHttp {
static Future toViewDel({required List<int?> aids}) async {
final Map<String, dynamic> params = {
'csrf': Accounts.main.csrf,
'resources': aids.join(',')
'resources': aids.join(','),
};
var res = await Request().post(
Api.toViewDel,
@@ -235,8 +238,10 @@ class UserHttp {
}
// 搜索历史记录
static Future<LoadingState<HistoryData>> searchHistory(
{required int pn, required String keyword}) async {
static Future<LoadingState<HistoryData>> searchHistory({
required int pn,
required String keyword,
}) async {
var res = await Request().get(
Api.searchHistory,
queryParameters: {
@@ -275,8 +280,10 @@ class UserHttp {
}
static Future<Map<String, dynamic>> videoTags({required String bvid}) async {
var res =
await Request().get(Api.videoTags, queryParameters: {'bvid': bvid});
var res = await Request().get(
Api.videoTags,
queryParameters: {'bvid': bvid},
);
if (res.data['code'] == 0) {
List<VideoTagItem>? list = (res.data['data'] as List?)
?.map((e) => VideoTagItem.fromJson(e))

View File

@@ -39,8 +39,10 @@ class VideoHttp {
static bool enableFilter = zoneRegExp.pattern.isNotEmpty;
// 首页推荐视频
static Future<LoadingState> rcmdVideoList(
{required int ps, required int freshIdx}) async {
static Future<LoadingState> rcmdVideoList({
required int ps,
required int freshIdx,
}) async {
var res = await Request().get(
Api.recommendListWeb,
queryParameters: {
@@ -50,7 +52,7 @@ class VideoHttp {
'ps': ps,
'fresh_idx': freshIdx,
'brush': freshIdx,
'fresh_type': 4
'fresh_type': 4,
},
);
if (res.data['code'] == 0) {
@@ -101,26 +103,28 @@ class VideoHttp {
's_locale': 'zh_CN',
'splash_id': '',
'statistics': Constants.statistics,
'voice_balance': '0'
'voice_balance': '0',
};
var res = await Request().get(
Api.recommendListApp,
queryParameters: data,
options: Options(headers: {
'buvid': LoginHttp.buvid,
'fp_local':
'1111111111111111111111111111111111111111111111111111111111111111',
'fp_remote':
'1111111111111111111111111111111111111111111111111111111111111111',
'session_id': '11111111',
'env': 'prod',
'app-key': 'android_hd',
'User-Agent': Constants.userAgent,
'x-bili-trace-id': Constants.traceId,
'x-bili-aurora-eid': '',
'x-bili-aurora-zone': '',
'bili-http-engine': 'cronet',
}),
options: Options(
headers: {
'buvid': LoginHttp.buvid,
'fp_local':
'1111111111111111111111111111111111111111111111111111111111111111',
'fp_remote':
'1111111111111111111111111111111111111111111111111111111111111111',
'session_id': '11111111',
'env': 'prod',
'app-key': 'android_hd',
'User-Agent': Constants.userAgent,
'x-bili-trace-id': Constants.traceId,
'x-bili-aurora-eid': '',
'x-bili-aurora-zone': '',
'bili-http-engine': 'cronet',
},
),
);
if (res.data['code'] == 0) {
List<RecVideoItemAppModel> list = <RecVideoItemAppModel>[];
@@ -150,8 +154,10 @@ class VideoHttp {
}
// 最热视频
static Future<LoadingState<List<HotVideoItemModel>>> hotVideoList(
{required int pn, required int ps}) async {
static Future<LoadingState<List<HotVideoItemModel>>> hotVideoList({
required int pn,
required int ps,
}) async {
var res = await Request().get(
Api.hotList,
queryParameters: {'pn': pn, 'ps': ps},
@@ -162,7 +168,9 @@ class VideoHttp {
if (!GlobalData().blackMids.contains(i['owner']['mid']) &&
!RecommendFilter.filterTitle(i['title']) &&
!RecommendFilter.filterLikeRatio(
i['stat']['like'], i['stat']['view'])) {
i['stat']['like'],
i['stat']['view'],
)) {
if (enableFilter &&
i['tname'] != null &&
zoneRegExp.hasMatch(i['tname'])) {
@@ -219,8 +227,8 @@ class VideoHttp {
late PlayUrlModel data;
if (epid != null && usePgcApi) {
data = PlayUrlModel.fromJson(res.data['result']['video_info'])
..lastPlayTime = res.data['result']['play_view_business_info']
['user_status']['watch_progress']['current_watch_progress'];
..lastPlayTime = res
.data['result']['play_view_business_info']['user_status']['watch_progress']['current_watch_progress'];
} else {
data = PlayUrlModel.fromJson(res.data['data']);
}
@@ -252,10 +260,13 @@ class VideoHttp {
}
// 视频信息 标题、简介
static Future<LoadingState<VideoDetailData>> videoIntro(
{required String bvid}) async {
var res =
await Request().get(Api.videoIntro, queryParameters: {'bvid': bvid});
static Future<LoadingState<VideoDetailData>> videoIntro({
required String bvid,
}) async {
var res = await Request().get(
Api.videoIntro,
queryParameters: {'bvid': bvid},
);
VideoDetailResponse data = VideoDetailResponse.fromJson(res.data);
if (data.code == 0) {
return Success(data.data!);
@@ -286,13 +297,17 @@ class VideoHttp {
}
// 相关视频
static Future<LoadingState<List<HotVideoItemModel>?>> relatedVideoList(
{required String bvid}) async {
var res =
await Request().get(Api.relatedList, queryParameters: {'bvid': bvid});
static Future<LoadingState<List<HotVideoItemModel>?>> relatedVideoList({
required String bvid,
}) async {
var res = await Request().get(
Api.relatedList,
queryParameters: {'bvid': bvid},
);
if (res.data['code'] == 0) {
final items = (res.data['data'] as List?)
?.map((i) => HotVideoItemModel.fromJson(i));
final items = (res.data['data'] as List?)?.map(
(i) => HotVideoItemModel.fromJson(i),
);
final list = RecommendFilter.applyFilterToRelatedVideos
? items?.where((i) => !RecommendFilter.filterAll(i)).toList()
: items?.toList();
@@ -426,29 +441,33 @@ class VideoHttp {
} else {
return {
'status': false,
'msg': res.data is String ? res.data : res.data['message']
'msg': res.data is String ? res.data : res.data['message'],
};
}
}
// 推送不感兴趣反馈
static Future feedDislike(
{required String goto,
required int id,
int? reasonId,
int? feedbackId}) async {
static Future feedDislike({
required String goto,
required int id,
int? reasonId,
int? feedbackId,
}) async {
if (Accounts.get(AccountType.recommend).accessKey.isNullOrEmpty) {
return {'status': false, 'msg': "请退出账号后重新登录"};
}
assert((reasonId != null) ^ (feedbackId != null));
var res = await Request().get(Api.feedDislike, queryParameters: {
'goto': goto,
'id': id,
'reason_id': ?reasonId,
'feedback_id': ?feedbackId,
'build': '1',
'mobi_app': 'android',
});
var res = await Request().get(
Api.feedDislike,
queryParameters: {
'goto': goto,
'id': id,
'reason_id': ?reasonId,
'feedback_id': ?feedbackId,
'build': '1',
'mobi_app': 'android',
},
);
if (res.data['code'] == 0) {
return {'status': true};
} else {
@@ -457,22 +476,26 @@ class VideoHttp {
}
// 推送不感兴趣取消
static Future feedDislikeCancel(
{required String goto,
required int id,
int? reasonId,
int? feedbackId}) async {
static Future feedDislikeCancel({
required String goto,
required int id,
int? reasonId,
int? feedbackId,
}) async {
if (Accounts.get(AccountType.recommend).accessKey.isNullOrEmpty) {
return {'status': false, 'msg': "请退出账号后重新登录"};
}
var res = await Request().get(Api.feedDislikeCancel, queryParameters: {
'goto': goto,
'id': id,
'reason_id': ?reasonId,
'feedback_id': ?feedbackId,
'build': '1',
'mobi_app': 'android',
});
var res = await Request().get(
Api.feedDislikeCancel,
queryParameters: {
'goto': goto,
'id': id,
'reason_id': ?reasonId,
'feedback_id': ?feedbackId,
'build': '1',
'mobi_app': 'android',
},
);
if (res.data['code'] == 0) {
return {'status': true};
} else {
@@ -531,12 +554,15 @@ class VideoHttp {
required int oid,
required int rpid,
}) async {
var res = await Request().post(Api.replyDel, queryParameters: {
'type': type, //type.index
'oid': oid,
'rpid': rpid,
'csrf': Accounts.main.csrf,
});
var res = await Request().post(
Api.replyDel,
queryParameters: {
'type': type, //type.index
'oid': oid,
'rpid': rpid,
'csrf': Accounts.main.csrf,
},
);
log(res.toString());
if (res.data['code'] == 0) {
return {'status': true};
@@ -546,8 +572,11 @@ class VideoHttp {
}
// 操作用户关系
static Future relationMod(
{required int mid, required int act, required int reSrc}) async {
static Future relationMod({
required int mid,
required int act,
required int reSrc,
}) async {
var res = await Request().post(
Api.relationMod,
queryParameters: {
@@ -603,11 +632,14 @@ class VideoHttp {
aid,
type,
}) async {
await Request().post(Api.historyReport, queryParameters: {
'aid': ?aid,
'type': ?type,
'csrf': Accounts.main.csrf,
});
await Request().post(
Api.historyReport,
queryParameters: {
'aid': ?aid,
'type': ?type,
'csrf': Accounts.main.csrf,
},
);
}
// 视频播放进度
@@ -619,16 +651,19 @@ class VideoHttp {
seasonId,
subType,
}) async {
await Request().post(Api.heartBeat, queryParameters: {
'bvid': bvid,
'cid': cid,
'epid': ?epid,
'sid': ?seasonId,
if (epid != null) 'type': 4,
'sub_type': ?subType,
'played_time': progress,
'csrf': Accounts.main.csrf,
});
await Request().post(
Api.heartBeat,
queryParameters: {
'bvid': bvid,
'cid': cid,
'epid': ?epid,
'sid': ?seasonId,
if (epid != null) 'type': 4,
'sub_type': ?subType,
'played_time': progress,
'csrf': Accounts.main.csrf,
},
);
}
static Future medialistHistory({
@@ -636,52 +671,65 @@ class VideoHttp {
required dynamic oid,
required dynamic upperMid,
}) async {
await Request().post(Api.mediaListHistory, queryParameters: {
'desc': desc,
'oid': oid,
'upper_mid': upperMid,
'csrf': Accounts.main.csrf,
});
await Request().post(
Api.mediaListHistory,
queryParameters: {
'desc': desc,
'oid': oid,
'upper_mid': upperMid,
'csrf': Accounts.main.csrf,
},
);
}
// 添加追番
static Future pgcAdd({int? seasonId}) async {
var res = await Request().post(Api.pgcAdd, queryParameters: {
'season_id': seasonId,
'csrf': Accounts.main.csrf,
});
var res = await Request().post(
Api.pgcAdd,
queryParameters: {
'season_id': seasonId,
'csrf': Accounts.main.csrf,
},
);
if (res.data['code'] == 0) {
return {
'status': true,
'msg':
res.data['result'] == null ? 'failed' : res.data['result']['toast']
'msg': res.data['result'] == null
? 'failed'
: res.data['result']['toast'],
};
} else {
return {
'status': false,
'msg':
res.data['result'] == null ? 'failed' : res.data['result']['toast']
'msg': res.data['result'] == null
? 'failed'
: res.data['result']['toast'],
};
}
}
// 取消追番
static Future pgcDel({int? seasonId}) async {
var res = await Request().post(Api.pgcDel, queryParameters: {
'season_id': seasonId,
'csrf': Accounts.main.csrf,
});
var res = await Request().post(
Api.pgcDel,
queryParameters: {
'season_id': seasonId,
'csrf': Accounts.main.csrf,
},
);
if (res.data['code'] == 0) {
return {
'status': true,
'msg':
res.data['result'] == null ? 'failed' : res.data['result']['toast']
'msg': res.data['result'] == null
? 'failed'
: res.data['result']['toast'],
};
} else {
return {
'status': false,
'msg':
res.data['result'] == null ? 'failed' : res.data['result']['toast']
'msg': res.data['result'] == null
? 'failed'
: res.data['result']['toast'],
};
}
}
@@ -703,17 +751,22 @@ class VideoHttp {
);
return {
'status': res.data['code'] == 0,
'msg': res.data['result'] == null ? 'failed' : res.data['result']['toast']
'msg': res.data['result'] == null
? 'failed'
: res.data['result']['toast'],
};
}
// 查看视频同时在看人数
static Future onlineTotal({int? aid, String? bvid, int? cid}) async {
var res = await Request().get(Api.onlineTotal, queryParameters: {
'aid': aid,
'bvid': bvid,
'cid': cid,
});
var res = await Request().get(
Api.onlineTotal,
queryParameters: {
'aid': aid,
'bvid': bvid,
'cid': cid,
},
);
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']['total']};
} else {
@@ -777,9 +830,12 @@ class VideoHttp {
String processList(List list) {
final sb = StringBuffer('WEBVTT\n\n')
..writeAll(
list.map((item) =>
'${item?['sid'] ?? 0}\n${subtitleTimecode(item['from'])} --> ${subtitleTimecode(item['to'])}\n${item['content'].trim()}'),
'\n\n');
list.map(
(item) =>
'${item?['sid'] ?? 0}\n${subtitleTimecode(item['from'])} --> ${subtitleTimecode(item['to'])}\n${item['content'].trim()}',
),
'\n\n',
);
return sb.toString();
}
@@ -793,7 +849,8 @@ class VideoHttp {
// 视频排行
static Future<LoadingState<List<HotVideoItemModel>>> getRankVideoList(
int rid) async {
int rid,
) async {
var res = await Request().get(
Api.getRankApi,
queryParameters: await WbiSign.makSign({
@@ -807,7 +864,9 @@ class VideoHttp {
if (!GlobalData().blackMids.contains(i['owner']['mid']) &&
!RecommendFilter.filterTitle(i['title']) &&
!RecommendFilter.filterLikeRatio(
i['stat']['like'], i['stat']['view'])) {
i['stat']['like'],
i['stat']['view'],
)) {
if (enableFilter &&
i['tname'] != null &&
zoneRegExp.hasMatch(i['tname'])) {
@@ -823,8 +882,10 @@ class VideoHttp {
}
// pgc 排行
static Future<LoadingState> pgcRankList(
{int day = 3, required int seasonType}) async {
static Future<LoadingState> pgcRankList({
int day = 3,
required int seasonType,
}) async {
var res = await Request().get(
Api.pgcRank,
queryParameters: await WbiSign.makSign({
@@ -833,17 +894,21 @@ class VideoHttp {
}),
);
if (res.data['code'] == 0) {
return Success((res.data['result']?['list'] as List?)
?.map((e) => PgcRankItemModel.fromJson(e))
.toList());
return Success(
(res.data['result']?['list'] as List?)
?.map((e) => PgcRankItemModel.fromJson(e))
.toList(),
);
} else {
return Error(res.data['message']);
}
}
// pgc season 排行
static Future<LoadingState> pgcSeasonRankList(
{int day = 3, required int seasonType}) async {
static Future<LoadingState> pgcSeasonRankList({
int day = 3,
required int seasonType,
}) async {
var res = await Request().get(
Api.pgcSeasonRank,
queryParameters: await WbiSign.makSign({
@@ -852,9 +917,11 @@ class VideoHttp {
}),
);
if (res.data['code'] == 0) {
return Success((res.data['data']?['list'] as List?)
?.map((e) => PgcRankItemModel.fromJson(e))
.toList());
return Success(
(res.data['data']?['list'] as List?)
?.map((e) => PgcRankItemModel.fromJson(e))
.toList(),
);
} else {
return Error(res.data['message']);
}