mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -789,4 +789,8 @@ class Api {
|
||||
static const String articleView = '/x/article/view';
|
||||
|
||||
static const String opusDetail = '/x/polymer/web-dynamic/v1/opus/detail';
|
||||
|
||||
static const String gaiaVgateRegister = '/x/gaia-vgate/v1/register';
|
||||
|
||||
static const String gaiaVgateValidate = '/x/gaia-vgate/v1/validate';
|
||||
}
|
||||
|
||||
@@ -14,8 +14,13 @@ import 'api.dart';
|
||||
import 'init.dart';
|
||||
|
||||
class LiveHttp {
|
||||
static Future<LoadingState<List<LiveItemModel>?>> liveList(
|
||||
{int? vmid, int? pn, int? ps, String? orderType}) async {
|
||||
static Future<LoadingState<List<LiveItemModel>?>> liveList({
|
||||
int? vmid,
|
||||
int? pn,
|
||||
int? ps,
|
||||
String? orderType,
|
||||
String? gaiaVtoken,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.liveList,
|
||||
queryParameters: await WbiSign.makSign({
|
||||
@@ -23,6 +28,7 @@ class LiveHttp {
|
||||
'page_size': 30,
|
||||
'platform': 'web',
|
||||
'web_location': 0.0,
|
||||
if (gaiaVtoken != null) 'gaia_vtoken': gaiaVtoken,
|
||||
}),
|
||||
options: Options(
|
||||
headers: {
|
||||
@@ -30,6 +36,9 @@ class LiveHttp {
|
||||
'referer': 'https://live.bilibili.com/',
|
||||
'user-agent': Request.headerUa(type: 'pc'),
|
||||
},
|
||||
extra: gaiaVtoken == null
|
||||
? null
|
||||
: {'cookie': 'x-bili-gaia-vtoken=$gaiaVtoken'},
|
||||
),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
@@ -38,7 +47,11 @@ class LiveHttp {
|
||||
.toList();
|
||||
return LoadingState.success(list);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
String? vVoucher;
|
||||
if (gaiaVtoken == null && res.data['code'] == -352) {
|
||||
vVoucher = res.headers['x-bili-gaia-vvoucher']?.firstOrNull;
|
||||
}
|
||||
return LoadingState.error(vVoucher ?? res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
42
lib/http/validate.dart
Normal file
42
lib/http/validate.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class ValidateHttp {
|
||||
static Future gaiaVgateRegister(String vVoucher) async {
|
||||
final res = await Request().post(
|
||||
Api.gaiaVgateRegister,
|
||||
data: {'v_voucher': vVoucher},
|
||||
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 gaiaVgateValidate({
|
||||
required challenge,
|
||||
required seccode,
|
||||
required token,
|
||||
required validate,
|
||||
}) async {
|
||||
final res = await Request().post(
|
||||
Api.gaiaVgateValidate,
|
||||
data: {
|
||||
'challenge': challenge,
|
||||
'seccode': seccode,
|
||||
'token': token,
|
||||
'validate': validate,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user