Skip to content

Commit

Permalink
fix: miss maccms json reponse parse
Browse files Browse the repository at this point in the history
Release Notes:
- fix: 修复部分 maccms 源返回 json 解析失败
  • Loading branch information
d1y committed Jun 27, 2024
1 parent c0f1b16 commit ca1c968
Show file tree
Hide file tree
Showing 4 changed files with 307 additions and 143 deletions.
55 changes: 1 addition & 54 deletions lib/app/modules/play/views/play_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:movie/app/widget/helper.dart';
import 'package:movie/app/widget/window_appbar.dart';
import 'package:movie/widget/simple_html/flutter_html.dart';
import 'package:simple/x.dart';
import 'package:xi/adapters/mac_cms.dart';
import 'package:xi/xi.dart';

import '../controllers/play_controller.dart';
Expand All @@ -21,17 +20,6 @@ class PlayState {
final int index;
}

class PlayListData {
final String title;

final List<VideoInfo> datas;

PlayListData({
required this.title,
required this.datas,
});
}

class PlayView extends StatefulWidget {
const PlayView({super.key});

Expand Down Expand Up @@ -59,48 +47,7 @@ class _PlayViewState extends State<PlayView> {
}

List<PlayListData> get playlist {
List<PlayListData> result = [];
var v = play.movieItem.videos;
for (var element in v) {
var url = element.url;
var hasUrl = isURL(url);
if (hasUrl) {
var output = [element];
result.add(PlayListData(title: element.name, datas: []));
var urls = url.split("#");
if (urls.length >= 2) {
output = urls
.map(
(e) => VideoInfo(
url: e,
type: MacCMSSpider.easyGetVideoType(e),
),
)
.toList();
}
result.last.datas.addAll(output);
} else {
var movies = url.split("#");
var cache = PlayListData(title: element.name, datas: []);
for (var e in movies) {
var subItem = e.split("\$");
if (subItem.length <= 1) continue;
var title = subItem[0];
var url = subItem[1];
// var subType = subItem[2];
cache.datas.add(VideoInfo(
name: title,
url: url,
type: MacCMSSpider.easyGetVideoType(url),
));
}
result.add(cache);
}
}
result = result.where((element) {
return element.datas.isNotEmpty;
}).toList();
return result;
return videoInfo2PlayListData(play.movieItem.videos);
}

get tabviewData {
Expand Down
Loading

0 comments on commit ca1c968

Please sign in to comment.