mod: av替换为bv

This commit is contained in:
guozhigq
2023-06-22 16:15:20 +08:00
parent 4e47281e7d
commit 28e7980c47
17 changed files with 98 additions and 71 deletions

View File

@ -22,6 +22,7 @@ class VideoCardH extends StatelessWidget {
@override
Widget build(BuildContext context) {
int aid = videoItem.aid;
String bvid = videoItem.bvid;
String heroTag = Utils.makeHeroTag(aid);
return GestureDetector(
onLongPress: () {
@ -37,7 +38,7 @@ class VideoCardH extends StatelessWidget {
child: InkWell(
onTap: () async {
await Future.delayed(const Duration(milliseconds: 200));
Get.toNamed('/video?aid=$aid&cid=${videoItem.cid}',
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.cid}',
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
},
child: Column(

View File

@ -44,7 +44,8 @@ class VideoCardV extends StatelessWidget {
child: InkWell(
onTap: () async {
await Future.delayed(const Duration(milliseconds: 200));
Get.toNamed('/video?aid=${videoItem.id}&cid=${videoItem.cid}',
print(videoItem.bvid);
Get.toNamed('/video?bvid=${videoItem.bvid}&cid=${videoItem.cid}',
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
},
child: Column(

View File

@ -3,7 +3,7 @@ import 'package:pilipala/http/init.dart';
class ReplyHttp {
static Future replyList({
required String oid,
required int oid,
required int pageNum,
required int type,
int sort = 1,
@ -36,7 +36,7 @@ class ReplyHttp {
}
static Future replyReplyList({
required String oid,
required int oid,
required String root,
required int pageNum,
required int type,

View File

@ -62,10 +62,10 @@ class VideoHttp {
// 视频流
static Future videoUrl(
{int? avid, int? bvid, required int cid, int? qn}) async {
{int? avid, String? bvid, required int cid, int? qn}) async {
Map<String, dynamic> data = {
'avid': avid,
// 'bvid': bvid,
// 'avid': avid,
'bvid': bvid,
'cid': cid,
// 'qn': qn ?? 80,
// 获取所有格式的视频
@ -99,8 +99,8 @@ class VideoHttp {
}
// 视频信息 标题、简介
static Future videoIntro({required String aid}) async {
var res = await Request().get(Api.videoIntro, data: {'aid': aid});
static Future videoIntro({required String bvid}) async {
var res = await Request().get(Api.videoIntro, data: {'bvid': bvid});
VideoDetailResponse result = VideoDetailResponse.fromJson(res.data);
if (result.code == 0) {
return {'status': true, 'data': result.data!};
@ -121,8 +121,8 @@ class VideoHttp {
}
// 相关视频
static Future relatedVideoList({required String aid}) async {
var res = await Request().get(Api.relatedList, data: {'aid': aid});
static Future relatedVideoList({required String bvid}) async {
var res = await Request().get(Api.relatedList, data: {'bvid': bvid});
if (res.data['code'] == 0) {
List<HotVideoItemModel> list = [];
for (var i in res.data['data']) {
@ -135,8 +135,8 @@ class VideoHttp {
}
// 获取点赞状态
static Future hasLikeVideo({required String aid}) async {
var res = await Request().get(Api.hasLikeVideo, data: {'aid': aid});
static Future hasLikeVideo({required String bvid}) async {
var res = await Request().get(Api.hasLikeVideo, data: {'bvid': bvid});
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
@ -145,8 +145,8 @@ class VideoHttp {
}
// 获取投币状态
static Future hasCoinVideo({required String aid}) async {
var res = await Request().get(Api.hasCoinVideo, data: {'aid': aid});
static Future hasCoinVideo({required String bvid}) async {
var res = await Request().get(Api.hasCoinVideo, data: {'bvid': bvid});
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
@ -155,11 +155,11 @@ class VideoHttp {
}
// 投币
static Future coinVideo({required String aid, required int multiply}) async {
static Future coinVideo({required String bvid, required int multiply}) async {
var res = await Request().post(
Api.coinVideo,
queryParameters: {
'aid': aid,
'bvid': bvid,
'multiply': multiply,
'select_like': 0,
'csrf': await Request.getCsrf(),
@ -173,7 +173,7 @@ class VideoHttp {
}
// 获取收藏状态
static Future hasFavVideo({required String aid}) async {
static Future hasFavVideo({required int aid}) async {
var res = await Request().get(Api.hasFavVideo, data: {'aid': aid});
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
@ -183,11 +183,11 @@ class VideoHttp {
}
// 一键三连
static Future oneThree({required String aid}) async {
static Future oneThree({required String bvid}) async {
var res = await Request().post(
Api.oneThree,
queryParameters: {
'aid': aid,
'bvid': bvid,
'csrf': await Request.getCsrf(),
},
);
@ -199,11 +199,11 @@ class VideoHttp {
}
// (取消)点赞
static Future likeVideo({required String aid, required bool type}) async {
static Future likeVideo({required String bvid, required bool type}) async {
var res = await Request().post(
Api.likeVideo,
queryParameters: {
'aid': aid,
'bvid': bvid,
'like': type ? 1 : 2,
'csrf': await Request.getCsrf(),
},
@ -217,7 +217,7 @@ class VideoHttp {
// (取消)收藏
static Future favVideo(
{required String aid, String? addIds, String? delIds}) async {
{required int aid, String? addIds, String? delIds}) async {
var res = await Request().post(Api.favVideo, queryParameters: {
'rid': aid,
'type': 2,
@ -233,7 +233,7 @@ class VideoHttp {
}
// 查看视频被收藏在哪个文件夹
static Future videoInFolder({required int mid, required String rid}) async {
static Future videoInFolder({required int mid, required int rid}) async {
var res = await Request()
.get(Api.videoInFolder, data: {'up_mid': mid, 'rid': rid});
if (res.data['code'] == 0) {
@ -305,10 +305,10 @@ class VideoHttp {
}
// 视频播放进度
static Future heartBeat({aid, progress, realtime}) async {
static Future heartBeat({bvid, progress, realtime}) async {
var res = await Request().post(Api.heartBeat, queryParameters: {
'aid': aid,
// 'bvid': '',
// 'aid': aid,
'bvid': bvid,
// 'cid': '',
// 'epid': '',
// 'sid': '',

View File

@ -76,6 +76,7 @@ class SearchVideoItemModel {
cid = json['id'];
arcurl = json['arcurl'];
aid = json['aid'];
bvid = json['bvid'];
title = json['title'].replaceAll(RegExp(r'<.*?>'), '');
description = json['description'];
pic = 'https:${json['pic']}';

View File

@ -4,6 +4,7 @@ import 'package:pilipala/http/user.dart';
import 'package:pilipala/http/video.dart';
import 'package:pilipala/models/user/fav_detail.dart';
import 'package:pilipala/models/user/fav_folder.dart';
import 'package:pilipala/utils/id_utils.dart';
class FavDetailController extends GetxController {
FavFolderItemData? item;
@ -20,6 +21,7 @@ class FavDetailController extends GetxController {
}
Future<dynamic> queryUserFavFolderDetail() async {
print('🐯🐯虎');
var res = await await UserHttp.userFavFolderDetail(
pn: 1,
ps: 15,
@ -31,7 +33,7 @@ class FavDetailController extends GetxController {
onCancelFav(int id) async {
var result = await VideoHttp.favVideo(
aid: id.toString(), addIds: '', delIds: mediaId.toString());
aid: id, addIds: '', delIds: mediaId.toString());
if (result['status']) {
if (result['data']['prompt']) {
List<FavDetailItemData> dataList = favDetailData.value.medias!;

View File

@ -20,10 +20,12 @@ class _FavDetailPageState extends State<FavDetailPage> {
final FavDetailController _favDetailController =
Get.put(FavDetailController());
late StreamController<bool> titleStreamC; // a
Future? _futureBuilderFuture;
@override
void initState() {
super.initState();
_futureBuilderFuture = _favDetailController.queryUserFavFolderDetail();
titleStreamC = StreamController<bool>();
_controller.addListener(
() {
@ -165,7 +167,7 @@ class _FavDetailPageState extends State<FavDetailPage> {
),
),
FutureBuilder(
future: _favDetailController.queryUserFavFolderDetail(),
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data;

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/stat/danmu.dart';
import 'package:pilipala/common/widgets/stat/view.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/utils.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
@ -19,6 +20,7 @@ class FavVideoCardH extends StatelessWidget {
@override
Widget build(BuildContext context) {
int id = videoItem.id;
String bvid = IdUtils.av2bv(id);
String heroTag = Utils.makeHeroTag(id);
return Dismissible(
movementDuration: const Duration(milliseconds: 300),
@ -43,7 +45,7 @@ class FavVideoCardH extends StatelessWidget {
child: InkWell(
onTap: () async {
await Future.delayed(const Duration(milliseconds: 200));
Get.toNamed('/video?aid=$id&cid=${videoItem.cid}',
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.cid}',
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
},
child: Column(

View File

@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/common/business_type.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/utils.dart';
class HistoryItem extends StatelessWidget {
@ -12,6 +13,7 @@ class HistoryItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
int aid = videoItem.history.oid;
String bvid = videoItem.history.bvid;
String heroTag = Utils.makeHeroTag(aid);
return InkWell(
onTap: () async {
@ -29,7 +31,7 @@ class HistoryItem extends StatelessWidget {
},
);
} else {
Get.toNamed('/video?aid=$aid&cid=${videoItem.history.cid}',
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.history.cid}',
arguments: {'heroTag': heroTag, 'pic': videoItem.cover});
}
},

View File

@ -16,7 +16,7 @@ class VideoDetailController extends GetxController {
RxList<String> tabs = <String>['简介', '评论'].obs;
// 视频aid
int aid = int.parse(Get.parameters['aid']!);
String bvid = Get.parameters['bvid']!;
int cid = int.parse(Get.parameters['cid']!);
// 是否预渲染 骨架屏
@ -113,7 +113,8 @@ class VideoDetailController extends GetxController {
// 视频链接
queryVideoUrl() async {
var result = await VideoHttp.videoUrl(cid: cid, avid: aid);
print('🐶🐶🐶');
var result = await VideoHttp.videoUrl(cid: cid, bvid: bvid);
// log('result: ${result.toString()}');
if (result['status']) {
PlayUrlModel data = result['data'];
@ -133,7 +134,7 @@ class VideoDetailController extends GetxController {
void markHeartBeat() async {
Duration progress = meeduPlayerController.position.value;
await VideoHttp.heartBeat(aid: aid, progress: progress.inSeconds);
await VideoHttp.heartBeat(bvid: bvid, progress: progress.inSeconds);
}
@override

View File

@ -8,12 +8,13 @@ import 'package:pilipala/http/video.dart';
import 'package:pilipala/models/user/fav_folder.dart';
import 'package:pilipala/models/video_detail_res.dart';
import 'package:pilipala/pages/video/detail/controller.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:share_plus/share_plus.dart';
class VideoIntroController extends GetxController {
// 视频aid
String aid = Get.parameters['aid']!;
// 视频bvid
String bvid = Get.parameters['bvid']!;
// 是否预渲染 骨架屏
bool preRender = false;
@ -69,7 +70,7 @@ class VideoIntroController extends GetxController {
// 获取视频简介
Future queryVideoIntro() async {
var result = await VideoHttp.videoIntro(aid: aid);
var result = await VideoHttp.videoIntro(bvid: bvid);
if (result['status']) {
videoDetail.value = result['data']!;
Get.find<VideoDetailController>(tag: Get.arguments['heroTag'])
@ -104,21 +105,25 @@ class VideoIntroController extends GetxController {
// 获取点赞状态
Future queryHasLikeVideo() async {
var result = await VideoHttp.hasLikeVideo(aid: aid);
var result = await VideoHttp.hasLikeVideo(bvid: bvid);
// data num 被点赞标志 0未点赞 1已点赞
hasLike.value = result["data"] == 1 ? true : false;
}
// 获取投币状态
Future queryHasCoinVideo() async {
var result = await VideoHttp.hasCoinVideo(aid: aid);
var result = await VideoHttp.hasCoinVideo(bvid: bvid);
hasCoin.value = result["data"]['multiply'] == 0 ? false : true;
}
// 获取收藏状态
Future queryHasFavVideo() async {
var result = await VideoHttp.hasFavVideo(aid: aid);
hasFav.value = result["data"]['favoured'];
var result = await VideoHttp.hasFavVideo(aid: IdUtils.bv2av(bvid));
if (result['status']) {
hasFav.value = result["data"]['favoured'];
} else {
hasFav.value = false;
}
}
// 一键三连
@ -141,7 +146,7 @@ class VideoIntroController extends GetxController {
child: const Text('点错了')),
TextButton(
onPressed: () async {
var result = await VideoHttp.oneThree(aid: aid);
var result = await VideoHttp.oneThree(bvid: bvid);
if (result['status']) {
hasLike.value = result["data"]["like"];
hasCoin.value = result["data"]["coin"];
@ -162,7 +167,7 @@ class VideoIntroController extends GetxController {
// (取消)点赞
Future actionLikeVideo() async {
var result = await VideoHttp.likeVideo(aid: aid, type: !hasLike.value);
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
if (result['status']) {
// hasLike.value = result["data"] == 1 ? true : false;
if (!hasLike.value) {
@ -216,7 +221,7 @@ class VideoIntroController extends GetxController {
TextButton(
onPressed: () async {
var res = await VideoHttp.coinVideo(
aid: aid, multiply: _tempThemeValue);
bvid: bvid, multiply: _tempThemeValue);
print(res);
if (res['status']) {
SmartDialog.showToast('投币成功');
@ -244,7 +249,7 @@ class VideoIntroController extends GetxController {
}
} catch (e) {}
var result = await VideoHttp.favVideo(
aid: aid,
aid: IdUtils.bv2av(bvid),
addIds: addMediaIdsNew.join(','),
delIds: delMediaIdsNew.join(','));
if (result['status']) {
@ -262,7 +267,7 @@ class VideoIntroController extends GetxController {
// 分享视频
Future actionShareVideo() async {
var result =
await Share.share('${HttpString.baseUrl}/video/$aid').whenComplete(() {
await Share.share('${HttpString.baseUrl}/video/$bvid').whenComplete(() {
print("share completion block ");
});
return result;
@ -270,7 +275,7 @@ class VideoIntroController extends GetxController {
Future queryVideoInFolder() async {
var result = await VideoHttp.videoInFolder(
mid: user.get(UserBoxKey.userMid), rid: aid);
mid: user.get(UserBoxKey.userMid), rid: IdUtils.bv2av(bvid));
if (result['status']) {
favFolderData.value = result['data'];
}

View File

@ -4,11 +4,11 @@ import 'package:pilipala/http/video.dart';
class ReleatedController extends GetxController {
// 视频aid
String aid = Get.parameters['aid']!;
String bvid = Get.parameters['bvid']!;
// 推荐视频列表
List relatedVideoList = [];
OverlayEntry? popupDialog;
Future<dynamic> queryRelatedVideo() => VideoHttp.relatedVideoList(aid: aid);
Future<dynamic> queryRelatedVideo() => VideoHttp.relatedVideoList(bvid: bvid);
}

View File

@ -10,10 +10,14 @@ import 'package:pilipala/models/video/reply/data.dart';
import 'package:pilipala/models/video/reply/item.dart';
class VideoReplyController extends GetxController {
VideoReplyController(this.aid, this.rpid, this.level);
VideoReplyController(
this.aid,
this.rpid,
this.level,
);
final ScrollController scrollController = ScrollController();
// 视频aid 请求时使用的oid
String? aid;
int? aid;
// 层级 2为楼中楼
String? level;
// rpid 请求楼中楼回复
@ -95,7 +99,7 @@ class VideoReplyController extends GetxController {
Future submitReplyAdd() async {
var result = await VideoHttp.replyAdd(
type: ReplyType.video,
oid: int.parse(aid!),
oid: aid!,
root: replyLevel == '0'
? 0
: replyLevel == '1'

View File

@ -7,16 +7,17 @@ import 'package:pilipala/common/skeleton/video_reply.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/video/detail/replyNew/index.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'controller.dart';
import 'widgets/reply_item.dart';
class VideoReplyPanel extends StatefulWidget {
int oid;
String? bvid;
int rpid;
String? level;
Key? key;
VideoReplyPanel({
this.oid = 0,
this.bvid,
this.rpid = 0,
this.level,
super.key,
@ -42,17 +43,19 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
@override
void initState() {
int oid = widget.bvid != null ? IdUtils.bv2av(widget.bvid!) : 0;
super.initState();
replyLevel = widget.level ?? '1';
if (widget.level != null && widget.level == '2') {
_videoReplyController = Get.put(
VideoReplyController(
widget.oid.toString(), widget.rpid.toString(), '2'),
VideoReplyController(oid, widget.rpid.toString(), '2'),
tag: widget.rpid.toString());
_videoReplyController.rPid = widget.rpid;
} else {
_videoReplyController = Get.put(
VideoReplyController(Get.parameters['aid']!, '', '1'),
int oid = Get.parameters['bvid'] != null
? IdUtils.bv2av(Get.parameters['bvid']!)
: 0;
_videoReplyController = Get.put(VideoReplyController(oid, '', '1'),
tag: Get.arguments['heroTag']);
}
@ -213,15 +216,18 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
builder: (builder) {
return VideoReplyNewDialog(
replyLevel: '0',
oid: int.parse(Get.parameters['aid']!),
oid: IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
);
},
).then((value) => {
// 完成评论,数据添加
_videoReplyController.replyList.add(value['data'])
});
).then(
(value) => {
// 完成评论,数据添加
if (value != null && value['data'])
{_videoReplyController.replyList.add(value['data'])}
},
);
},
tooltip: '发表评论',
child: const Icon(Icons.reply),

View File

@ -8,7 +8,7 @@ class VideoReplyReplyController extends GetxController {
VideoReplyReplyController(this.aid, this.rpid);
final ScrollController scrollController = ScrollController();
// 视频aid 请求时使用的oid
String? aid;
int? aid;
// rpid 请求楼中楼回复
String? rpid;
RxList<ReplyItemModel> replyList = [ReplyItemModel()].obs;
@ -29,13 +29,14 @@ class VideoReplyReplyController extends GetxController {
super.onInit();
currentPage = 0;
}
// 上拉加载
Future onLoad() async {
queryReplyList(type: 'onLoad');
}
Future queryReplyList({type = 'init'}) async {
if(type == 'init'){
if (type == 'init') {
currentPage = 0;
}
isLoadingMore = true;
@ -87,4 +88,4 @@ class VideoReplyReplyController extends GetxController {
currentPage = 0;
super.onClose();
}
}
}

View File

@ -31,8 +31,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
@override
void initState() {
_videoReplyReplyController = Get.put(
VideoReplyReplyController(
widget.oid.toString(), widget.rpid.toString()),
VideoReplyReplyController(widget.oid, widget.rpid.toString()),
tag: widget.rpid.toString());
super.initState();

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();