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
@@ -8,7 +8,7 @@ class BangumiListDataModel {
|
||||
});
|
||||
|
||||
int? hasNext;
|
||||
List? list;
|
||||
List<BangumiListItemModel>? list;
|
||||
int? num;
|
||||
int? size;
|
||||
int? total;
|
||||
|
||||
@@ -1,60 +1,20 @@
|
||||
import 'package:PiliPlus/models/model_rec_video_item.dart';
|
||||
import 'package:PiliPlus/models/model_video.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
class RecVideoItemAppModel {
|
||||
RecVideoItemAppModel({
|
||||
this.id,
|
||||
this.aid,
|
||||
this.bvid,
|
||||
this.cid,
|
||||
this.pic,
|
||||
this.stat,
|
||||
this.duration,
|
||||
this.title,
|
||||
this.isFollowed,
|
||||
this.owner,
|
||||
this.rcmdReason,
|
||||
this.goto,
|
||||
this.param,
|
||||
this.uri,
|
||||
this.talkBack,
|
||||
this.bangumiView,
|
||||
this.bangumiFollow,
|
||||
this.bangumiBadge,
|
||||
this.cardType,
|
||||
this.adInfo,
|
||||
this.threePoint,
|
||||
this.desc,
|
||||
});
|
||||
|
||||
class RecVideoItemAppModel extends BaseRecVideoItemModel {
|
||||
int? id;
|
||||
int? aid;
|
||||
String? bvid;
|
||||
int? cid;
|
||||
String? pic;
|
||||
RcmdStat? stat;
|
||||
int? duration;
|
||||
String? title;
|
||||
int? isFollowed;
|
||||
RcmdOwner? owner;
|
||||
String? rcmdReason;
|
||||
String? goto;
|
||||
int? param;
|
||||
String? uri;
|
||||
String? talkBack;
|
||||
// 番剧
|
||||
String? bangumiView;
|
||||
String? bangumiFollow;
|
||||
String? bangumiBadge;
|
||||
|
||||
String? cardType;
|
||||
Map? adInfo;
|
||||
ThreePoint? threePoint;
|
||||
String? desc;
|
||||
|
||||
RecVideoItemAppModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['player_args'] != null
|
||||
? json['player_args']['aid']
|
||||
: int.parse(json['param'] ?? '-1');
|
||||
: int.tryParse(json['param'] ?? '-1');
|
||||
aid = id;
|
||||
bvid = json['bvid'] ??
|
||||
(json['player_args'] != null
|
||||
@@ -70,21 +30,22 @@ class RecVideoItemAppModel {
|
||||
title = json['title'];
|
||||
owner = RcmdOwner.fromJson(json);
|
||||
rcmdReason = json['bottom_rcmd_reason'] ?? json['top_rcmd_reason'];
|
||||
if (rcmdReason != null && rcmdReason!.contains('赞')) {
|
||||
// 有时能在推荐原因里获得点赞数
|
||||
(stat as RcmdStat).like = Utils.parseNum(rcmdReason!);
|
||||
}
|
||||
// 由于app端api并不会直接返回与owner的关注状态
|
||||
// 所以借用推荐原因是否为“已关注”、“新关注”判别关注状态,从而与web端接口等效
|
||||
isFollowed = (rcmdReason == '已关注') || (rcmdReason == '新关注') ? 1 : 0;
|
||||
isFollowed = const {'已关注', '新关注'}.contains(rcmdReason);
|
||||
// 如果是,就无需再显示推荐原因,交由view统一处理即可
|
||||
if (isFollowed == 1) {
|
||||
rcmdReason = null;
|
||||
}
|
||||
if (isFollowed) rcmdReason = null;
|
||||
|
||||
goto = json['goto'];
|
||||
param = int.parse(json['param']);
|
||||
uri = json['uri'];
|
||||
talkBack = json['talk_back'];
|
||||
|
||||
if (json['goto'] == 'bangumi') {
|
||||
bangumiView = json['cover_left_text_1'];
|
||||
bangumiFollow = json['cover_left_text_2'];
|
||||
bangumiBadge = json['cover_right_text'];
|
||||
}
|
||||
|
||||
@@ -95,30 +56,37 @@ class RecVideoItemAppModel {
|
||||
: null;
|
||||
desc = json['desc'];
|
||||
}
|
||||
|
||||
// @override
|
||||
// int? get pubdate => null;
|
||||
}
|
||||
|
||||
class RcmdStat {
|
||||
RcmdStat({
|
||||
this.view,
|
||||
this.like,
|
||||
this.danmu,
|
||||
});
|
||||
String? view;
|
||||
String? like;
|
||||
String? danmu;
|
||||
class RcmdStat implements BaseStat {
|
||||
@override
|
||||
int? like;
|
||||
|
||||
@override
|
||||
int? get view => Utils.parseNum(viewStr);
|
||||
@override
|
||||
int? get danmu => Utils.parseNum(danmuStr);
|
||||
|
||||
@override
|
||||
late String viewStr;
|
||||
@override
|
||||
late String danmuStr;
|
||||
|
||||
RcmdStat.fromJson(Map<String, dynamic> json) {
|
||||
view = json["cover_left_text_1"];
|
||||
danmu = json['cover_left_text_2'] ?? '-';
|
||||
viewStr = json["cover_left_text_1"];
|
||||
danmuStr = json['cover_left_text_2'];
|
||||
}
|
||||
|
||||
@override
|
||||
set danmu(_) {}
|
||||
@override
|
||||
set view(_) {}
|
||||
}
|
||||
|
||||
class RcmdOwner {
|
||||
RcmdOwner({this.name, this.mid});
|
||||
|
||||
String? name;
|
||||
int? mid;
|
||||
|
||||
class RcmdOwner extends BaseOwner {
|
||||
RcmdOwner.fromJson(Map<String, dynamic> json) {
|
||||
name = json['goto'] == 'av'
|
||||
? json['args']['up_name']
|
||||
@@ -130,63 +98,26 @@ class RcmdOwner {
|
||||
}
|
||||
|
||||
class ThreePoint {
|
||||
ThreePoint({
|
||||
this.dislikeReasons,
|
||||
this.feedbacks,
|
||||
this.watchLater,
|
||||
});
|
||||
|
||||
List<DislikeReason>? dislikeReasons;
|
||||
List<FeedbackReason>? feedbacks;
|
||||
List<Reason>? dislikeReasons;
|
||||
List<Reason>? feedbacks;
|
||||
int? watchLater;
|
||||
|
||||
ThreePoint.fromJson(Map<String, dynamic> json) {
|
||||
if (json['dislike_reasons'] != null) {
|
||||
dislikeReasons = [];
|
||||
json['dislike_reasons'].forEach((v) {
|
||||
dislikeReasons!.add(DislikeReason.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['feedbacks'] != null) {
|
||||
feedbacks = [];
|
||||
json['feedbacks'].forEach((v) {
|
||||
feedbacks!.add(FeedbackReason.fromJson(v));
|
||||
});
|
||||
}
|
||||
dislikeReasons = (json['dislike_reasons'] as List?)
|
||||
?.map((v) => Reason.fromJson(v))
|
||||
.toList();
|
||||
feedbacks =
|
||||
(json['feedbacks'] as List?)?.map((v) => Reason.fromJson(v)).toList();
|
||||
watchLater = json['watch_later'];
|
||||
}
|
||||
}
|
||||
|
||||
class DislikeReason {
|
||||
DislikeReason({
|
||||
this.id,
|
||||
this.name,
|
||||
this.toast,
|
||||
});
|
||||
|
||||
class Reason {
|
||||
int? id;
|
||||
String? name;
|
||||
String? toast;
|
||||
|
||||
DislikeReason.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
toast = json['toast'];
|
||||
}
|
||||
}
|
||||
|
||||
class FeedbackReason {
|
||||
FeedbackReason({
|
||||
this.id,
|
||||
this.name,
|
||||
this.toast,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? name;
|
||||
String? toast;
|
||||
|
||||
FeedbackReason.fromJson(Map<String, dynamic> json) {
|
||||
Reason.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
toast = json['toast'];
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
import '../model_video.dart';
|
||||
|
||||
class MemberArchiveDataModel {
|
||||
MemberArchiveDataModel({
|
||||
this.list,
|
||||
@@ -51,114 +55,60 @@ class TListItemModel {
|
||||
}
|
||||
}
|
||||
|
||||
class VListItemModel {
|
||||
VListItemModel({
|
||||
this.comment,
|
||||
this.typeid,
|
||||
this.play,
|
||||
this.pic,
|
||||
this.subtitle,
|
||||
this.description,
|
||||
this.copyright,
|
||||
this.title,
|
||||
this.review,
|
||||
this.author,
|
||||
this.mid,
|
||||
this.created,
|
||||
this.pubdate,
|
||||
this.length,
|
||||
this.duration,
|
||||
this.videoReview,
|
||||
this.aid,
|
||||
this.bvid,
|
||||
this.cid,
|
||||
this.hideClick,
|
||||
this.isChargingSrc,
|
||||
this.rcmdReason,
|
||||
this.owner,
|
||||
});
|
||||
|
||||
class VListItemModel extends BaseVideoItemModel {
|
||||
int? comment;
|
||||
int? typeid;
|
||||
int? play;
|
||||
String? pic;
|
||||
String? subtitle;
|
||||
String? description;
|
||||
String? copyright;
|
||||
String? title;
|
||||
int? review;
|
||||
String? author;
|
||||
int? mid;
|
||||
int? created;
|
||||
int? pubdate;
|
||||
String? length;
|
||||
String? duration;
|
||||
int? videoReview;
|
||||
int? aid;
|
||||
String? bvid;
|
||||
int? cid;
|
||||
bool? hideClick;
|
||||
bool? isChargingSrc;
|
||||
Stat? stat;
|
||||
String? rcmdReason;
|
||||
Owner? owner;
|
||||
|
||||
VListItemModel.fromJson(Map<String, dynamic> json) {
|
||||
comment = json['comment'];
|
||||
typeid = json['typeid'];
|
||||
play = json['play'];
|
||||
pic = json['pic'];
|
||||
subtitle = json['subtitle'];
|
||||
description = json['description'];
|
||||
desc = json['description'];
|
||||
copyright = json['copyright'];
|
||||
title = json['title'];
|
||||
review = json['review'];
|
||||
author = json['author'];
|
||||
mid = json['mid'];
|
||||
created = json['created'];
|
||||
pubdate = json['created'];
|
||||
length = json['length'];
|
||||
duration = json['length'];
|
||||
videoReview = json['video_review'];
|
||||
if (json['length'] != null) duration = Utils.duration(json['length']);
|
||||
aid = json['aid'];
|
||||
bvid = json['bvid'];
|
||||
cid = null;
|
||||
hideClick = json['hide_click'];
|
||||
isChargingSrc = json['is_charging_arc'];
|
||||
stat = Stat.fromJson(json);
|
||||
rcmdReason = null;
|
||||
owner = Owner.fromJson(json);
|
||||
stat = VListStat.fromJson(json);
|
||||
owner = VListOwner.fromJson(json);
|
||||
}
|
||||
|
||||
// @override
|
||||
// int? cid = null;
|
||||
|
||||
// @override
|
||||
// String? rcmdReason = null;
|
||||
|
||||
// @override
|
||||
// String? goto;
|
||||
|
||||
// @override
|
||||
// bool isFollowed;
|
||||
|
||||
// @override
|
||||
// String? uri;
|
||||
}
|
||||
|
||||
class VListOwner extends BaseOwner {
|
||||
VListOwner.fromJson(Map<String, dynamic> json) {
|
||||
mid = json["mid"];
|
||||
name = json["author"];
|
||||
}
|
||||
}
|
||||
|
||||
class Stat {
|
||||
Stat({
|
||||
this.view,
|
||||
this.danmu,
|
||||
});
|
||||
|
||||
int? view;
|
||||
int? danmu;
|
||||
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
class VListStat extends BaseStat {
|
||||
VListStat.fromJson(Map<String, dynamic> json) {
|
||||
view = json["play"];
|
||||
danmu = json['video_review'];
|
||||
}
|
||||
}
|
||||
|
||||
class Owner {
|
||||
Owner({
|
||||
this.mid,
|
||||
this.name,
|
||||
this.face,
|
||||
});
|
||||
int? mid;
|
||||
String? name;
|
||||
String? face;
|
||||
|
||||
Owner.fromJson(Map<String, dynamic> json) {
|
||||
mid = json["mid"];
|
||||
name = json["author"];
|
||||
face = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +1,26 @@
|
||||
class MemberCoinsDataModel {
|
||||
MemberCoinsDataModel({
|
||||
this.aid,
|
||||
this.bvid,
|
||||
this.cid,
|
||||
this.coins,
|
||||
this.copyright,
|
||||
this.ctime,
|
||||
this.desc,
|
||||
this.duration,
|
||||
this.owner,
|
||||
this.pic,
|
||||
this.pubLocation,
|
||||
this.pubdate,
|
||||
this.resourceType,
|
||||
this.state,
|
||||
this.subtitle,
|
||||
this.time,
|
||||
this.title,
|
||||
this.tname,
|
||||
this.videos,
|
||||
this.view,
|
||||
this.danmaku,
|
||||
});
|
||||
import '../model_hot_video_item.dart';
|
||||
|
||||
int? aid;
|
||||
String? bvid;
|
||||
int? cid;
|
||||
int? coins;
|
||||
int? copyright;
|
||||
int? ctime;
|
||||
String? desc;
|
||||
int? duration;
|
||||
Owner? owner;
|
||||
String? pic;
|
||||
String? pubLocation;
|
||||
int? pubdate;
|
||||
String? resourceType;
|
||||
int? state;
|
||||
class MemberCoinsDataModel extends HotVideoItemModel {
|
||||
String? subtitle;
|
||||
int? coins;
|
||||
int? time;
|
||||
String? title;
|
||||
String? tname;
|
||||
int? videos;
|
||||
int? view;
|
||||
int? danmaku;
|
||||
// int? get view => stat.view;
|
||||
// int? get danmaku => stat.danmu;
|
||||
|
||||
MemberCoinsDataModel.fromJson(Map<String, dynamic> json) {
|
||||
aid = json['aid'];
|
||||
bvid = json['bvid'];
|
||||
cid = json['cid'];
|
||||
MemberCoinsDataModel.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
coins = json['coins'];
|
||||
copyright = json['copyright'];
|
||||
ctime = json['ctime'];
|
||||
desc = json['desc'];
|
||||
duration = json['duration'];
|
||||
owner = Owner.fromJson(json['owner']);
|
||||
pic = json['pic'];
|
||||
pubLocation = json['pub_location'];
|
||||
pubdate = json['pubdate'];
|
||||
resourceType = json['resource_type'];
|
||||
state = json['state'];
|
||||
subtitle = json['subtitle'];
|
||||
time = json['time'];
|
||||
title = json['title'];
|
||||
tname = json['tname'];
|
||||
videos = json['videos'];
|
||||
view = json['stat']['view'];
|
||||
danmaku = json['stat']['danmaku'];
|
||||
}
|
||||
}
|
||||
|
||||
class Owner {
|
||||
Owner({
|
||||
this.mid,
|
||||
this.name,
|
||||
this.face,
|
||||
});
|
||||
|
||||
int? mid;
|
||||
String? name;
|
||||
String? face;
|
||||
|
||||
Owner.fromJson(Map<String, dynamic> json) {
|
||||
mid = json['mid'];
|
||||
name = json['name'];
|
||||
face = json['face'];
|
||||
// view = json['stat']['view'];
|
||||
// danmaku = json['stat']['danmaku'];
|
||||
}
|
||||
// @override
|
||||
// String? goto;
|
||||
// @override
|
||||
// bool isFollowed;
|
||||
// @override
|
||||
// String? rcmdReason;
|
||||
// @override
|
||||
// String? uri;
|
||||
}
|
||||
|
||||
@@ -1,66 +1,23 @@
|
||||
import './model_owner.dart';
|
||||
import 'model_owner.dart';
|
||||
import 'model_rec_video_item.dart';
|
||||
import 'model_video.dart';
|
||||
|
||||
class HotVideoItemModel {
|
||||
HotVideoItemModel({
|
||||
this.aid,
|
||||
this.cid,
|
||||
this.bvid,
|
||||
this.videos,
|
||||
this.tid,
|
||||
this.tname,
|
||||
this.copyright,
|
||||
this.pic,
|
||||
this.title,
|
||||
this.pubdate,
|
||||
this.ctime,
|
||||
this.desc,
|
||||
this.state,
|
||||
this.duration,
|
||||
this.middionId,
|
||||
this.owner,
|
||||
this.stat,
|
||||
this.vDynamic,
|
||||
this.dimension,
|
||||
this.shortLinkV2,
|
||||
this.firstFrame,
|
||||
this.pubLocation,
|
||||
this.seasontype,
|
||||
this.isOgv,
|
||||
this.rcmdReason,
|
||||
this.checked,
|
||||
this.pgcLabel,
|
||||
this.redirectUrl,
|
||||
});
|
||||
|
||||
int? aid;
|
||||
int? cid;
|
||||
String? bvid;
|
||||
// 稍后再看, 排行榜等网页返回也使用该类
|
||||
class HotVideoItemModel extends BaseRecVideoItemModel {
|
||||
int? videos;
|
||||
int? tid;
|
||||
String? tname;
|
||||
int? copyright;
|
||||
String? pic;
|
||||
String? title;
|
||||
int? pubdate;
|
||||
int? ctime;
|
||||
String? desc;
|
||||
int? state;
|
||||
int? duration;
|
||||
int? middionId;
|
||||
Owner? owner;
|
||||
Stat? stat;
|
||||
String? vDynamic;
|
||||
Dimension? dimension;
|
||||
String? shortLinkV2;
|
||||
String? firstFrame;
|
||||
String? pubLocation;
|
||||
int? seasontype;
|
||||
bool? isOgv;
|
||||
RcmdReason? rcmdReason;
|
||||
bool? checked;
|
||||
String? pgcLabel;
|
||||
String? redirectUrl;
|
||||
|
||||
bool? checked; // 手动设置的
|
||||
|
||||
HotVideoItemModel.fromJson(Map<String, dynamic> json) {
|
||||
aid = json["aid"];
|
||||
cid = json["cid"];
|
||||
@@ -76,97 +33,62 @@ class HotVideoItemModel {
|
||||
desc = json["desc"];
|
||||
state = json["state"];
|
||||
duration = json["duration"];
|
||||
middionId = json["middion_id"];
|
||||
owner = Owner.fromJson(json["owner"]);
|
||||
stat = Stat.fromJson(json['stat']);
|
||||
vDynamic = json["vDynamic"];
|
||||
dimension = Dimension.fromMap(json['dimension']);
|
||||
shortLinkV2 = json["short_link_v2"];
|
||||
stat = HotStat.fromJson(json['stat']);
|
||||
dimension = Dimension.fromJson(json['dimension']);
|
||||
firstFrame = json["first_frame"];
|
||||
pubLocation = json["pub_location"];
|
||||
seasontype = json["seasontype"];
|
||||
isOgv = json["isOgv"];
|
||||
rcmdReason = json['rcmd_reason'] != '' && json['rcmd_reason'] != null
|
||||
? RcmdReason.fromJson(json['rcmd_reason'])
|
||||
: null;
|
||||
dynamic rcmd = json['rcmd_reason'];
|
||||
rcmdReason = rcmd is Map ? rcmd['content'] : rcmd; // 相关视频里rcmd为String,
|
||||
if (rcmdReason?.isEmpty == true) rcmdReason = null;
|
||||
pgcLabel = json['pgc_label'];
|
||||
redirectUrl = json['redirect_url'];
|
||||
// uri = json['uri']; // 仅在稍后再看存在
|
||||
}
|
||||
|
||||
// @override
|
||||
// get isFollowed => false;
|
||||
// @override
|
||||
// get goto => 'av';
|
||||
// @override
|
||||
// get uri => 'bilibili://video/$aid';
|
||||
}
|
||||
|
||||
class Stat {
|
||||
Stat({
|
||||
this.aid,
|
||||
this.view,
|
||||
this.danmu,
|
||||
this.reply,
|
||||
this.favorite,
|
||||
this.coin,
|
||||
this.share,
|
||||
this.nowRank,
|
||||
this.hisRank,
|
||||
this.like,
|
||||
this.dislike,
|
||||
this.vt,
|
||||
this.vv,
|
||||
});
|
||||
|
||||
int? aid;
|
||||
int? view;
|
||||
int? danmu;
|
||||
class HotStat extends Stat {
|
||||
int? reply;
|
||||
int? favorite;
|
||||
int? coin;
|
||||
int? share;
|
||||
int? nowRank;
|
||||
int? hisRank;
|
||||
int? like;
|
||||
int? dislike;
|
||||
int? vt;
|
||||
int? vv;
|
||||
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
aid = json["aid"];
|
||||
view = json["view"];
|
||||
danmu = json['danmaku'];
|
||||
HotStat.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
reply = json["reply"];
|
||||
favorite = json["favorite"];
|
||||
coin = json['coin'];
|
||||
share = json["share"];
|
||||
nowRank = json["now_rank"];
|
||||
hisRank = json['his_rank'];
|
||||
like = json["like"];
|
||||
dislike = json["dislike"];
|
||||
vt = json['vt'];
|
||||
vv = json["vv"];
|
||||
}
|
||||
}
|
||||
|
||||
class Dimension {
|
||||
Dimension({this.width, this.height, this.rotate});
|
||||
// class RcmdReason {
|
||||
// RcmdReason({
|
||||
// this.rcornerMark,
|
||||
// this.content,
|
||||
// });
|
||||
|
||||
int? width;
|
||||
int? height;
|
||||
int? rotate;
|
||||
// int? rcornerMark;
|
||||
// String? content = '';
|
||||
|
||||
Dimension.fromMap(Map<String, dynamic> json) {
|
||||
width = json["width"];
|
||||
height = json["height"];
|
||||
rotate = json["rotate"];
|
||||
}
|
||||
}
|
||||
|
||||
class RcmdReason {
|
||||
RcmdReason({
|
||||
this.rcornerMark,
|
||||
this.content,
|
||||
});
|
||||
|
||||
int? rcornerMark;
|
||||
String? content = '';
|
||||
|
||||
RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||
rcornerMark = json["corner_mark"];
|
||||
content = json["content"] ?? '';
|
||||
}
|
||||
}
|
||||
// RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||
// rcornerMark = json["corner_mark"];
|
||||
// content = json["content"] ?? '';
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import 'model_video.dart';
|
||||
|
||||
part 'model_owner.g.dart';
|
||||
|
||||
@HiveType(typeId: 3)
|
||||
class Owner {
|
||||
class Owner implements BaseOwner {
|
||||
Owner({
|
||||
this.mid,
|
||||
this.name,
|
||||
this.face,
|
||||
});
|
||||
@HiveField(0)
|
||||
@override
|
||||
int? mid;
|
||||
@HiveField(1)
|
||||
@override
|
||||
String? name;
|
||||
@HiveField(2)
|
||||
String? face;
|
||||
|
||||
@@ -1,55 +1,19 @@
|
||||
import './model_owner.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'model_video.dart';
|
||||
|
||||
part 'model_rec_video_item.g.dart';
|
||||
|
||||
@HiveType(typeId: 0)
|
||||
class RecVideoItemModel {
|
||||
RecVideoItemModel({
|
||||
this.id,
|
||||
this.bvid,
|
||||
this.cid,
|
||||
this.goto,
|
||||
this.uri,
|
||||
this.pic,
|
||||
this.title,
|
||||
this.duration,
|
||||
this.pubdate,
|
||||
this.owner,
|
||||
this.stat,
|
||||
this.isFollowed,
|
||||
this.rcmdReason,
|
||||
});
|
||||
|
||||
@HiveField(0)
|
||||
int? id = -1;
|
||||
@HiveField(1)
|
||||
String? bvid = '';
|
||||
@HiveField(2)
|
||||
int? cid = -1;
|
||||
@HiveField(3)
|
||||
String? goto = '';
|
||||
@HiveField(4)
|
||||
String? uri = '';
|
||||
@HiveField(5)
|
||||
String? pic = '';
|
||||
@HiveField(6)
|
||||
String? title = '';
|
||||
@HiveField(7)
|
||||
int? duration = -1;
|
||||
@HiveField(8)
|
||||
int? pubdate = -1;
|
||||
@HiveField(9)
|
||||
Owner? owner;
|
||||
@HiveField(10)
|
||||
Stat? stat;
|
||||
@HiveField(11)
|
||||
int? isFollowed;
|
||||
@HiveField(12)
|
||||
abstract class BaseRecVideoItemModel extends BaseVideoItemModel {
|
||||
String? goto;
|
||||
String? uri;
|
||||
String? rcmdReason;
|
||||
|
||||
// app推荐专属
|
||||
int? param;
|
||||
String? bangumiBadge;
|
||||
}
|
||||
|
||||
class RecVideoItemModel extends BaseRecVideoItemModel {
|
||||
RecVideoItemModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json["id"];
|
||||
aid = json["id"];
|
||||
bvid = json["bvid"];
|
||||
cid = json["cid"];
|
||||
goto = json["goto"];
|
||||
@@ -60,34 +24,15 @@ class RecVideoItemModel {
|
||||
pubdate = json["pubdate"];
|
||||
owner = Owner.fromJson(json["owner"]);
|
||||
stat = Stat.fromJson(json["stat"]);
|
||||
isFollowed = json["is_followed"] ?? 0;
|
||||
isFollowed = json["is_followed"] == 1;
|
||||
// rcmdReason = json["rcmd_reason"] != null
|
||||
// ? RcmdReason.fromJson(json["rcmd_reason"])
|
||||
// : RcmdReason(content: '');
|
||||
rcmdReason = json["rcmd_reason"]?['content'];
|
||||
}
|
||||
}
|
||||
|
||||
@HiveType(typeId: 1)
|
||||
class Stat {
|
||||
Stat({
|
||||
this.view,
|
||||
this.like,
|
||||
this.danmu,
|
||||
});
|
||||
@HiveField(0)
|
||||
int? view;
|
||||
@HiveField(1)
|
||||
int? like;
|
||||
@HiveField(2)
|
||||
int? danmu;
|
||||
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
// 无需在model中转换以保留原始数据,在view层处理即可
|
||||
view = json["view"];
|
||||
like = json["like"];
|
||||
danmu = json['danmaku'];
|
||||
}
|
||||
// @override
|
||||
// String? get desc => null;
|
||||
}
|
||||
|
||||
// @HiveType(typeId: 2)
|
||||
@@ -96,10 +41,8 @@ class Stat {
|
||||
// this.reasonType,
|
||||
// this.content,
|
||||
// });
|
||||
// @HiveField(0)
|
||||
// int? reasonType;
|
||||
// @HiveField(1)
|
||||
// String? content = '';
|
||||
// // int? reasonType;
|
||||
// // String? content;
|
||||
//
|
||||
// RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||
// reasonType = json["reason_type"];
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'model_rec_video_item.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class RecVideoItemModelAdapter extends TypeAdapter<RecVideoItemModel> {
|
||||
@override
|
||||
final int typeId = 0;
|
||||
|
||||
@override
|
||||
RecVideoItemModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return RecVideoItemModel(
|
||||
id: fields[0] as int?,
|
||||
bvid: fields[1] as String?,
|
||||
cid: fields[2] as int?,
|
||||
goto: fields[3] as String?,
|
||||
uri: fields[4] as String?,
|
||||
pic: fields[5] as String?,
|
||||
title: fields[6] as String?,
|
||||
duration: fields[7] as int?,
|
||||
pubdate: fields[8] as int?,
|
||||
owner: fields[9] as Owner?,
|
||||
stat: fields[10] as Stat?,
|
||||
isFollowed: fields[11] as int?,
|
||||
rcmdReason: fields[12] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, RecVideoItemModel obj) {
|
||||
writer
|
||||
..writeByte(13)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.bvid)
|
||||
..writeByte(2)
|
||||
..write(obj.cid)
|
||||
..writeByte(3)
|
||||
..write(obj.goto)
|
||||
..writeByte(4)
|
||||
..write(obj.uri)
|
||||
..writeByte(5)
|
||||
..write(obj.pic)
|
||||
..writeByte(6)
|
||||
..write(obj.title)
|
||||
..writeByte(7)
|
||||
..write(obj.duration)
|
||||
..writeByte(8)
|
||||
..write(obj.pubdate)
|
||||
..writeByte(9)
|
||||
..write(obj.owner)
|
||||
..writeByte(10)
|
||||
..write(obj.stat)
|
||||
..writeByte(11)
|
||||
..write(obj.isFollowed)
|
||||
..writeByte(12)
|
||||
..write(obj.rcmdReason);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is RecVideoItemModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
class StatAdapter extends TypeAdapter<Stat> {
|
||||
@override
|
||||
final int typeId = 1;
|
||||
|
||||
@override
|
||||
Stat read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return Stat(
|
||||
view: fields[0] as int?,
|
||||
like: fields[1] as int?,
|
||||
danmu: fields[2] as int?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, Stat obj) {
|
||||
writer
|
||||
..writeByte(3)
|
||||
..writeByte(0)
|
||||
..write(obj.view)
|
||||
..writeByte(1)
|
||||
..write(obj.like)
|
||||
..writeByte(2)
|
||||
..write(obj.danmu);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is StatAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
//
|
||||
// class RcmdReasonAdapter extends TypeAdapter<RcmdReason> {
|
||||
// @override
|
||||
// final int typeId = 2;
|
||||
//
|
||||
// @override
|
||||
// RcmdReason read(BinaryReader reader) {
|
||||
// final numOfFields = reader.readByte();
|
||||
// final fields = <int, dynamic>{
|
||||
// for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
// };
|
||||
// return RcmdReason(
|
||||
// reasonType: fields[0] as int?,
|
||||
// content: fields[1] as String?,
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void write(BinaryWriter writer, RcmdReason obj) {
|
||||
// writer
|
||||
// ..writeByte(2)
|
||||
// ..writeByte(0)
|
||||
// ..write(obj.reasonType)
|
||||
// ..writeByte(1)
|
||||
// ..write(obj.content);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// int get hashCode => typeId.hashCode;
|
||||
//
|
||||
// @override
|
||||
// bool operator ==(Object other) =>
|
||||
// identical(this, other) ||
|
||||
// other is RcmdReasonAdapter &&
|
||||
// runtimeType == other.runtimeType &&
|
||||
// typeId == other.typeId;
|
||||
// }
|
||||
59
lib/models/model_video.dart
Normal file
59
lib/models/model_video.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
abstract class BaseSimpleVideoItemModel {
|
||||
late String title;
|
||||
String? bvid;
|
||||
int? cid;
|
||||
String? pic;
|
||||
int duration = -1;
|
||||
late BaseOwner owner;
|
||||
late BaseStat stat;
|
||||
}
|
||||
|
||||
abstract class BaseVideoItemModel extends BaseSimpleVideoItemModel {
|
||||
int? aid;
|
||||
String? desc;
|
||||
int? pubdate;
|
||||
bool isFollowed = false;
|
||||
}
|
||||
|
||||
abstract class BaseOwner {
|
||||
int? mid;
|
||||
String? name;
|
||||
}
|
||||
|
||||
abstract class BaseStat {
|
||||
int? view;
|
||||
int? like;
|
||||
int? danmu;
|
||||
|
||||
String get viewStr => Utils.numFormat(view);
|
||||
String get danmuStr => Utils.numFormat(danmu);
|
||||
}
|
||||
|
||||
class Stat extends BaseStat {
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
view = json["view"];
|
||||
like = json["like"];
|
||||
danmu = json['danmaku'];
|
||||
}
|
||||
}
|
||||
|
||||
class PlayStat extends BaseStat {
|
||||
PlayStat.fromJson(Map<String, dynamic> json) {
|
||||
view = json['play'];
|
||||
danmu = json['danmaku'];
|
||||
}
|
||||
}
|
||||
|
||||
class Dimension {
|
||||
int? width;
|
||||
int? height;
|
||||
int? rotate;
|
||||
|
||||
Dimension.fromJson(Map<String, dynamic> json) {
|
||||
width = json["width"];
|
||||
height = json["height"];
|
||||
rotate = json["rotate"];
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
import 'package:PiliPlus/utils/em.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
class SearchVideoModel {
|
||||
SearchVideoModel({
|
||||
this.numResults,
|
||||
this.list,
|
||||
});
|
||||
import '../model_owner.dart';
|
||||
import '../model_video.dart';
|
||||
|
||||
class SearchVideoModel {
|
||||
int? numResults;
|
||||
List<SearchVideoItemModel>? list;
|
||||
|
||||
@@ -19,68 +17,25 @@ class SearchVideoModel {
|
||||
}
|
||||
}
|
||||
|
||||
class SearchVideoItemModel {
|
||||
SearchVideoItemModel({
|
||||
this.type,
|
||||
this.id,
|
||||
this.cid,
|
||||
// this.author,
|
||||
this.mid,
|
||||
// this.typeid,
|
||||
// this.typename,
|
||||
this.arcurl,
|
||||
this.aid,
|
||||
this.bvid,
|
||||
this.title,
|
||||
this.description,
|
||||
this.pic,
|
||||
// this.play,
|
||||
this.videoReview,
|
||||
// this.favorites,
|
||||
this.tag,
|
||||
// this.review,
|
||||
this.pubdate,
|
||||
this.senddate,
|
||||
this.duration,
|
||||
// this.viewType,
|
||||
// this.like,
|
||||
// this.upic,
|
||||
// this.danmaku,
|
||||
this.owner,
|
||||
this.stat,
|
||||
this.rcmdReason,
|
||||
});
|
||||
|
||||
class SearchVideoItemModel extends BaseVideoItemModel {
|
||||
String? type;
|
||||
int? id;
|
||||
int? cid;
|
||||
// String? author;
|
||||
int? mid;
|
||||
// String? typeid;
|
||||
// String? typename;
|
||||
String? arcurl;
|
||||
int? aid;
|
||||
String? bvid;
|
||||
List? title;
|
||||
// List? titleList;
|
||||
String? description;
|
||||
String? pic;
|
||||
// String? play;
|
||||
int? videoReview;
|
||||
// int? videoReview;
|
||||
// String? favorites;
|
||||
String? tag;
|
||||
// String? review;
|
||||
int? pubdate;
|
||||
int? senddate;
|
||||
int? duration;
|
||||
int? ctime;
|
||||
// String? duration;
|
||||
// String? viewType;
|
||||
// String? like;
|
||||
// String? upic;
|
||||
// String? danmaku;
|
||||
Owner? owner;
|
||||
Stat? stat;
|
||||
String? rcmdReason;
|
||||
List<Map<String, String>>? titleList;
|
||||
|
||||
SearchVideoItemModel.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
@@ -88,43 +43,35 @@ class SearchVideoItemModel {
|
||||
arcurl = json['arcurl'];
|
||||
aid = json['aid'];
|
||||
bvid = json['bvid'];
|
||||
mid = json['mid'];
|
||||
// title = json['title'].replaceAll(RegExp(r'<.*?>'), '');
|
||||
title = Em.regTitle(json['title']);
|
||||
description = json['description'];
|
||||
titleList = Em.regTitle(json['title']);
|
||||
title = titleList!.map((i) => i['text']!).join();
|
||||
desc = json['description'];
|
||||
pic = json['pic'] != null && json['pic'].startsWith('//')
|
||||
? 'https:${json['pic']}'
|
||||
: json['pic'] ?? '';
|
||||
videoReview = json['video_review'];
|
||||
pubdate = json['pubdate'];
|
||||
senddate = json['senddate'];
|
||||
ctime = json['senddate'];
|
||||
duration = Utils.duration(json['duration']);
|
||||
owner = Owner.fromJson(json);
|
||||
stat = Stat.fromJson(json);
|
||||
owner = SearchOwner.fromJson(json);
|
||||
stat = SearchStat.fromJson(json);
|
||||
}
|
||||
|
||||
// @override
|
||||
// String? goto;
|
||||
// @override
|
||||
// bool isFollowed;
|
||||
// @override
|
||||
// String? uri;
|
||||
}
|
||||
|
||||
class Stat {
|
||||
Stat({
|
||||
this.view,
|
||||
this.danmu,
|
||||
this.favorite,
|
||||
this.reply,
|
||||
this.like,
|
||||
});
|
||||
|
||||
// 播放量
|
||||
int? view;
|
||||
// 弹幕数
|
||||
int? danmu;
|
||||
class SearchStat extends BaseStat {
|
||||
// 收藏数
|
||||
int? favorite;
|
||||
// 评论数
|
||||
int? reply;
|
||||
// 喜欢
|
||||
int? like;
|
||||
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
SearchStat.fromJson(Map<String, dynamic> json) {
|
||||
view = json['play'];
|
||||
danmu = json['danmaku'];
|
||||
favorite = json['favorite'];
|
||||
@@ -133,17 +80,8 @@ class Stat {
|
||||
}
|
||||
}
|
||||
|
||||
class Owner {
|
||||
Owner({
|
||||
this.mid,
|
||||
this.name,
|
||||
this.face,
|
||||
});
|
||||
int? mid;
|
||||
String? name;
|
||||
String? face;
|
||||
|
||||
Owner.fromJson(Map<String, dynamic> json) {
|
||||
class SearchOwner extends Owner {
|
||||
SearchOwner.fromJson(Map<String, dynamic> json) {
|
||||
mid = json["mid"];
|
||||
name = json["author"];
|
||||
face = json['upic'];
|
||||
@@ -301,7 +239,7 @@ class SearchLiveItemModel {
|
||||
rankScore = json['rank_score'];
|
||||
roomid = json['roomid'];
|
||||
attentions = json['attentions'];
|
||||
cateName = Em.regCate(json['cate_name']) ?? '';
|
||||
cateName = Em.regCate(json['cate_name']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,107 +1,90 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../model_owner.dart';
|
||||
import '../model_video.dart';
|
||||
import 'badge.dart';
|
||||
import 'cursor_attr.dart';
|
||||
import 'three_point.dart';
|
||||
|
||||
part 'item.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Item {
|
||||
String? title;
|
||||
class Item extends BaseSimpleVideoItemModel {
|
||||
String? subtitle;
|
||||
String? tname;
|
||||
String? cover;
|
||||
@JsonKey(name: 'cover_icon')
|
||||
String? get cover => pic; // 不知道哪里使用了cover
|
||||
String? coverIcon;
|
||||
String? uri;
|
||||
String? param;
|
||||
String? goto;
|
||||
String? length;
|
||||
int? duration;
|
||||
@JsonKey(name: 'is_popular')
|
||||
bool? isPopular;
|
||||
@JsonKey(name: 'is_steins')
|
||||
bool? isSteins;
|
||||
@JsonKey(name: 'is_ugcpay')
|
||||
bool? isUgcpay;
|
||||
@JsonKey(name: 'is_cooperation')
|
||||
bool? isCooperation;
|
||||
@JsonKey(name: 'is_pgc')
|
||||
bool? isPgc;
|
||||
@JsonKey(name: 'is_live_playback')
|
||||
bool? isLivePlayback;
|
||||
@JsonKey(name: 'is_pugv')
|
||||
bool? isPugv;
|
||||
@JsonKey(name: 'is_fold')
|
||||
bool? isFold;
|
||||
@JsonKey(name: 'is_oneself')
|
||||
bool? isOneself;
|
||||
int? play;
|
||||
int? danmaku;
|
||||
int? ctime;
|
||||
@JsonKey(name: 'ugc_pay')
|
||||
int? ugcPay;
|
||||
String? author;
|
||||
bool? state;
|
||||
String? bvid;
|
||||
int? videos;
|
||||
@JsonKey(name: 'three_point')
|
||||
List<ThreePoint>? threePoint;
|
||||
@JsonKey(name: 'first_cid')
|
||||
int? firstCid;
|
||||
@JsonKey(name: 'cursor_attr')
|
||||
CursorAttr? cursorAttr;
|
||||
@JsonKey(name: 'view_content')
|
||||
String? viewContent;
|
||||
@JsonKey(name: 'icon_type')
|
||||
int? iconType;
|
||||
@JsonKey(name: 'publish_time_text')
|
||||
String? publishTimeText;
|
||||
List<Badge>? badges;
|
||||
Map? season;
|
||||
Map? history;
|
||||
|
||||
Item({
|
||||
this.title,
|
||||
this.subtitle,
|
||||
this.tname,
|
||||
this.cover,
|
||||
this.coverIcon,
|
||||
this.uri,
|
||||
this.param,
|
||||
this.goto,
|
||||
this.length,
|
||||
this.duration,
|
||||
this.isPopular,
|
||||
this.isSteins,
|
||||
this.isUgcpay,
|
||||
this.isCooperation,
|
||||
this.isPgc,
|
||||
this.isLivePlayback,
|
||||
this.isPugv,
|
||||
this.isFold,
|
||||
this.isOneself,
|
||||
this.play,
|
||||
this.danmaku,
|
||||
this.ctime,
|
||||
this.ugcPay,
|
||||
this.author,
|
||||
this.state,
|
||||
this.bvid,
|
||||
this.videos,
|
||||
this.threePoint,
|
||||
this.firstCid,
|
||||
this.cursorAttr,
|
||||
this.viewContent,
|
||||
this.iconType,
|
||||
this.publishTimeText,
|
||||
this.badges,
|
||||
this.season,
|
||||
this.history,
|
||||
});
|
||||
|
||||
factory Item.fromJson(Map<String, dynamic> json) => _$ItemFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ItemToJson(this);
|
||||
Item.fromJson(Map<String, dynamic> json) {
|
||||
title = json['title'];
|
||||
subtitle = json['subtitle'];
|
||||
tname = json['tname'];
|
||||
pic = json['cover'];
|
||||
coverIcon = json['cover_icon'];
|
||||
uri = json['uri'];
|
||||
param = json['param'];
|
||||
goto = json['goto'];
|
||||
length = json['length'];
|
||||
duration = json['duration'] ?? -1;
|
||||
isPopular = json['is_popular'];
|
||||
isSteins = json['is_steins'];
|
||||
isUgcpay = json['is_ugcpay'];
|
||||
isCooperation = json['is_cooperation'];
|
||||
isPgc = json['is_pgc'];
|
||||
isLivePlayback = json['is_live_playback'];
|
||||
isPugv = json['is_pugv'];
|
||||
isFold = json['is_fold'];
|
||||
isOneself = json['is_oneself'];
|
||||
ctime = json['ctime'];
|
||||
ugcPay = json['ugc_pay'];
|
||||
state = json['state'];
|
||||
bvid = json['bvid'];
|
||||
videos = json['videos'];
|
||||
threePoint = (json['three_point'] as List<dynamic>?)
|
||||
?.map((e) => ThreePoint.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
cid = json['first_cid'];
|
||||
cursorAttr = json['cursor_attr'] == null
|
||||
? null
|
||||
: CursorAttr.fromJson(json['cursor_attr'] as Map<String, dynamic>);
|
||||
iconType = json['icon_type'];
|
||||
publishTimeText = json['publish_time_text'];
|
||||
badges = (json['badges'] as List<dynamic>?)
|
||||
?.map((e) => Badge.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
season = json['season'];
|
||||
history = json['history'];
|
||||
stat = PlayStat.fromJson(json);
|
||||
owner = Owner(mid: 0, name: json['author']);
|
||||
}
|
||||
}
|
||||
|
||||
class UserStat extends PlayStat {
|
||||
String? _viewStr;
|
||||
|
||||
@override
|
||||
String get viewStr => _viewStr ?? super.viewStr;
|
||||
|
||||
UserStat.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
_viewStr = json['view_content'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'item.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Item _$ItemFromJson(Map<String, dynamic> json) => Item(
|
||||
title: json['title'] as String?,
|
||||
subtitle: json['subtitle'] as String?,
|
||||
tname: json['tname'] as String?,
|
||||
cover: json['cover'] as String?,
|
||||
coverIcon: json['cover_icon'] as String?,
|
||||
uri: json['uri'] as String?,
|
||||
param: json['param'] as String?,
|
||||
goto: json['goto'] as String?,
|
||||
length: json['length'] as String?,
|
||||
duration: (json['duration'] as num?)?.toInt(),
|
||||
isPopular: json['is_popular'] as bool?,
|
||||
isSteins: json['is_steins'] as bool?,
|
||||
isUgcpay: json['is_ugcpay'] as bool?,
|
||||
isCooperation: json['is_cooperation'] as bool?,
|
||||
isPgc: json['is_pgc'] as bool?,
|
||||
isLivePlayback: json['is_live_playback'] as bool?,
|
||||
isPugv: json['is_pugv'] as bool?,
|
||||
isFold: json['is_fold'] as bool?,
|
||||
isOneself: json['is_oneself'] as bool?,
|
||||
play: (json['play'] as num?)?.toInt(),
|
||||
danmaku: (json['danmaku'] as num?)?.toInt(),
|
||||
ctime: (json['ctime'] as num?)?.toInt(),
|
||||
ugcPay: (json['ugc_pay'] as num?)?.toInt(),
|
||||
author: json['author'] as String?,
|
||||
state: json['state'] as bool?,
|
||||
bvid: json['bvid'] as String?,
|
||||
videos: (json['videos'] as num?)?.toInt(),
|
||||
threePoint: (json['three_point'] as List<dynamic>?)
|
||||
?.map((e) => ThreePoint.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
firstCid: (json['first_cid'] as num?)?.toInt(),
|
||||
cursorAttr: json['cursor_attr'] == null
|
||||
? null
|
||||
: CursorAttr.fromJson(json['cursor_attr'] as Map<String, dynamic>),
|
||||
viewContent: json['view_content'] as String?,
|
||||
iconType: (json['icon_type'] as num?)?.toInt(),
|
||||
publishTimeText: json['publish_time_text'] as String?,
|
||||
badges: (json['badges'] as List<dynamic>?)
|
||||
?.map((e) => Badge.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
season: json['season'],
|
||||
history: json['history'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ItemToJson(Item instance) => <String, dynamic>{
|
||||
'title': instance.title,
|
||||
'subtitle': instance.subtitle,
|
||||
'tname': instance.tname,
|
||||
'cover': instance.cover,
|
||||
'cover_icon': instance.coverIcon,
|
||||
'uri': instance.uri,
|
||||
'param': instance.param,
|
||||
'goto': instance.goto,
|
||||
'length': instance.length,
|
||||
'duration': instance.duration,
|
||||
'is_popular': instance.isPopular,
|
||||
'is_steins': instance.isSteins,
|
||||
'is_ugcpay': instance.isUgcpay,
|
||||
'is_cooperation': instance.isCooperation,
|
||||
'is_pgc': instance.isPgc,
|
||||
'is_live_playback': instance.isLivePlayback,
|
||||
'is_pugv': instance.isPugv,
|
||||
'is_fold': instance.isFold,
|
||||
'is_oneself': instance.isOneself,
|
||||
'play': instance.play,
|
||||
'danmaku': instance.danmaku,
|
||||
'ctime': instance.ctime,
|
||||
'ugc_pay': instance.ugcPay,
|
||||
'author': instance.author,
|
||||
'state': instance.state,
|
||||
'bvid': instance.bvid,
|
||||
'videos': instance.videos,
|
||||
'three_point': instance.threePoint,
|
||||
'first_cid': instance.firstCid,
|
||||
'cursor_attr': instance.cursorAttr,
|
||||
'view_content': instance.viewContent,
|
||||
'icon_type': instance.iconType,
|
||||
'publish_time_text': instance.publishTimeText,
|
||||
'badges': instance.badges,
|
||||
'season': instance.season,
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import '../model_owner.dart';
|
||||
import '../model_video.dart';
|
||||
|
||||
class MediaVideoItemModel {
|
||||
MediaVideoItemModel({
|
||||
this.id,
|
||||
@@ -43,7 +46,7 @@ class MediaVideoItemModel {
|
||||
int? attr;
|
||||
int? tid;
|
||||
int? copyRight;
|
||||
Map? cntInfo;
|
||||
Map<String, dynamic>? cntInfo;
|
||||
String? cover;
|
||||
int? duration;
|
||||
int? pubtime;
|
||||
@@ -152,24 +155,6 @@ class Page {
|
||||
);
|
||||
}
|
||||
|
||||
class Dimension {
|
||||
Dimension({
|
||||
this.width,
|
||||
this.height,
|
||||
this.rotate,
|
||||
});
|
||||
|
||||
int? width;
|
||||
int? height;
|
||||
int? rotate;
|
||||
|
||||
factory Dimension.fromJson(Map<String, dynamic> json) => Dimension(
|
||||
width: json["width"],
|
||||
height: json["height"],
|
||||
rotate: json["rotate"],
|
||||
);
|
||||
}
|
||||
|
||||
class Meta {
|
||||
Meta({
|
||||
this.quality,
|
||||
@@ -224,26 +209,7 @@ class Rights {
|
||||
);
|
||||
}
|
||||
|
||||
class Upper {
|
||||
Upper({
|
||||
this.mid,
|
||||
this.name,
|
||||
this.face,
|
||||
this.followed,
|
||||
this.fans,
|
||||
this.vipType,
|
||||
this.vipStatue,
|
||||
this.vipDueDate,
|
||||
this.vipPayType,
|
||||
this.officialRole,
|
||||
this.officialTitle,
|
||||
this.officialDesc,
|
||||
this.displayName,
|
||||
});
|
||||
|
||||
int? mid;
|
||||
String? name;
|
||||
String? face;
|
||||
class Upper extends Owner {
|
||||
int? followed;
|
||||
int? fans;
|
||||
int? vipType;
|
||||
@@ -255,19 +221,16 @@ class Upper {
|
||||
String? officialDesc;
|
||||
String? displayName;
|
||||
|
||||
factory Upper.fromJson(Map<String, dynamic> json) => Upper(
|
||||
mid: json["mid"],
|
||||
name: json["name"],
|
||||
face: json["face"],
|
||||
followed: json["followed"],
|
||||
fans: json["fans"],
|
||||
vipType: json["vip_type"],
|
||||
vipStatue: json["vip_statue"],
|
||||
vipDueDate: json["vip_due_date"],
|
||||
vipPayType: json["vip_pay_type"],
|
||||
officialRole: json["official_role"],
|
||||
officialTitle: json["official_title"],
|
||||
officialDesc: json["official_desc"],
|
||||
displayName: json["display_name"],
|
||||
);
|
||||
Upper.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
followed = json["followed"];
|
||||
fans = json["fans"];
|
||||
vipType = json["vip_type"];
|
||||
vipStatue = json["vip_statue"];
|
||||
vipDueDate = json["vip_due_date"];
|
||||
vipPayType = json["vip_pay_type"];
|
||||
officialRole = json["official_role"];
|
||||
officialTitle = json["official_title"];
|
||||
officialDesc = json["official_desc"];
|
||||
displayName = json["display_name"];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user