diff --git a/lib/models_new/video/video_play_info/subtitle.dart b/lib/models_new/video/video_play_info/subtitle.dart index 445d3c71f..f43b0f9d1 100644 --- a/lib/models_new/video/video_play_info/subtitle.dart +++ b/lib/models_new/video/video_play_info/subtitle.dart @@ -11,10 +11,10 @@ class Subtitle { this.subtitleUrlV2, }); - factory Subtitle.fromJson(Map json) => Subtitle( - lan: json["lan"], - lanDoc: json["lan_doc"], - subtitleUrl: json["subtitle_url"], - subtitleUrlV2: json["subtitle_url_v2"], - ); + Subtitle.fromJson(Map json) { + lan = json["lan"]; + lanDoc = '${json["lan_doc"]}${lan!.startsWith('ai') ? '(AI)' : ''}'; + subtitleUrl = json["subtitle_url"]; + subtitleUrlV2 = json["subtitle_url_v2"]; + } } diff --git a/lib/models_new/video/video_play_info/subtitle_info.dart b/lib/models_new/video/video_play_info/subtitle_info.dart index b70956089..128f33d54 100644 --- a/lib/models_new/video/video_play_info/subtitle_info.dart +++ b/lib/models_new/video/video_play_info/subtitle_info.dart @@ -7,11 +7,22 @@ class SubtitleInfo { SubtitleInfo({this.lan, this.lanDoc, this.subtitles}); - factory SubtitleInfo.fromJson(Map json) => SubtitleInfo( - lan: json['lan'] as String?, - lanDoc: json['lan_doc'] as String?, - subtitles: (json['subtitles'] as List?) - ?.map((e) => Subtitle.fromJson(e as Map)) - .toList(), - ); + SubtitleInfo.fromJson(Map json) { + lan = json['lan'] as String?; + lanDoc = json['lan_doc'] as String?; + final List? list = json['subtitles']; + if (list != null && list.isNotEmpty) { + subtitles = []; + int index = 0; + for (var e in list) { + final item = Subtitle.fromJson(e); + if (item.lan!.contains('zh')) { + subtitles!.insert(index, item); + index++; + } else { + subtitles!.add(item); + } + } + } + } }