feat: 直播弹幕

This commit is contained in:
guozhigq
2024-08-18 23:30:51 +08:00
parent c0f7623e3c
commit 1012b5d009
11 changed files with 890 additions and 20 deletions

View File

@ -554,4 +554,8 @@ class Api {
/// 系统通知
static const String messageSystemAPi =
'${HttpString.messageBaseUrl}/x/sys-msg/query_unified_notify';
/// 直播间弹幕信息
static const String getDanmuInfo =
'${HttpString.liveBaseUrl}/xlive/web-room/v1/index/getDanmuInfo';
}

View File

@ -29,6 +29,7 @@ class Request {
late String systemProxyPort;
static final RegExp spmPrefixExp =
RegExp(r'<meta name="spm_prefix" content="([^"]+?)">');
static late String buvid;
/// 设置cookie
static setCookie() async {
@ -70,6 +71,8 @@ class Request {
final String cookieString = cookie
.map((Cookie cookie) => '${cookie.name}=${cookie.value}')
.join('; ');
buvid = cookie.firstWhere((e) => e.name == 'buvid3').value;
dio.options.headers['cookie'] = cookieString;
}

View File

@ -65,4 +65,23 @@ class LiveHttp {
};
}
}
// 获取弹幕信息
static Future liveDanmakuInfo({roomId}) async {
var res = await Request().get(Api.getDanmuInfo, data: {
'id': roomId,
});
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data'],
};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
}