mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
refa: video model (#523)
This commit is contained in:
committed by
GitHub
parent
bf464994df
commit
7a6085e923
@@ -1,83 +1,45 @@
|
||||
import 'package:PiliPlus/models/model_owner.dart';
|
||||
import 'package:PiliPlus/models/user/fav_folder.dart';
|
||||
import '../model_owner.dart';
|
||||
import '../model_video.dart';
|
||||
import 'fav_folder.dart';
|
||||
|
||||
class FavDetailData {
|
||||
FavDetailData({
|
||||
this.info,
|
||||
this.medias,
|
||||
this.hasMore,
|
||||
});
|
||||
|
||||
FavFolderItemData? info;
|
||||
List<FavDetailItemData>? medias;
|
||||
List<FavDetailItemData>? list;
|
||||
List<FavDetailItemData>? get medias => list;
|
||||
bool? hasMore;
|
||||
|
||||
FavDetailData.fromJson(Map<String, dynamic> json) {
|
||||
info =
|
||||
json['info'] == null ? null : FavFolderItemData.fromJson(json['info']);
|
||||
medias = (json['medias'] as List?)
|
||||
list = (json['medias'] as List?)
|
||||
?.map<FavDetailItemData>((e) => FavDetailItemData.fromJson(e))
|
||||
.toList();
|
||||
hasMore = json['has_more'];
|
||||
}
|
||||
}
|
||||
|
||||
class FavDetailItemData {
|
||||
FavDetailItemData({
|
||||
this.id,
|
||||
this.type,
|
||||
this.title,
|
||||
this.pic,
|
||||
this.intro,
|
||||
this.page,
|
||||
this.duration,
|
||||
this.owner,
|
||||
this.attr,
|
||||
this.cntInfo,
|
||||
this.link,
|
||||
this.ctime,
|
||||
this.pubdate,
|
||||
this.favTime,
|
||||
this.bvId,
|
||||
this.bvid,
|
||||
// this.season,
|
||||
this.ogv,
|
||||
this.stat,
|
||||
this.cid,
|
||||
this.epId,
|
||||
this.checked,
|
||||
});
|
||||
|
||||
class FavDetailItemData extends BaseVideoItemModel {
|
||||
int? id;
|
||||
int? type;
|
||||
String? title;
|
||||
String? pic;
|
||||
String? intro;
|
||||
int? page;
|
||||
int? duration;
|
||||
Owner? owner;
|
||||
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/fav/list.md
|
||||
// | attr | num | 失效 | 0: 正常;9: up自己删除;1: 其他原因删除 |
|
||||
int? attr;
|
||||
Map? cntInfo;
|
||||
String? link;
|
||||
int? ctime;
|
||||
int? pubdate;
|
||||
int? favTime;
|
||||
String? bvId;
|
||||
String? bvid;
|
||||
Map? ogv;
|
||||
Stat? stat;
|
||||
int? cid;
|
||||
String? epId;
|
||||
bool? checked;
|
||||
|
||||
FavDetailItemData.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
aid = id;
|
||||
type = json['type'];
|
||||
title = json['title'];
|
||||
pic = json['cover'];
|
||||
intro = json['intro'];
|
||||
desc = json['intro'];
|
||||
page = json['page'];
|
||||
duration = json['duration'];
|
||||
owner = Owner.fromJson(json['upper']);
|
||||
@@ -87,38 +49,18 @@ class FavDetailItemData {
|
||||
ctime = json['ctime'];
|
||||
pubdate = json['pubtime'];
|
||||
favTime = json['fav_time'];
|
||||
bvId = json['bv_id'];
|
||||
bvid = json['bvid'];
|
||||
ogv = json['ogv'];
|
||||
stat = Stat.fromJson(json['cnt_info']);
|
||||
cid = json['ugc'] != null ? json['ugc']['first_cid'] : null;
|
||||
stat = PlayStat.fromJson(json['cnt_info']);
|
||||
cid = json['ugc']?['first_cid'];
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
class Stat {
|
||||
Stat({
|
||||
this.view,
|
||||
this.danmu,
|
||||
});
|
||||
|
||||
int? view;
|
||||
int? danmu;
|
||||
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
view = json['play'];
|
||||
danmu = json['danmaku'];
|
||||
}
|
||||
static final _digitRegExp = RegExp(r'\d+');
|
||||
String resolveEpId(String url) => _digitRegExp.firstMatch(url)!.group(0)!;
|
||||
|
||||
// @override
|
||||
// bool isFollowed;
|
||||
}
|
||||
|
||||
@@ -60,47 +60,19 @@ class HisTabItem {
|
||||
}
|
||||
|
||||
class HisListItem {
|
||||
HisListItem({
|
||||
this.title,
|
||||
this.longTitle,
|
||||
this.cover,
|
||||
this.pic,
|
||||
this.covers,
|
||||
this.uri,
|
||||
this.history,
|
||||
this.videos,
|
||||
this.authorName,
|
||||
this.authorFace,
|
||||
this.authorMid,
|
||||
this.viewAt,
|
||||
this.progress,
|
||||
this.badge,
|
||||
this.showTitle,
|
||||
this.duration,
|
||||
this.current,
|
||||
this.total,
|
||||
this.newDesc,
|
||||
this.isFinish,
|
||||
this.isFav,
|
||||
this.kid,
|
||||
this.tagName,
|
||||
this.liveStatus,
|
||||
this.checked,
|
||||
});
|
||||
|
||||
String? title;
|
||||
late String title;
|
||||
String? longTitle;
|
||||
String? cover;
|
||||
String? pic;
|
||||
List? covers;
|
||||
String? uri;
|
||||
History? history;
|
||||
late History history;
|
||||
int? videos;
|
||||
String? authorName;
|
||||
String? authorFace;
|
||||
int? authorMid;
|
||||
int? viewAt;
|
||||
int? progress;
|
||||
int progress = 0;
|
||||
String? badge;
|
||||
String? showTitle;
|
||||
int? duration;
|
||||
@@ -113,7 +85,7 @@ class HisListItem {
|
||||
String? tagName;
|
||||
int? liveStatus;
|
||||
bool? checked;
|
||||
void isFullScreen;
|
||||
dynamic isFullScreen;
|
||||
|
||||
HisListItem.fromJson(Map<String, dynamic> json) {
|
||||
title = json['title'];
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
class SubDetailModelData {
|
||||
DetailInfo? info;
|
||||
List<SubDetailMediaItem>? medias;
|
||||
List<SubDetailMediaItem>? list;
|
||||
|
||||
SubDetailModelData({this.info, this.medias});
|
||||
List<SubDetailMediaItem>? get medias => list; // 不知道哪里使用了这个
|
||||
|
||||
SubDetailModelData({this.info, this.list});
|
||||
|
||||
SubDetailModelData.fromJson(Map<String, dynamic> json) {
|
||||
info = DetailInfo.fromJson(json['info']);
|
||||
if (json['medias'] != null) {
|
||||
medias = <SubDetailMediaItem>[];
|
||||
json['medias'].forEach((v) {
|
||||
medias!.add(SubDetailMediaItem.fromJson(v));
|
||||
});
|
||||
}
|
||||
list = (json['medias'] as List?)
|
||||
?.map((i) => SubDetailMediaItem.fromJson(i))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +22,8 @@ class SubDetailMediaItem {
|
||||
int? duration;
|
||||
int? pubtime;
|
||||
String? bvid;
|
||||
Map? upper;
|
||||
Map? cntInfo;
|
||||
Map<String, dynamic>? upper;
|
||||
Map<String, dynamic>? cntInfo;
|
||||
int? enableVt;
|
||||
String? vtDisplay;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user