mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -14,12 +14,21 @@ class HtmlHttp {
|
|||||||
var response = await Request().get(
|
var response = await Request().get(
|
||||||
"https://www.bilibili.com/opus/$id",
|
"https://www.bilibili.com/opus/$id",
|
||||||
extra: {'ua': 'pc'},
|
extra: {'ua': 'pc'},
|
||||||
|
options: Options(
|
||||||
|
followRedirects: false,
|
||||||
|
validateStatus: (status) => true,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (response.data is! String && response.data is! List<int>) {
|
if (response.data is! String && response.data is! List<int>) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (response.data.contains('Redirecting to')) {
|
if (response.data.contains('Redirecting to')) {
|
||||||
|
String? cvid = RegExp(r'cv\d+').firstMatch(response.data)?.group(0);
|
||||||
|
if (cvid != null) {
|
||||||
|
return await reqReadHtml(cvid, dynamicType, false);
|
||||||
|
}
|
||||||
|
|
||||||
RegExp regex = RegExp(r'//([\w\.]+)/(\w+)/(\w+)');
|
RegExp regex = RegExp(r'//([\w\.]+)/(\w+)/(\w+)');
|
||||||
Match match = regex.firstMatch(response.data)!;
|
Match match = regex.firstMatch(response.data)!;
|
||||||
String matchedString = match.group(0)!;
|
String matchedString = match.group(0)!;
|
||||||
@@ -75,11 +84,13 @@ class HtmlHttp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read
|
// read
|
||||||
static Future reqReadHtml(id, dynamicType) async {
|
static Future reqReadHtml(id, dynamicType, [bool redirect = true]) async {
|
||||||
String? redirectUrl = await UrlUtils.parseRedirectUrl(
|
if (redirect) {
|
||||||
'https://www.bilibili.com/$dynamicType/$id/');
|
String? redirectUrl = await UrlUtils.parseRedirectUrl(
|
||||||
if (redirectUrl != null) {
|
'https://www.bilibili.com/$dynamicType/$id/');
|
||||||
return await reqHtml(redirectUrl.split('/').last, dynamicType);
|
if (redirectUrl != null) {
|
||||||
|
return await reqHtml(redirectUrl.split('/').last, dynamicType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var response = await Request().get(
|
var response = await Request().get(
|
||||||
|
|||||||
Reference in New Issue
Block a user