mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: data parse
related #258 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -39,8 +39,8 @@ class ModelResult {
|
||||
ModelResult.fromJson(Map<String, dynamic> json) {
|
||||
resultType = json['result_type'];
|
||||
summary = json['summary'];
|
||||
outline = json['outline']
|
||||
.map<OutlineItem>((e) => OutlineItem.fromJson(e))
|
||||
outline = (json['outline'] as List?)
|
||||
?.map<OutlineItem>((e) => OutlineItem.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -56,8 +56,8 @@ class OutlineItem {
|
||||
|
||||
OutlineItem.fromJson(Map<String, dynamic> json) {
|
||||
title = json['title'];
|
||||
partOutline = json['part_outline']
|
||||
.map<PartOutline>((e) => PartOutline.fromJson(e))
|
||||
partOutline = (json['part_outline'] as List?)
|
||||
?.map<PartOutline>((e) => PartOutline.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,10 +84,7 @@ class MediaVideoItemModel {
|
||||
likeState: json["like_state"],
|
||||
favState: json["fav_state"],
|
||||
page: json["page"],
|
||||
// json["pages"] 可能为null
|
||||
pages: json["pages"] == null
|
||||
? []
|
||||
: List<Page>.from(json["pages"].map((x) => Page.fromJson(x))),
|
||||
pages: (json["pages"] as List?)?.map((x) => Page.fromJson(x)).toList(),
|
||||
title: json["title"],
|
||||
type: json["type"],
|
||||
upper: Upper.fromJson(json["upper"]),
|
||||
@@ -149,7 +146,7 @@ class Page {
|
||||
duration: json["duration"],
|
||||
link: json["link"],
|
||||
page: json["page"],
|
||||
metas: List<Meta>.from(json["metas"].map((x) => Meta.fromJson(x))),
|
||||
metas: (json["metas"] as List?)?.map((x) => Meta.fromJson(x)).toList(),
|
||||
from: json["from"],
|
||||
dimension: Dimension.fromJson(json["dimension"]),
|
||||
);
|
||||
|
||||
@@ -49,17 +49,16 @@ class PlayUrlModel {
|
||||
timeLength = json['timelength'];
|
||||
acceptFormat = json['accept_format'];
|
||||
acceptDesc = json['accept_description'];
|
||||
acceptQuality = json['accept_quality'].map<int>((e) => e as int).toList();
|
||||
acceptQuality =
|
||||
(json['accept_quality'] as List?)?.map<int>((e) => e as int).toList();
|
||||
videoCodecid = json['video_codecid'];
|
||||
seekParam = json['seek_param'];
|
||||
seekType = json['seek_type'];
|
||||
dash = json['dash'] != null ? Dash.fromJson(json['dash']) : null;
|
||||
durl = json['durl']?.map<Durl>((e) => Durl.fromJson(e)).toList();
|
||||
supportFormats = json['support_formats'] != null
|
||||
? json['support_formats']
|
||||
.map<FormatItem>((e) => FormatItem.fromJson(e))
|
||||
.toList()
|
||||
: [];
|
||||
durl = (json['durl'] as List?)?.map<Durl>((e) => Durl.fromJson(e)).toList();
|
||||
supportFormats = (json['support_formats'] as List?)
|
||||
?.map<FormatItem>((e) => FormatItem.fromJson(e))
|
||||
.toList();
|
||||
lastPlayTime = json['last_play_time'];
|
||||
lastPlayCid = json['last_play_cid'];
|
||||
}
|
||||
@@ -85,10 +84,12 @@ class Dash {
|
||||
Dash.fromJson(Map<String, dynamic> json) {
|
||||
duration = json['duration'];
|
||||
minBufferTime = json['minBufferTime'];
|
||||
video = json['video'].map<VideoItem>((e) => VideoItem.fromJson(e)).toList();
|
||||
audio = json['audio'] != null
|
||||
? json['audio'].map<AudioItem>((e) => AudioItem.fromJson(e)).toList()
|
||||
: [];
|
||||
video = (json['video'] as List?)
|
||||
?.map<VideoItem>((e) => VideoItem.fromJson(e))
|
||||
.toList();
|
||||
audio = (json['audio'] as List?)
|
||||
?.map<AudioItem>((e) => AudioItem.fromJson(e))
|
||||
.toList();
|
||||
dolby = json['dolby'] != null ? Dolby.fromJson(json['dolby']) : null;
|
||||
flac = json['flac'] != null ? Flac.fromJson(json['flac']) : null;
|
||||
}
|
||||
@@ -288,9 +289,9 @@ class Dolby {
|
||||
|
||||
Dolby.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
audio = json['audio'] != null
|
||||
? json['audio'].map<AudioItem>((e) => AudioItem.fromJson(e)).toList()
|
||||
: [];
|
||||
audio = (json['audio'] as List?)
|
||||
?.map<AudioItem>((e) => AudioItem.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ class ReplyContent {
|
||||
this.pictures, // {}
|
||||
this.vote,
|
||||
this.richText,
|
||||
this.isText,
|
||||
this.topicsMeta,
|
||||
});
|
||||
|
||||
@@ -20,27 +19,19 @@ class ReplyContent {
|
||||
List? pictures;
|
||||
Map? vote;
|
||||
Map? richText;
|
||||
bool? isText;
|
||||
Map? topicsMeta;
|
||||
|
||||
ReplyContent.fromJson(Map<String, dynamic> json) {
|
||||
message = json['message']
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll(''', "'");
|
||||
message = json['message'];
|
||||
atNameToMid = json['at_name_to_mid'] ?? {};
|
||||
members = json['members'] != null
|
||||
? json['members']
|
||||
.map<MemberItemModel>((e) => MemberItemModel.fromJson(e))
|
||||
.toList()
|
||||
: [];
|
||||
members = (json['members'] as List?)
|
||||
?.map<MemberItemModel>((e) => MemberItemModel.fromJson(e))
|
||||
.toList();
|
||||
emote = json['emote'] ?? {};
|
||||
jumpUrl = json['jump_url'] ?? {};
|
||||
pictures = json['pictures'] ?? [];
|
||||
vote = json['vote'] ?? {};
|
||||
richText = json['rich_text'] ?? {};
|
||||
// 不包含@ 笔记 图片的时候,文字可折叠
|
||||
isText = atNameToMid!.isEmpty && vote!.isEmpty && pictures!.isEmpty;
|
||||
topicsMeta = json['topics_meta'] ?? {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,15 +27,15 @@ class ReplyData {
|
||||
json['cursor'] == null ? null : ReplyCursor.fromJson(json['cursor']);
|
||||
config =
|
||||
json['config'] == null ? null : ReplyConfig.fromJson(json['config']);
|
||||
replies = json['replies'] != null
|
||||
? List<ReplyItemModel>.from(json['replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'])))
|
||||
: <ReplyItemModel>[];
|
||||
topReplies = json['top_replies'] != null
|
||||
? List<ReplyItemModel>.from(json['top_replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'],
|
||||
isTopStatus: true)))
|
||||
: <ReplyItemModel>[];
|
||||
replies = (json['replies'] as List?)
|
||||
?.map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid']))
|
||||
.toList();
|
||||
topReplies = (json['top_replies'] as List?)
|
||||
?.map<ReplyItemModel>((item) => ReplyItemModel.fromJson(
|
||||
item, json['upper']['mid'],
|
||||
isTopStatus: true))
|
||||
.toList();
|
||||
upper = json['upper'] == null ? null : ReplyUpper.fromJson(json['upper']);
|
||||
}
|
||||
}
|
||||
@@ -60,15 +60,15 @@ class ReplyReplyData {
|
||||
ReplyReplyData.fromJson(Map<String, dynamic> json) {
|
||||
page = ReplyPage.fromJson(json['page']);
|
||||
config = ReplyConfig.fromJson(json['config']);
|
||||
replies = json['replies'] != null
|
||||
? List<ReplyItemModel>.from(json['replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'])))
|
||||
: <ReplyItemModel>[];
|
||||
topReplies = json['top_replies'] != null
|
||||
? List<ReplyItemModel>.from(json['top_replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'],
|
||||
isTopStatus: true)))
|
||||
: <ReplyItemModel>[];
|
||||
replies = (json['replies'] as List?)
|
||||
?.map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid']))
|
||||
.toList();
|
||||
topReplies = (json['top_replies'] as List?)
|
||||
?.map<ReplyItemModel>((item) => ReplyItemModel.fromJson(
|
||||
item, json['upper']['mid'],
|
||||
isTopStatus: true))
|
||||
.toList();
|
||||
upper = ReplyUpper.fromJson(json['upper']);
|
||||
root = ReplyItemModel.fromJson(json['root'], json['upper']['mid']);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class EmoteModelData {
|
||||
|
||||
EmoteModelData.fromJson(Map<String, dynamic> json) {
|
||||
setting =
|
||||
json['setting'] != null ? Setting.fromJson(json['setting']) : null;
|
||||
json['setting'] != null ? Setting.fromJson(json['setting']) : null;
|
||||
if (json['packages'] != null) {
|
||||
packages = <Packages>[];
|
||||
json['packages'].forEach((v) {
|
||||
@@ -68,17 +68,17 @@ class Packages {
|
||||
|
||||
Packages(
|
||||
{this.id,
|
||||
this.text,
|
||||
this.url,
|
||||
this.mtime,
|
||||
this.type,
|
||||
this.attr,
|
||||
this.meta,
|
||||
this.emote,
|
||||
this.flags,
|
||||
this.label,
|
||||
this.packageSubTitle,
|
||||
this.refMid});
|
||||
this.text,
|
||||
this.url,
|
||||
this.mtime,
|
||||
this.type,
|
||||
this.attr,
|
||||
this.meta,
|
||||
this.emote,
|
||||
this.flags,
|
||||
this.label,
|
||||
this.packageSubTitle,
|
||||
this.refMid});
|
||||
|
||||
Packages.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
@@ -95,7 +95,7 @@ class Packages {
|
||||
});
|
||||
}
|
||||
flags =
|
||||
json['flags'] != null ? PackagesFlags.fromJson(json['flags']) : null;
|
||||
json['flags'] != null ? PackagesFlags.fromJson(json['flags']) : null;
|
||||
label = json['label'] != null ? Label.fromJson(json['label']) : null;
|
||||
packageSubTitle = json['package_sub_title'];
|
||||
refMid = json['ref_mid'];
|
||||
@@ -189,16 +189,16 @@ class Emote {
|
||||
|
||||
Emote(
|
||||
{this.id,
|
||||
this.packageId,
|
||||
this.text,
|
||||
this.url,
|
||||
this.mtime,
|
||||
this.type,
|
||||
this.attr,
|
||||
this.meta,
|
||||
this.flags,
|
||||
this.activity,
|
||||
this.gifUrl});
|
||||
this.packageId,
|
||||
this.text,
|
||||
this.url,
|
||||
this.mtime,
|
||||
this.type,
|
||||
this.attr,
|
||||
this.meta,
|
||||
this.flags,
|
||||
this.activity,
|
||||
this.gifUrl});
|
||||
|
||||
Emote.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
@@ -245,9 +245,7 @@ class EmoteMeta {
|
||||
|
||||
EmoteMeta.fromJson(Map<String, dynamic> json) {
|
||||
size = json['size'];
|
||||
suggest = json['suggest'] == null
|
||||
? null
|
||||
: List<String>.from(json['suggest'].map((x) => x));
|
||||
suggest = json['suggest'];
|
||||
alias = json['alias'];
|
||||
gifUrl = json['gif_url'];
|
||||
}
|
||||
|
||||
@@ -86,10 +86,9 @@ class ReplyItemModel {
|
||||
action = json['action'];
|
||||
member = ReplyMember.fromJson(json['member']);
|
||||
content = ReplyContent.fromJson(json['content']);
|
||||
replies = json['replies'] != null
|
||||
? List<ReplyItemModel>.from(json['replies']
|
||||
.map((item) => ReplyItemModel.fromJson(item, upperMid)))
|
||||
: <ReplyItemModel>[];
|
||||
replies = (json['replies'] as List?)
|
||||
?.map((item) => ReplyItemModel.fromJson(item, upperMid))
|
||||
.toList();
|
||||
assist = json['assist'];
|
||||
upAction = UpAction.fromJson(json['up_action']);
|
||||
invisible = json['invisible'];
|
||||
@@ -98,9 +97,8 @@ class ReplyItemModel {
|
||||
: ReplyControl.fromJson(json['reply_control']);
|
||||
isUp = upperMid.toString() == json['member']['mid'];
|
||||
isTop = isTopStatus;
|
||||
cardLabel = json['card_label'] != null
|
||||
? json['card_label'].map((e) => e['text_content']).toList()
|
||||
: [];
|
||||
cardLabel =
|
||||
(json['card_label'] as List?)?.map((e) => e['text_content']).toList();
|
||||
rcount = json['rcount'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user