mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-05 01:27:49 +08:00
refa: sb & feat: sb portVideo (WIP) (#1751)
* refa: sb * feat: sb portVideo (WIP) * fix: keep-alive * revert: ua version * fix * tweak [skip ci] Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> --------- Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
d5d95671ff
commit
2be13e7283
@@ -10,6 +10,7 @@ import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/sponsor_block.dart';
|
||||
import 'package:PiliPlus/http/ua_type.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
@@ -63,7 +64,6 @@ import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:PiliPlus/utils/video_utils.dart';
|
||||
import 'package:dio/dio.dart' show Options;
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
@@ -492,25 +492,15 @@ class VideoDetailController extends GetxController
|
||||
plPlayerController.blockColor[segment.index];
|
||||
late RxString videoLabel = ''.obs;
|
||||
|
||||
String get blockServer => plPlayerController.blockServer;
|
||||
|
||||
Timer? skipTimer;
|
||||
late final listKey = GlobalKey<AnimatedListState>();
|
||||
late final List listData = [];
|
||||
|
||||
void _vote(String uuid, int type) {
|
||||
Request()
|
||||
.post(
|
||||
'$blockServer/api/voteOnSponsorTime',
|
||||
queryParameters: {
|
||||
'UUID': uuid,
|
||||
'userID': Pref.blockUserID,
|
||||
'type': type,
|
||||
},
|
||||
)
|
||||
.then((res) {
|
||||
SmartDialog.showToast(res.statusCode == 200 ? '投票成功' : '投票失败');
|
||||
});
|
||||
SponsorBlock.voteOnSponsorTime(
|
||||
uuid: uuid,
|
||||
type: type,
|
||||
).then((i) => SmartDialog.showToast(i.isSuccess ? '投票成功' : '投票失败: $i'));
|
||||
}
|
||||
|
||||
void _showCategoryDialog(BuildContext context, SegmentModel segment) {
|
||||
@@ -528,20 +518,14 @@ class VideoDetailController extends GetxController
|
||||
dense: true,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Request()
|
||||
.post(
|
||||
'$blockServer/api/voteOnSponsorTime',
|
||||
queryParameters: {
|
||||
'UUID': segment.UUID,
|
||||
'userID': Pref.blockUserID,
|
||||
'category': item.name,
|
||||
},
|
||||
)
|
||||
.then((res) {
|
||||
SmartDialog.showToast(
|
||||
'类别更改${res.statusCode == 200 ? '成功' : '失败'}',
|
||||
);
|
||||
});
|
||||
SponsorBlock.voteOnSponsorTime(
|
||||
uuid: segment.UUID,
|
||||
category: item,
|
||||
).then((i) {
|
||||
SmartDialog.showToast(
|
||||
'类别更改${i.isSuccess ? '成功' : '失败: $i'}',
|
||||
);
|
||||
});
|
||||
},
|
||||
title: Text.rich(
|
||||
TextSpan(
|
||||
@@ -736,18 +720,19 @@ class VideoDetailController extends GetxController
|
||||
videoLabel.value = '';
|
||||
segmentList.clear();
|
||||
segmentProgressList.clear();
|
||||
final result = await Request().get(
|
||||
'$blockServer/api/skipSegments',
|
||||
queryParameters: {
|
||||
'videoID': bvid,
|
||||
'cid': cid.value,
|
||||
},
|
||||
options: Options(validateStatus: (status) => true),
|
||||
|
||||
final result = await SponsorBlock.getSkipSegments(
|
||||
bvid: bvid,
|
||||
cid: cid.value,
|
||||
);
|
||||
if (result.statusCode == 200) {
|
||||
if (result.data case List list) {
|
||||
handleSBData(list.map((e) => SegmentItemModel.fromJson(e)).toList());
|
||||
}
|
||||
switch (result) {
|
||||
case Success<List<SegmentItemModel>>(:final response):
|
||||
handleSBData(response);
|
||||
case Error(:final code) when code != 404:
|
||||
if (kDebugMode) {
|
||||
result.toast();
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1013,10 +998,7 @@ class VideoDetailController extends GetxController
|
||||
_showBlockToast('已跳过${item.segmentType.shortTitle}片段');
|
||||
}
|
||||
if (_isBlock && Pref.blockTrack) {
|
||||
Request().post(
|
||||
'$blockServer/api/viewedVideoSponsorTime',
|
||||
queryParameters: {'UUID': item.UUID},
|
||||
);
|
||||
SponsorBlock.viewedVideoSponsorTime(item.UUID);
|
||||
}
|
||||
} else {
|
||||
_showBlockToast('已跳至${item.segmentType.shortTitle}');
|
||||
|
||||
Reference in New Issue
Block a user