Merge branch 'feature-readRender' into feature-opusRender
This commit is contained in:
@ -578,4 +578,7 @@ class Api {
|
||||
|
||||
/// 稍后再看&收藏夹视频列表
|
||||
static const String mediaList = '/x/v2/medialist/resource/list';
|
||||
|
||||
///
|
||||
static const String getViewInfo = '/x/article/viewinfo';
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import 'dart:convert';
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:pilipala/models/read/opus.dart';
|
||||
import 'init.dart';
|
||||
import 'package:pilipala/models/read/read.dart';
|
||||
import 'package:pilipala/utils/wbi_sign.dart';
|
||||
import 'index.dart';
|
||||
|
||||
class ReadHttp {
|
||||
static List<String> extractScriptContents(String htmlContent) {
|
||||
@ -57,4 +59,58 @@ class ReadHttp {
|
||||
'cvId': cvId,
|
||||
};
|
||||
}
|
||||
|
||||
// 解析专栏 cv格式
|
||||
static Future parseArticleCv({required String id}) async {
|
||||
var res = await Request().get(
|
||||
'https://www.bilibili.com/read/cv$id',
|
||||
extra: {'ua': 'pc'},
|
||||
);
|
||||
String scriptContent =
|
||||
extractScriptContents(parse(res.data).body!.outerHtml)[0];
|
||||
int startIndex = scriptContent.indexOf('{');
|
||||
int endIndex = scriptContent.lastIndexOf('};');
|
||||
String jsonContent = scriptContent.substring(startIndex, endIndex + 1);
|
||||
// 解析JSON字符串为Map
|
||||
Map<String, dynamic> jsonData = json.decode(jsonContent);
|
||||
return {
|
||||
'status': true,
|
||||
'data': ReadDataModel.fromJson(jsonData),
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
static Future getViewInfo({required String id}) async {
|
||||
Map params = await WbiSign().makSign({
|
||||
'id': id,
|
||||
'mobi_app': 'pc',
|
||||
'from': 'web',
|
||||
'gaia_source': 'main_web',
|
||||
'web_location': 333.976,
|
||||
});
|
||||
var res = await Request().get(
|
||||
Api.getViewInfo,
|
||||
data: {
|
||||
'id': id,
|
||||
'mobi_app': 'pc',
|
||||
'from': 'web',
|
||||
'gaia_source': 'main_web',
|
||||
'web_location': 333.976,
|
||||
'w_rid': params['w_rid'],
|
||||
'wts': params['wts'],
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': res.data['data'],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'data': [],
|
||||
'msg': res.data['message'],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +143,11 @@ class SearchHttp {
|
||||
}
|
||||
final dynamic res =
|
||||
await Request().get(Api.ab2c, data: <String, dynamic>{...data});
|
||||
return res.data['data'].first['cid'];
|
||||
if (res.data['code'] == 0) {
|
||||
return res.data['data'].first['cid'];
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> bangumiInfo(
|
||||
|
||||
Reference in New Issue
Block a user