mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-18 08:06:21 +08:00
committed by
GitHub
parent
c899ea95e1
commit
8d34e6f340
@@ -1,30 +1,16 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
enum AudioQuality {
|
||||
k64(30216, '64K'),
|
||||
k132(30232, '132K'),
|
||||
k192(30280, '192K'),
|
||||
dolby(30250, '杜比全景声'),
|
||||
hiRes(30251, 'Hi-Res无损');
|
||||
|
||||
enum AudioQuality { k64, k132, k192, dolby, hiRes }
|
||||
final int code;
|
||||
final String description;
|
||||
|
||||
extension AudioQualityExt on AudioQuality {
|
||||
static const List<int> _codeList = [
|
||||
30216,
|
||||
30232,
|
||||
30280,
|
||||
30250,
|
||||
30251,
|
||||
];
|
||||
int get code => _codeList[index];
|
||||
const AudioQuality(this.code, this.description);
|
||||
|
||||
static AudioQuality? fromCode(int code) {
|
||||
final index = _codeList.indexOf(code);
|
||||
if (index != -1) {
|
||||
return AudioQuality.values[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
static final _codeMap = {for (var i in values) i.code: i};
|
||||
|
||||
String get description => const [
|
||||
'64K',
|
||||
'132K',
|
||||
'192K',
|
||||
'杜比全景声',
|
||||
'Hi-Res无损',
|
||||
][index];
|
||||
static AudioQuality fromCode(int code) => _codeMap[code]!;
|
||||
}
|
||||
|
||||
@@ -1,55 +1,23 @@
|
||||
enum VideoQuality {
|
||||
speed240,
|
||||
fluent360,
|
||||
clear480,
|
||||
high720,
|
||||
high72060,
|
||||
high1080,
|
||||
high1080plus,
|
||||
high108060,
|
||||
super4K,
|
||||
hdr,
|
||||
dolbyVision,
|
||||
super8k
|
||||
}
|
||||
|
||||
extension VideoQualityExt on VideoQuality {
|
||||
static const List<int> _codeList = [
|
||||
6,
|
||||
16,
|
||||
32,
|
||||
64,
|
||||
74,
|
||||
80,
|
||||
112,
|
||||
116,
|
||||
120,
|
||||
125,
|
||||
126,
|
||||
127,
|
||||
];
|
||||
int get code => _codeList[index];
|
||||
|
||||
static VideoQuality? fromCode(int code) {
|
||||
final index = _codeList.indexOf(code);
|
||||
if (index != -1) {
|
||||
return VideoQuality.values[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String get description => const [
|
||||
'240P 极速',
|
||||
'360P 流畅',
|
||||
'480P 清晰',
|
||||
'720P 高清',
|
||||
'720P60 高帧率',
|
||||
'1080P 高清',
|
||||
'1080P+ 高码率',
|
||||
'1080P60 高帧率',
|
||||
'4K 超清',
|
||||
'HDR 真彩色',
|
||||
'杜比视界',
|
||||
'8K 超高清'
|
||||
][index];
|
||||
speed240(6, '240P 极速'),
|
||||
fluent360(16, '360P 流畅'),
|
||||
clear480(32, '480P 清晰'),
|
||||
high720(64, '720P 高清'),
|
||||
high72060(74, '720P60 高帧率'),
|
||||
high1080(80, '1080P 高清'),
|
||||
high1080plus(112, '1080P+ 高码率'),
|
||||
high108060(116, '1080P60 高帧率'),
|
||||
super4K(120, '4K 超清'),
|
||||
hdr(125, 'HDR 真彩色'),
|
||||
dolbyVision(126, '杜比视界'),
|
||||
super8k(127, '8K 超高清');
|
||||
|
||||
final int code;
|
||||
final String description;
|
||||
|
||||
const VideoQuality(this.code, this.description);
|
||||
|
||||
static final _codeMap = {for (var i in values) i.code: i};
|
||||
|
||||
static VideoQuality fromCode(int code) => _codeMap[code]!;
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
import 'package:PiliPlus/models/dynamics/article_list/category.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_list/stats.dart';
|
||||
|
||||
class Article {
|
||||
int? id;
|
||||
String? title;
|
||||
int? state;
|
||||
int? publishTime;
|
||||
int? words;
|
||||
List? imageUrls;
|
||||
Category? category;
|
||||
List<Category>? categories;
|
||||
String? summary;
|
||||
int? type;
|
||||
String? dynIdStr;
|
||||
int? attributes;
|
||||
int? authorUid;
|
||||
int? onlyFans;
|
||||
Stats? stats;
|
||||
int? likeState;
|
||||
|
||||
Article({
|
||||
this.id,
|
||||
this.title,
|
||||
this.state,
|
||||
this.publishTime,
|
||||
this.words,
|
||||
this.imageUrls,
|
||||
this.category,
|
||||
this.categories,
|
||||
this.summary,
|
||||
this.type,
|
||||
this.dynIdStr,
|
||||
this.attributes,
|
||||
this.authorUid,
|
||||
this.onlyFans,
|
||||
this.stats,
|
||||
this.likeState,
|
||||
});
|
||||
|
||||
factory Article.fromJson(Map<String, dynamic> json) => Article(
|
||||
id: json['id'] as int?,
|
||||
title: json['title'] as String?,
|
||||
state: json['state'] as int?,
|
||||
publishTime: json['publish_time'] as int?,
|
||||
words: json['words'] as int?,
|
||||
imageUrls: json['image_urls'],
|
||||
category: json['category'] == null
|
||||
? null
|
||||
: Category.fromJson(json['category'] as Map<String, dynamic>),
|
||||
categories: (json['categories'] as List<dynamic>?)
|
||||
?.map((e) => Category.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
summary: json['summary'] as String?,
|
||||
type: json['type'] as int?,
|
||||
dynIdStr: json['dyn_id_str'] as String?,
|
||||
attributes: json['attributes'] as int?,
|
||||
authorUid: json['author_uid'] as int?,
|
||||
onlyFans: json['only_fans'] as int?,
|
||||
stats: json['stats'] == null
|
||||
? null
|
||||
: Stats.fromJson(json['stats'] as Map<String, dynamic>),
|
||||
likeState: json['like_state'] as int?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'state': state,
|
||||
'publish_time': publishTime,
|
||||
'words': words,
|
||||
'image_urls': imageUrls,
|
||||
'category': category?.toJson(),
|
||||
'categories': categories?.map((e) => e.toJson()).toList(),
|
||||
'summary': summary,
|
||||
'type': type,
|
||||
'dyn_id_str': dynIdStr,
|
||||
'attributes': attributes,
|
||||
'author_uid': authorUid,
|
||||
'only_fans': onlyFans,
|
||||
'stats': stats?.toJson(),
|
||||
'like_state': likeState,
|
||||
};
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
class Author {
|
||||
int? mid;
|
||||
String? name;
|
||||
String? face;
|
||||
|
||||
Author({
|
||||
this.mid,
|
||||
this.name,
|
||||
this.face,
|
||||
});
|
||||
|
||||
factory Author.fromJson(Map<String, dynamic> json) => Author(
|
||||
mid: json['mid'] as int?,
|
||||
name: json['name'] as String?,
|
||||
face: json['face'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'mid': mid,
|
||||
'name': name,
|
||||
'face': face,
|
||||
};
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
class Category {
|
||||
int? id;
|
||||
int? parentId;
|
||||
String? name;
|
||||
|
||||
Category({this.id, this.parentId, this.name});
|
||||
|
||||
factory Category.fromJson(Map<String, dynamic> json) => Category(
|
||||
id: json['id'] as int?,
|
||||
parentId: json['parent_id'] as int?,
|
||||
name: json['name'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'parent_id': parentId,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:PiliPlus/models/dynamics/article_list/article.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_list/author.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_list/list.dart';
|
||||
import 'package:PiliPlus/models/model_owner.dart';
|
||||
import 'package:PiliPlus/models/space_article/item.dart';
|
||||
|
||||
class ArticleListData {
|
||||
ArticleList? list;
|
||||
List<Article>? articles;
|
||||
Author? author;
|
||||
List<SpaceArticleItem>? articles;
|
||||
Owner? author;
|
||||
bool? attention;
|
||||
|
||||
ArticleListData({
|
||||
@@ -21,18 +21,11 @@ class ArticleListData {
|
||||
? null
|
||||
: ArticleList.fromJson(json['list'] as Map<String, dynamic>),
|
||||
articles: (json['articles'] as List<dynamic>?)
|
||||
?.map((e) => Article.fromJson(e as Map<String, dynamic>))
|
||||
?.map((e) => SpaceArticleItem.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
author: json['author'] == null
|
||||
? null
|
||||
: Author.fromJson(json['author'] as Map<String, dynamic>),
|
||||
: Owner.fromJson(json['author'] as Map<String, dynamic>),
|
||||
attention: json['attention'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'list': list?.toJson(),
|
||||
'articles': articles?.map((e) => e.toJson()).toList(),
|
||||
'author': author?.toJson(),
|
||||
'attention': attention,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
class Stats {
|
||||
int? view;
|
||||
int? favorite;
|
||||
int? like;
|
||||
int? dislike;
|
||||
int? reply;
|
||||
int? share;
|
||||
int? coin;
|
||||
int? dynam1c;
|
||||
|
||||
Stats({
|
||||
this.view,
|
||||
this.favorite,
|
||||
this.like,
|
||||
this.dislike,
|
||||
this.reply,
|
||||
this.share,
|
||||
this.coin,
|
||||
this.dynam1c,
|
||||
});
|
||||
|
||||
factory Stats.fromJson(Map<String, dynamic> json) => Stats(
|
||||
view: json['view'] as int?,
|
||||
favorite: json['favorite'] as int?,
|
||||
like: json['like'] as int?,
|
||||
dislike: json['dislike'] as int?,
|
||||
reply: json['reply'] as int?,
|
||||
share: json['share'] as int?,
|
||||
coin: json['coin'] as int?,
|
||||
dynam1c: json['dynamic'] as int?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'view': view,
|
||||
'favorite': favorite,
|
||||
'like': like,
|
||||
'dislike': dislike,
|
||||
'reply': reply,
|
||||
'share': share,
|
||||
'coin': coin,
|
||||
'dynamic': dynam1c,
|
||||
};
|
||||
}
|
||||
@@ -136,24 +136,7 @@ bool _isMCDNorPCDN(String url) {
|
||||
_ipRegExp.hasMatch(url);
|
||||
}
|
||||
|
||||
class VideoItem {
|
||||
VideoItem({
|
||||
this.id,
|
||||
this.baseUrl,
|
||||
this.backupUrl,
|
||||
this.bandWidth,
|
||||
this.mimeType,
|
||||
this.codecs,
|
||||
this.width,
|
||||
this.height,
|
||||
this.frameRate,
|
||||
this.sar,
|
||||
this.startWithSap,
|
||||
this.segmentBase,
|
||||
this.codecid,
|
||||
this.quality,
|
||||
});
|
||||
|
||||
abstract class BaseItem {
|
||||
int? id;
|
||||
String? baseUrl;
|
||||
String? backupUrl;
|
||||
@@ -167,16 +150,31 @@ class VideoItem {
|
||||
int? startWithSap;
|
||||
Map? segmentBase;
|
||||
int? codecid;
|
||||
VideoQuality? quality;
|
||||
|
||||
VideoItem.fromJson(Map<String, dynamic> json) {
|
||||
BaseItem({
|
||||
this.id,
|
||||
this.baseUrl,
|
||||
this.backupUrl,
|
||||
this.bandWidth,
|
||||
this.mimeType,
|
||||
this.codecs,
|
||||
this.width,
|
||||
this.height,
|
||||
this.frameRate,
|
||||
this.sar,
|
||||
this.startWithSap,
|
||||
this.segmentBase,
|
||||
this.codecid,
|
||||
});
|
||||
|
||||
BaseItem.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
baseUrl = json['baseUrl'];
|
||||
var backupUrls = json['backupUrl']?.toList() ?? [];
|
||||
final backupUrls = (json['backupUrl'] as List?)?.cast<String>() ?? [];
|
||||
backupUrl = backupUrls.isNotEmpty
|
||||
? backupUrls.firstWhere((i) => !_isMCDNorPCDN(i),
|
||||
orElse: () => backupUrls.first)
|
||||
: '';
|
||||
: null;
|
||||
bandWidth = json['bandWidth'];
|
||||
mimeType = json['mime_type'];
|
||||
codecs = json['codecs'];
|
||||
@@ -187,82 +185,41 @@ class VideoItem {
|
||||
startWithSap = json['startWithSap'];
|
||||
segmentBase = json['segmentBase'];
|
||||
codecid = json['codecid'];
|
||||
quality = VideoQuality.values.firstWhere((i) => i.code == json['id']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['baseUrl'] = baseUrl;
|
||||
data['backupUrl'] = backupUrl;
|
||||
data['bandWidth'] = bandWidth;
|
||||
data['mime_type'] = mimeType;
|
||||
data['codecs'] = codecs;
|
||||
data['width'] = width;
|
||||
data['height'] = height;
|
||||
data['frameRate'] = frameRate;
|
||||
data['sar'] = sar;
|
||||
data['startWithSap'] = startWithSap;
|
||||
data['segmentBase'] = segmentBase;
|
||||
data['codecid'] = codecid;
|
||||
data['quality'] = quality;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class AudioItem {
|
||||
AudioItem({
|
||||
this.id,
|
||||
this.baseUrl,
|
||||
this.backupUrl,
|
||||
this.bandWidth,
|
||||
this.mimeType,
|
||||
this.codecs,
|
||||
this.width,
|
||||
this.height,
|
||||
this.frameRate,
|
||||
this.sar,
|
||||
this.startWithSap,
|
||||
this.segmentBase,
|
||||
this.codecid,
|
||||
this.quality,
|
||||
class VideoItem extends BaseItem {
|
||||
late VideoQuality quality;
|
||||
|
||||
VideoItem({
|
||||
super.id,
|
||||
super.baseUrl,
|
||||
super.backupUrl,
|
||||
super.bandWidth,
|
||||
super.mimeType,
|
||||
super.codecs,
|
||||
super.width,
|
||||
super.height,
|
||||
super.frameRate,
|
||||
super.sar,
|
||||
super.startWithSap,
|
||||
super.segmentBase,
|
||||
super.codecid,
|
||||
required this.quality,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? baseUrl;
|
||||
String? backupUrl;
|
||||
int? bandWidth;
|
||||
String? mimeType;
|
||||
String? codecs;
|
||||
int? width;
|
||||
int? height;
|
||||
String? frameRate;
|
||||
String? sar;
|
||||
int? startWithSap;
|
||||
Map? segmentBase;
|
||||
int? codecid;
|
||||
String? quality;
|
||||
VideoItem.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
quality = VideoQuality.fromCode(json['id']);
|
||||
}
|
||||
}
|
||||
|
||||
AudioItem.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
baseUrl = json['baseUrl'];
|
||||
var backupUrls = json['backupUrl']?.toList() ?? [];
|
||||
backupUrl = backupUrls.isNotEmpty
|
||||
? backupUrls.firstWhere((i) => !_isMCDNorPCDN(i),
|
||||
orElse: () => backupUrls.first)
|
||||
: '';
|
||||
bandWidth = json['bandWidth'];
|
||||
mimeType = json['mime_type'];
|
||||
codecs = json['codecs'];
|
||||
width = json['width'];
|
||||
height = json['height'];
|
||||
frameRate = json['frameRate'];
|
||||
sar = json['sar'];
|
||||
startWithSap = json['startWithSap'];
|
||||
segmentBase = json['segmentBase'];
|
||||
codecid = json['codecid'];
|
||||
quality =
|
||||
AudioQuality.values.firstWhere((i) => i.code == json['id']).description;
|
||||
class AudioItem extends BaseItem {
|
||||
late String quality;
|
||||
|
||||
AudioItem();
|
||||
|
||||
AudioItem.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
quality = AudioQuality.fromCode(json['id']).description;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user