From 632900605b21d092df4f557a7764a44dbe44324f Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 5 Aug 2023 14:15:59 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E6=94=B6=E8=97=8F=E5=A4=B9=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E7=95=AA=E5=89=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/user.dart | 3 +- lib/models/user/fav_detail.dart | 21 +++++++++-- lib/models/video_detail_res.dart | 18 ++++++---- .../favDetail/widget/fav_video_card.dart | 35 ++++++++++++++++--- 4 files changed, 63 insertions(+), 14 deletions(-) diff --git a/lib/http/user.dart b/lib/http/user.dart index 3b734d79..14292e73 100644 --- a/lib/http/user.dart +++ b/lib/http/user.dart @@ -69,7 +69,8 @@ class UserHttp { 'keyword': keyword, 'order': order, 'type': 0, - 'tid': 0 + 'tid': 0, + 'platform': 'web' }); if (res.data['code'] == 0) { FavDetailData data = FavDetailData.fromJson(res.data['data']); diff --git a/lib/models/user/fav_detail.dart b/lib/models/user/fav_detail.dart index d8013b75..e69697e6 100644 --- a/lib/models/user/fav_detail.dart +++ b/lib/models/user/fav_detail.dart @@ -41,9 +41,10 @@ class FavDetailItemData { this.bvId, this.bvid, // this.season, - // this.ogv, + this.ogv, this.stat, this.cid, + this.epId, }); int? id; @@ -62,8 +63,10 @@ class FavDetailItemData { int? favTime; String? bvId; String? bvid; + Map? ogv; Stat? stat; int? cid; + String? epId; FavDetailItemData.fromJson(Map json) { id = json['id']; @@ -82,8 +85,22 @@ class FavDetailItemData { favTime = json['fav_time']; bvId = json['bv_id']; bvid = json['bvid']; + ogv = json['ogv']; stat = Stat.fromJson(json['cnt_info']); - cid = json['ugc']['first_cid']; + cid = json['ugc'] != null ? json['ugc']['first_cid'] : null; + if (json['link'] != null && json['link'].contains('/bangumi')) { + epId = resolveEpId(json['link']); + } + } + + String resolveEpId(url) { + RegExp regex = RegExp(r'\d+'); + Iterable matches = regex.allMatches(url); + List numbers = []; + for (Match match in matches) { + numbers.add(match.group(0)!); + } + return numbers[0]; } } diff --git a/lib/models/video_detail_res.dart b/lib/models/video_detail_res.dart index 5ac9dcf0..277d1e30 100644 --- a/lib/models/video_detail_res.dart +++ b/lib/models/video_detail_res.dart @@ -153,16 +153,20 @@ class VideoDetailData { likeIcon = json["like_icon"]; needJumpBv = json["need_jump_bv"]; if (json['redirect_url'] != null) { - RegExp regex = RegExp(r'\d+'); - Iterable matches = regex.allMatches(json['redirect_url']); - List numbers = []; - for (Match match in matches) { - numbers.add(match.group(0)!); - } - epId = numbers[0]; + epId = resolveEpId(json['redirect_url']); } } + String resolveEpId(url) { + RegExp regex = RegExp(r'\d+'); + Iterable matches = regex.allMatches(url); + List numbers = []; + for (Match match in matches) { + numbers.add(match.group(0)!); + } + return numbers[0]; + } + Map toJson() => { "bvid": bvid, "aid": aid, diff --git a/lib/pages/favDetail/widget/fav_video_card.dart b/lib/pages/favDetail/widget/fav_video_card.dart index 2b4c2409..a89189e7 100644 --- a/lib/pages/favDetail/widget/fav_video_card.dart +++ b/lib/pages/favDetail/widget/fav_video_card.dart @@ -3,6 +3,9 @@ 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/http/search.dart'; +import 'package:pilipala/http/video.dart'; +import 'package:pilipala/models/common/search_type.dart'; import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/utils.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; @@ -20,7 +23,7 @@ class FavVideoCardH extends StatelessWidget { @override Widget build(BuildContext context) { int id = videoItem.id; - String bvid = IdUtils.av2bv(id); + String bvid = videoItem.bvid ?? IdUtils.av2bv(id); String heroTag = Utils.makeHeroTag(id); return Dismissible( movementDuration: const Duration(milliseconds: 300), @@ -44,9 +47,33 @@ class FavVideoCardH 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}); + // int? seasonId; + String? epId; + if (videoItem.ogv != null && videoItem.ogv['type_name'] == '番剧') { + videoItem.cid = await SearchHttp.ab2c(bvid: bvid); + // seasonId = videoItem.ogv['season_id']; + epId = videoItem.epId; + } else if (videoItem.page == 0 || videoItem.page > 1) { + var result = await VideoHttp.videoIntro(bvid: bvid); + if (result['status']) { + epId = result['data'].epId; + } + } + + Map parameters = { + 'bvid': bvid, + 'cid': videoItem.cid.toString(), + 'epId': epId ?? '', + }; + // if (seasonId != null) { + // parameters['seasonId'] = seasonId.toString(); + // } + Get.toNamed('/video', parameters: parameters, arguments: { + 'videoItem': videoItem, + 'heroTag': heroTag, + 'videoType': + epId != null ? SearchType.media_bangumi : SearchType.video, + }); }, child: Column( children: [