mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-30 14:20:15 +08:00
feat: more subtitle
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
class Subtitle {
|
||||
class Subtitle implements Comparable<Subtitle> {
|
||||
late String lan;
|
||||
String? lanDoc;
|
||||
String? subtitleUrl;
|
||||
@@ -8,6 +8,8 @@ class Subtitle {
|
||||
Subtitle({
|
||||
required this.lan,
|
||||
this.lanDoc,
|
||||
this.subtitleUrl,
|
||||
this.isAi = false,
|
||||
});
|
||||
|
||||
Subtitle.fromJson(Map<String, dynamic> json) {
|
||||
@@ -17,4 +19,13 @@ class Subtitle {
|
||||
subtitleUrl = json["subtitle_url"];
|
||||
subtitleUrlV2 = json["subtitle_url_v2"];
|
||||
}
|
||||
|
||||
@override
|
||||
int compareTo(Subtitle other) {
|
||||
final thisHasZh = lan.contains('zh');
|
||||
final otherHasZh = other.lan.contains('zh');
|
||||
if (thisHasZh != otherHasZh) return thisHasZh ? -1 : 1;
|
||||
if (isAi != other.isAi) return isAi ? 1 : -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,6 @@ class SubtitleInfo {
|
||||
(json['subtitles'] as List<dynamic>?)
|
||||
?.map((e) => Subtitle.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
?..sort((a, b) {
|
||||
final aHasZh = a.lan.contains('zh');
|
||||
final bHasZh = b.lan.contains('zh');
|
||||
if (aHasZh != bHasZh) return aHasZh ? -1 : 1;
|
||||
if (a.isAi != b.isAi) return a.isAi ? 1 : -1;
|
||||
return 0;
|
||||
}),
|
||||
?..sort(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user