mod: cid获取

This commit is contained in:
guozhigq
2023-06-22 16:44:26 +08:00
parent 28e7980c47
commit 72361af269
5 changed files with 29 additions and 10 deletions

View File

@ -1,7 +1,9 @@
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/stat/view.dart';
import 'package:pilipala/http/search.dart';
import 'package:pilipala/utils/utils.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
@ -37,9 +39,14 @@ class VideoCardH extends StatelessWidget {
},
child: InkWell(
onTap: () async {
await Future.delayed(const Duration(milliseconds: 200));
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.cid}',
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
try {
int cid =
videoItem.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
Get.toNamed('/video?bvid=$bvid&cid=$cid',
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
} catch (err) {
SmartDialog.showToast(err.toString());
}
},
child: Column(
children: [

View File

@ -154,4 +154,7 @@ class Api {
// 记录视频播放进度
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/report.md
static const String heartBeat = '/x/click-interface/web/heartbeat';
// 查询视频分P列表 (avid/bvid转cid)
static const String ab2c = '/x/player/pagelist';
}

View File

@ -80,4 +80,15 @@ class SearchHttp {
};
}
}
static Future ab2c({int? aid, String? bvid}) async {
Map<String, dynamic> data = {};
if (aid != null) {
data['aid'] = aid;
} else if (bvid != null) {
data['bvid'] = bvid;
}
var res = await Request().get(Api.ab2c, data: {...data});
return res.data['data'].first['cid'];
}
}

View File

@ -73,7 +73,6 @@ class SearchVideoItemModel {
SearchVideoItemModel.fromJson(Map<String, dynamic> json) {
type = json['type'];
id = json['id'];
cid = json['id'];
arcurl = json['arcurl'];
aid = json['aid'];
bvid = json['bvid'];
@ -83,14 +82,13 @@ class SearchVideoItemModel {
videoReview = json['video_review'];
pubdate = json['pubdate'];
senddate = json['senddate'];
duration = test(json['duration']);
// duration = json['duration'];
duration = _dutation(json['duration']);
owner = Owner.fromJson(json);
stat = Stat.fromJson(json);
}
}
test(String duration) {
_dutation(String duration) {
List timeList = duration.split(':');
int len = timeList.length;
if (len == 2) {

View File

@ -46,15 +46,15 @@ class _VideoDetailPageState extends State<VideoDetailPage>
_meeduPlayerController = videoDetailController.meeduPlayerController;
_playerEventSubs = _meeduPlayerController!.onPlayerStatusChanged.listen(
(PlayerStatus status) {
// videoDetailController.markHeartBeat();
videoDetailController.markHeartBeat();
if (status == PlayerStatus.playing) {
Wakelock.enable();
isPlay = false;
isShowCover = false;
setState(() {});
// videoDetailController.loopHeartBeat();
videoDetailController.loopHeartBeat();
} else {
// videoDetailController.timer!.cancel();
videoDetailController.timer!.cancel();
isPlay = true;
setState(() {});
Wakelock.disable();