feat: get bangumi last play time

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-02 11:26:30 +08:00
parent 28c2323ef1
commit 665f5cdeef
5 changed files with 44 additions and 13 deletions

View File

@@ -19,8 +19,8 @@ class Api {
static const String videoUrl = '/x/player/wbi/playurl';
// 番剧视频流
// https://api.bilibili.com/pgc/player/web/playurl?cid=104236640&bvid=BV13t411n7ex
static const String bangumiVideoUrl = '/pgc/player/web/playurl';
// https://api.bilibili.com/pgc/player/web/v2/playurl?cid=104236640&bvid=BV13t411n7ex
static const String bangumiVideoUrl = '/pgc/player/web/v2/playurl';
// 字幕
// aid, cid

View File

@@ -195,20 +195,24 @@ class VideoHttp {
}
// 视频流
static Future videoUrl(
{int? avid, String? bvid, required int cid, int? qn}) async {
static Future videoUrl({
int? avid,
String? bvid,
required int cid,
int? qn,
dynamic epid,
dynamic seasonId,
}) async {
Map<String, dynamic> data = {
if (avid != null) 'avid': avid,
if (bvid != null) 'bvid': bvid,
if (epid != null) 'ep_id': epid,
if (seasonId != null) 'season_id': seasonId,
'cid': cid,
'qn': qn ?? 80,
// 获取所有格式的视频
'fnval': 4048,
};
if (avid != null) {
data['avid'] = avid;
}
if (bvid != null) {
data['bvid'] = bvid;
}
// 免登录查看1080p
if ((GStorage.userInfo.get('userInfoCache') == null ||
@@ -226,11 +230,21 @@ class VideoHttp {
});
try {
var res = await Request().get(Api.videoUrl, queryParameters: params);
var res = epid != null
? await Request().get(Api.bangumiVideoUrl, queryParameters: params)
: await Request().get(Api.videoUrl, queryParameters: params);
if (res.data['code'] == 0) {
late PlayUrlModel data;
if (epid != null) {
data = PlayUrlModel.fromJson(res.data['result']['video_info'])
..lastPlayTime = res.data['result']['play_view_business_info']
['user_status']['watch_progress']['last_time'];
} else {
data = PlayUrlModel.fromJson(res.data['data']);
}
return {
'status': true,
'data': PlayUrlModel.fromJson(res.data['data'])
'data': data,
};
} else {
return {

View File

@@ -551,6 +551,10 @@ class BangumiIntroController extends CommonController {
scriptContent['props']['pageProps']['followState']['isFollowed'];
followStatus.value =
scriptContent['props']['pageProps']['followState']['followStatus'];
// int progress = scriptContent['props']['pageProps']['dehydratedState']
// ['queries'][0]['state']['data']['result']
// ['play_view_business_info']['user_status']['watch_progress']
// ['current_watch_progress'];
}
}
}

View File

@@ -1078,7 +1078,12 @@ class VideoDetailController extends GetxController
defaultValue: AudioQuality.k192.code);
});
}
var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid);
var result = await VideoHttp.videoUrl(
cid: cid.value,
bvid: bvid,
epid: epId,
seasonId: seasonId,
);
if (result['status']) {
data = result['data'];
if (enableSponsorBlock) {

View File

@@ -34,6 +34,14 @@ class Utils {
static const channel = MethodChannel("pilipalax");
static void showCopyTextDialog(text) {
Get.dialog(
AlertDialog(
content: SelectableText('$text'),
),
);
}
static Future<dynamic> getWwebid(mid) async {
try {
dynamic response =