mod: 收藏夹跳转番剧

This commit is contained in:
guozhigq
2023-08-05 14:15:59 +08:00
parent d4cf67bbc7
commit 632900605b
4 changed files with 63 additions and 14 deletions

View File

@ -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']);

View File

@ -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<String, dynamic> 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<Match> matches = regex.allMatches(url);
List<String> numbers = [];
for (Match match in matches) {
numbers.add(match.group(0)!);
}
return numbers[0];
}
}

View File

@ -153,14 +153,18 @@ class VideoDetailData {
likeIcon = json["like_icon"];
needJumpBv = json["need_jump_bv"];
if (json['redirect_url'] != null) {
epId = resolveEpId(json['redirect_url']);
}
}
String resolveEpId(url) {
RegExp regex = RegExp(r'\d+');
Iterable<Match> matches = regex.allMatches(json['redirect_url']);
Iterable<Match> matches = regex.allMatches(url);
List<String> numbers = [];
for (Match match in matches) {
numbers.add(match.group(0)!);
}
epId = numbers[0];
}
return numbers[0];
}
Map<String, dynamic> toJson() => {

View File

@ -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<String, String> 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: [