Merge branch 'main' into opt-dataInt
This commit is contained in:
@ -29,7 +29,7 @@ class Request {
|
|||||||
late String systemProxyPort;
|
late String systemProxyPort;
|
||||||
static final RegExp spmPrefixExp =
|
static final RegExp spmPrefixExp =
|
||||||
RegExp(r'<meta name="spm_prefix" content="([^"]+?)">');
|
RegExp(r'<meta name="spm_prefix" content="([^"]+?)">');
|
||||||
static late String buvid;
|
static String? buvid;
|
||||||
|
|
||||||
/// 设置cookie
|
/// 设置cookie
|
||||||
static setCookie() async {
|
static setCookie() async {
|
||||||
@ -72,7 +72,6 @@ class Request {
|
|||||||
.map((Cookie cookie) => '${cookie.name}=${cookie.value}')
|
.map((Cookie cookie) => '${cookie.name}=${cookie.value}')
|
||||||
.join('; ');
|
.join('; ');
|
||||||
|
|
||||||
buvid = cookie.firstWhere((e) => e.name == 'buvid3').value;
|
|
||||||
dio.options.headers['cookie'] = cookieString;
|
dio.options.headers['cookie'] = cookieString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +86,30 @@ class Request {
|
|||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<String> getBuvid() async {
|
||||||
|
if (buvid != null) {
|
||||||
|
return buvid!;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Cookie> cookies = await cookieManager.cookieJar
|
||||||
|
.loadForRequest(Uri.parse(HttpString.baseUrl));
|
||||||
|
buvid = cookies.firstWhere((cookie) => cookie.name == 'buvid3').value;
|
||||||
|
if (buvid == null) {
|
||||||
|
try {
|
||||||
|
var result = await Request().get(
|
||||||
|
"${HttpString.apiBaseUrl}/x/frontend/finger/spi",
|
||||||
|
);
|
||||||
|
buvid = result["data"]["b_3"].toString();
|
||||||
|
} catch (e) {
|
||||||
|
// 处理请求错误
|
||||||
|
buvid = '';
|
||||||
|
print("Error fetching buvid: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return buvid!;
|
||||||
|
}
|
||||||
|
|
||||||
static setOptionsHeaders(userInfo, bool status) {
|
static setOptionsHeaders(userInfo, bool status) {
|
||||||
if (status) {
|
if (status) {
|
||||||
dio.options.headers['x-bili-mid'] = userInfo.mid.toString();
|
dio.options.headers['x-bili-mid'] = userInfo.mid.toString();
|
||||||
|
|||||||
@ -47,6 +47,7 @@ class LiveRoomController extends GetxController {
|
|||||||
RxMap<String, String> joinRoomTip = {'userName': '', 'message': ''}.obs;
|
RxMap<String, String> joinRoomTip = {'userName': '', 'message': ''}.obs;
|
||||||
// 直播间弹幕开关 默认打开
|
// 直播间弹幕开关 默认打开
|
||||||
RxBool danmakuSwitch = true.obs;
|
RxBool danmakuSwitch = true.obs;
|
||||||
|
late String buvid;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -63,6 +64,7 @@ class LiveRoomController extends GetxController {
|
|||||||
if (liveItem != null && liveItem.cover != null && liveItem.cover != '') {
|
if (liveItem != null && liveItem.cover != null && liveItem.cover != '') {
|
||||||
cover = liveItem.cover;
|
cover = liveItem.cover;
|
||||||
}
|
}
|
||||||
|
Request.getBuvid().then((value) => buvid = value);
|
||||||
}
|
}
|
||||||
// CDN优化
|
// CDN优化
|
||||||
enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: true);
|
enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: true);
|
||||||
@ -249,7 +251,7 @@ class LiveRoomController extends GetxController {
|
|||||||
"uid": userId,
|
"uid": userId,
|
||||||
"roomid": roomId,
|
"roomid": roomId,
|
||||||
"protover": 3,
|
"protover": 3,
|
||||||
"buvid": Request.buvid,
|
"buvid": buvid,
|
||||||
"platform": "web",
|
"platform": "web",
|
||||||
"type": 2,
|
"type": 2,
|
||||||
"key": token,
|
"key": token,
|
||||||
|
|||||||
Reference in New Issue
Block a user