mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
replace grpc to dio (#313)
* replace grpc to dio * load danmaku from grpc
This commit is contained in:
committed by
GitHub
parent
9e242fb902
commit
347a704b54
@@ -419,7 +419,7 @@ class Api {
|
||||
// https://api.bilibili.com/x/player/online/total?aid=913663681&cid=1203559746&bvid=BV1MM4y1s7NZ&ts=56427838
|
||||
static const String onlineTotal = '/x/player/online/total';
|
||||
|
||||
static const String webDanmaku = '/x/v2/dm/web/seg.so';
|
||||
// static const String webDanmaku = '/x/v2/dm/web/seg.so';
|
||||
|
||||
// 发送视频弹幕
|
||||
//https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/danmaku/action.md
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:PiliPlus/grpc/dm/v1/dm.pb.dart';
|
||||
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'index.dart';
|
||||
@@ -11,20 +12,12 @@ class DanmakuHttp {
|
||||
required bool mergeDanmaku,
|
||||
}) async {
|
||||
// 构建参数对象
|
||||
Map<String, int> params = {
|
||||
'type': 1,
|
||||
'oid': cid,
|
||||
'segment_index': segmentIndex,
|
||||
};
|
||||
var response = await Request().get(
|
||||
Api.webDanmaku,
|
||||
queryParameters: params,
|
||||
options: Options(responseType: ResponseType.bytes),
|
||||
);
|
||||
if (response.statusCode != 200 || response.data == null) {
|
||||
final response =
|
||||
await GrpcRepo.dmSegMobile(cid: cid, segmentIndex: segmentIndex);
|
||||
if (!response['status']) {
|
||||
return DmSegMobileReply();
|
||||
}
|
||||
DmSegMobileReply data = DmSegMobileReply.fromBuffer(response.data);
|
||||
DmSegMobileReply data = response['data'];
|
||||
if (mergeDanmaku) {
|
||||
data.elems.unique((item) => item.content);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ class ApiInterceptor extends Interceptor {
|
||||
Api.bangumiInfo,
|
||||
Api.liveRoomInfo,
|
||||
Api.onlineTotal,
|
||||
Api.webDanmaku,
|
||||
Api.dynamicDetail,
|
||||
Api.aiConclusion,
|
||||
Api.getSeasonDetailApi,
|
||||
@@ -44,6 +43,11 @@ class ApiInterceptor extends Interceptor {
|
||||
}
|
||||
}
|
||||
|
||||
// app端不需要cookie
|
||||
if (options.uri.host == 'app.bilibili.com') {
|
||||
options.headers['cookie'] = '';
|
||||
}
|
||||
|
||||
if (options.extra['clearCookie'] == true) {
|
||||
onRemoveCookie();
|
||||
} else if (MineController.anonymity.value) {
|
||||
|
||||
Reference in New Issue
Block a user