From acb0de1adf0d755ff32ff15c0b551cd1d18f49d5 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 11 Nov 2024 09:51:19 +0800 Subject: [PATCH 1/2] mod: skipSegments type filter --- lib/http/common.dart | 3 +-- lib/pages/video/detail/controller.dart | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/http/common.dart b/lib/http/common.dart index 3096ecf7..454a355a 100644 --- a/lib/http/common.dart +++ b/lib/http/common.dart @@ -21,7 +21,6 @@ class CommonHttp { var res = await Request().get(Api.getSkipSegments, data: { 'videoID': bvid, }); - print(res.data); if (res.data is List && res.data.isNotEmpty) { try { return { @@ -39,7 +38,7 @@ class CommonHttp { } } else { return { - 'status': true, + 'status': false, 'data': [], }; } diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index be86246e..6d2d7739 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -722,15 +722,16 @@ class VideoDetailController extends GetxController var res = await CommonHttp.querySkipSegments(bvid: bvid); if (res['status']) { /// TODO 根据segmentType过滤数据 - skipSegments = res['data']; - } else { - SmartDialog.showToast(res['msg']); + skipSegments = res['data'] ?? []; } } // 监听视频进度 void onPositionChanged() async { - if (skipSegments.isEmpty) { + final List sponsorSkipSegments = skipSegments + .where((e) => e.category!.value == SegmentType.sponsor.value) + .toList(); + if (sponsorSkipSegments.isEmpty) { return; } @@ -744,8 +745,7 @@ class VideoDetailController extends GetxController } lastPosition = positionMs; - - for (SegmentDataModel segment in skipSegments) { + for (SegmentDataModel segment in sponsorSkipSegments) { try { final segmentStart = segment.segment!.first.toInt(); final segmentEnd = segment.segment!.last.toInt(); From e112a8589420b4bcaf3bb1e93cce81e2d0860958 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 11 Nov 2024 22:24:37 +0800 Subject: [PATCH 2/2] opt: request method --- lib/http/common.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/http/common.dart b/lib/http/common.dart index 454a355a..2f5f0e84 100644 --- a/lib/http/common.dart +++ b/lib/http/common.dart @@ -18,7 +18,7 @@ class CommonHttp { } static Future querySkipSegments({required String bvid}) async { - var res = await Request().get(Api.getSkipSegments, data: { + var res = await Request().getWithoutCookie(Api.getSkipSegments, data: { 'videoID': bvid, }); if (res.data is List && res.data.isNotEmpty) {