mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-21 08:38:37 +00:00
unify horizontal video models
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
21
lib/models/horizontal_video_model.dart
Normal file
21
lib/models/horizontal_video_model.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:PiliPlus/models/model_video.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/dimension.dart';
|
||||
|
||||
abstract class HorizontalVideoModel extends BaseVideoItemModel {
|
||||
bool? isPugv;
|
||||
int? seasonId;
|
||||
|
||||
int? roomId;
|
||||
bool? isLive;
|
||||
|
||||
Dimension? dimension;
|
||||
|
||||
String? badge;
|
||||
|
||||
num? progress;
|
||||
|
||||
String? redirectUrl;
|
||||
|
||||
// search
|
||||
List<({bool isEm, String text})>? titleList;
|
||||
}
|
||||
@@ -1,25 +1,19 @@
|
||||
import 'package:PiliPlus/models/horizontal_video_model.dart';
|
||||
import 'package:PiliPlus/models/model_owner.dart';
|
||||
import 'package:PiliPlus/models/model_rec_video_item.dart';
|
||||
import 'package:PiliPlus/models/model_video.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/dimension.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select/base.dart';
|
||||
|
||||
// 稍后再看, 排行榜等网页返回也使用该类
|
||||
class HotVideoItemModel extends BaseRcmdVideoItemModel with MultiSelectData {
|
||||
class HotVideoItemModel extends HorizontalVideoModel with MultiSelectData {
|
||||
int? videos;
|
||||
int? tid;
|
||||
String? tname;
|
||||
int? copyright;
|
||||
int? ctime;
|
||||
int? state;
|
||||
Dimension? dimension;
|
||||
String? firstFrame;
|
||||
String? pubLocation;
|
||||
String? pgcLabel;
|
||||
String? redirectUrl;
|
||||
num? progress;
|
||||
int? isCooperation;
|
||||
bool? isCharging;
|
||||
|
||||
HotVideoItemModel.fromJson(Map<String, dynamic> json) {
|
||||
aid = json["aid"];
|
||||
@@ -43,23 +37,16 @@ class HotVideoItemModel extends BaseRcmdVideoItemModel with MultiSelectData {
|
||||
: Dimension.fromJson(json['dimension']);
|
||||
firstFrame = json["first_frame"];
|
||||
pubLocation = json["pub_location"];
|
||||
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']; // 仅在稍后再看存在
|
||||
progress = json['progress'];
|
||||
isCooperation = json['rights']?['is_cooperation'];
|
||||
isCharging = json['charging_pay']?['level'] != null;
|
||||
if (json['charging_pay']?['level'] != null) {
|
||||
badge = '充电专属';
|
||||
} else if (json['rights']?['is_cooperation'] == 1) {
|
||||
badge = '合作';
|
||||
} else {
|
||||
badge = json['pgc_label'];
|
||||
}
|
||||
}
|
||||
|
||||
// @override
|
||||
// get isFollowed => false;
|
||||
// @override
|
||||
// get goto => 'av';
|
||||
// @override
|
||||
// get uri => 'bilibili://video/$aid';
|
||||
}
|
||||
|
||||
class HotStat extends Stat {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/models/horizontal_video_model.dart';
|
||||
import 'package:PiliPlus/models/model_avatar.dart';
|
||||
import 'package:PiliPlus/models/model_owner.dart';
|
||||
import 'package:PiliPlus/models/model_video.dart';
|
||||
@@ -64,18 +65,16 @@ class SearchVideoData extends SearchNumData<SearchVideoItemModel> {
|
||||
}
|
||||
}
|
||||
|
||||
class SearchVideoItemModel extends BaseVideoItemModel {
|
||||
String? type;
|
||||
class SearchVideoItemModel extends HorizontalVideoModel {
|
||||
int? id;
|
||||
String? arcurl;
|
||||
String? tag;
|
||||
int? ctime;
|
||||
int? isUnionVideo;
|
||||
|
||||
List<({bool isEm, String text})>? titleList;
|
||||
@override
|
||||
int? get seasonId => aid;
|
||||
|
||||
SearchVideoItemModel.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
id = json['id'];
|
||||
arcurl = json['arcurl'];
|
||||
aid = json['aid'];
|
||||
@@ -89,7 +88,19 @@ class SearchVideoItemModel extends BaseVideoItemModel {
|
||||
duration = DurationUtils.parseDuration(json['duration']);
|
||||
owner = SearchOwner.fromJson(json);
|
||||
stat = SearchStat.fromJson(json);
|
||||
isUnionVideo = json['is_union_video'];
|
||||
switch (json['type']) {
|
||||
case 'ketang':
|
||||
badge = '课堂';
|
||||
isPugv = true;
|
||||
case 'live_room':
|
||||
badge = '直播';
|
||||
isLive = true;
|
||||
roomId = json['roomid'];
|
||||
default:
|
||||
if (json['is_union_video'] == 1) {
|
||||
badge = '合作';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user