mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: view pgc section as normal video
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -80,6 +80,7 @@ class BangumiInfoModel {
|
|||||||
int? type;
|
int? type;
|
||||||
UserStatus? userStatus;
|
UserStatus? userStatus;
|
||||||
String? staff;
|
String? staff;
|
||||||
|
List<Section>? section;
|
||||||
|
|
||||||
BangumiInfoModel.fromJson(Map<String, dynamic> json) {
|
BangumiInfoModel.fromJson(Map<String, dynamic> json) {
|
||||||
activity = json['activity'];
|
activity = json['activity'];
|
||||||
@@ -89,8 +90,8 @@ class BangumiInfoModel {
|
|||||||
bkgCover = json['bkg_cover'];
|
bkgCover = json['bkg_cover'];
|
||||||
cover = json['cover'];
|
cover = json['cover'];
|
||||||
enableVt = json['enableVt'];
|
enableVt = json['enableVt'];
|
||||||
episodes = json['episodes']
|
episodes = (json['episodes'] as List?)
|
||||||
.map<EpisodeItem>((e) => EpisodeItem.fromJson(e))
|
?.map<EpisodeItem>((e) => EpisodeItem.fromJson(e))
|
||||||
.toList();
|
.toList();
|
||||||
evaluate = json['evaluate'];
|
evaluate = json['evaluate'];
|
||||||
freya = json['freya'];
|
freya = json['freya'];
|
||||||
@@ -125,6 +126,22 @@ class BangumiInfoModel {
|
|||||||
userStatus = UserStatus.fromJson(json['user_status']);
|
userStatus = UserStatus.fromJson(json['user_status']);
|
||||||
}
|
}
|
||||||
staff = json['staff'];
|
staff = json['staff'];
|
||||||
|
section = (json['section'] as List?)
|
||||||
|
?.map((item) => Section.fromJson(item))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Section {
|
||||||
|
Section({
|
||||||
|
this.episodes,
|
||||||
|
});
|
||||||
|
List<EpisodeItem>? episodes;
|
||||||
|
|
||||||
|
Section.fromJson(Map<String, dynamic> json) {
|
||||||
|
episodes = (json['episodes'] as List?)
|
||||||
|
?.map<EpisodeItem>((e) => EpisodeItem.fromJson(e))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -426,42 +426,73 @@ class Utils {
|
|||||||
dynamic seasonId,
|
dynamic seasonId,
|
||||||
dynamic epId,
|
dynamic epId,
|
||||||
}) async {
|
}) async {
|
||||||
SmartDialog.showLoading(msg: '资源获取中');
|
try {
|
||||||
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
SmartDialog.showLoading(msg: '资源获取中');
|
||||||
SmartDialog.dismiss();
|
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
||||||
if (result['status']) {
|
SmartDialog.dismiss();
|
||||||
if (result['data'].episodes.isEmpty) {
|
if (result['status']) {
|
||||||
SmartDialog.showToast('资源加载失败');
|
BangumiInfoModel data = result['data'];
|
||||||
return;
|
|
||||||
}
|
// epId episode -> progress episode -> first episode
|
||||||
// epId episode -> progress episode -> first episode
|
EpisodeItem? episode;
|
||||||
EpisodeItem? episode;
|
|
||||||
if (epId != null) {
|
if (epId != null) {
|
||||||
episode = (result['data'].episodes as List).firstWhereOrNull(
|
if (data.episodes?.isNotEmpty == true) {
|
||||||
(item) {
|
episode = data.episodes!.firstWhereOrNull(
|
||||||
return item.epId.toString() == epId.toString();
|
(item) {
|
||||||
|
return item.epId.toString() == epId.toString();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (episode == null && data.section?.isNotEmpty == true) {
|
||||||
|
for (Section item in data.section!) {
|
||||||
|
if (item.episodes?.isNotEmpty == true) {
|
||||||
|
for (EpisodeItem item in item.episodes!) {
|
||||||
|
if (item.epId.toString() == epId.toString()) {
|
||||||
|
// view as normal video
|
||||||
|
Utils.toDupNamed(
|
||||||
|
'/video?bvid=${item.bvid}&cid=${item.cid}',
|
||||||
|
arguments: {
|
||||||
|
'pic': item.cover,
|
||||||
|
'heroTag': Utils.makeHeroTag(item.cid),
|
||||||
|
'videoType': SearchType.video,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.episodes?.isEmpty == true) {
|
||||||
|
SmartDialog.showToast('资源加载失败');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
episode ??= data.userStatus?.progress?.lastEpId != null
|
||||||
|
? data.episodes!.firstWhereOrNull(
|
||||||
|
(item) => item.epId == data.userStatus?.progress?.lastEpId,
|
||||||
|
) ??
|
||||||
|
data.episodes!.first
|
||||||
|
: data.episodes!.first;
|
||||||
|
Utils.toDupNamed(
|
||||||
|
'/video?bvid=${episode.bvid}&cid=${episode.cid}&seasonId=${data.seasonId}&epId=${episode.epId}&type=${data.type}',
|
||||||
|
arguments: {
|
||||||
|
'pic': episode.cover,
|
||||||
|
'heroTag': Utils.makeHeroTag(episode.cid),
|
||||||
|
'videoType': SearchType.media_bangumi,
|
||||||
|
'bangumiItem': data,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
episode ??= (result['data'].episodes as List).firstWhereOrNull(
|
} catch (e) {
|
||||||
(item) =>
|
SmartDialog.dismiss();
|
||||||
item.epId == result['data'].userStatus?.progress?.lastEpId,
|
SmartDialog.showToast('$e');
|
||||||
) ??
|
debugPrint('$e');
|
||||||
result['data'].episodes.first;
|
|
||||||
dynamic bvid = episode?.bvid;
|
|
||||||
dynamic cid = episode?.cid;
|
|
||||||
dynamic pic = episode?.cover;
|
|
||||||
Utils.toDupNamed(
|
|
||||||
'/video?bvid=$bvid&cid=$cid&seasonId=${result['data'].seasonId}&epId=${episode?.epId}&type=${result['data'].type}',
|
|
||||||
arguments: {
|
|
||||||
'pic': pic,
|
|
||||||
'heroTag': Utils.makeHeroTag(cid),
|
|
||||||
'videoType': SearchType.media_bangumi,
|
|
||||||
'bangumiItem': result['data'],
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
SmartDialog.showToast(result['msg']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user