mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 新增视频标题本地关键词过滤
This commit is contained in:
@@ -28,6 +28,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
|||||||
// late int filterUnfollowedRatio;
|
// late int filterUnfollowedRatio;
|
||||||
late int minDurationForRcmd;
|
late int minDurationForRcmd;
|
||||||
late int minLikeRatioForRecommend;
|
late int minLikeRatioForRecommend;
|
||||||
|
late String banWordForRecommend;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -44,6 +45,8 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
|||||||
setting.get(SettingBoxKey.minDurationForRcmd, defaultValue: 0);
|
setting.get(SettingBoxKey.minDurationForRcmd, defaultValue: 0);
|
||||||
minLikeRatioForRecommend =
|
minLikeRatioForRecommend =
|
||||||
setting.get(SettingBoxKey.minLikeRatioForRecommend, defaultValue: 0);
|
setting.get(SettingBoxKey.minLikeRatioForRecommend, defaultValue: 0);
|
||||||
|
banWordForRecommend =
|
||||||
|
setting.get(SettingBoxKey.banWordForRecommend, defaultValue: '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -144,6 +147,66 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
leading: const Icon(Icons.title_outlined),
|
||||||
|
title: Text('标题关键词过滤', style: titleStyle),
|
||||||
|
subtitle: Text(
|
||||||
|
banWordForRecommend.isEmpty ? "点击添加" : banWordForRecommend,
|
||||||
|
style: subTitleStyle,
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
final TextEditingController textController =
|
||||||
|
TextEditingController(text: banWordForRecommend);
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('标题关键词过滤'),
|
||||||
|
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||||
|
const Text('使用空格隔开,如:尝试 测试'),
|
||||||
|
TextField(
|
||||||
|
controller: textController,
|
||||||
|
//decoration: InputDecoration(hintText: hintText),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: const Text('清空'),
|
||||||
|
onPressed: () {
|
||||||
|
textController.text = '';
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('取消'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
SmartDialog.showToast('关键词未被修改');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('保存'),
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
String filter = textController.text.trim();
|
||||||
|
banWordForRecommend = filter;
|
||||||
|
setting.put(SettingBoxKey.banWordForRecommend,
|
||||||
|
banWordForRecommend);
|
||||||
|
setState(() {});
|
||||||
|
RecommendFilter.update();
|
||||||
|
if (filter.isNotEmpty) {
|
||||||
|
SmartDialog.showToast('已保存:$banWordForRecommend');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast('已清除全部关键词');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: false,
|
dense: false,
|
||||||
title: Text('视频时长过滤', style: titleStyle),
|
title: Text('视频时长过滤', style: titleStyle),
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class RecommendFilter {
|
|||||||
static late int minLikeRatioForRecommend;
|
static late int minLikeRatioForRecommend;
|
||||||
static late bool exemptFilterForFollowed;
|
static late bool exemptFilterForFollowed;
|
||||||
static late bool applyFilterToRelatedVideos;
|
static late bool applyFilterToRelatedVideos;
|
||||||
|
static late List<String> banWordList;
|
||||||
RecommendFilter() {
|
RecommendFilter() {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -20,6 +21,9 @@ class RecommendFilter {
|
|||||||
setting.get(SettingBoxKey.minDurationForRcmd, defaultValue: 0);
|
setting.get(SettingBoxKey.minDurationForRcmd, defaultValue: 0);
|
||||||
minLikeRatioForRecommend =
|
minLikeRatioForRecommend =
|
||||||
setting.get(SettingBoxKey.minLikeRatioForRecommend, defaultValue: 0);
|
setting.get(SettingBoxKey.minLikeRatioForRecommend, defaultValue: 0);
|
||||||
|
banWordList = (setting.get(SettingBoxKey.banWordForRecommend,
|
||||||
|
defaultValue: '') as String)
|
||||||
|
.split(' ');
|
||||||
exemptFilterForFollowed =
|
exemptFilterForFollowed =
|
||||||
setting.get(SettingBoxKey.exemptFilterForFollowed, defaultValue: true);
|
setting.get(SettingBoxKey.exemptFilterForFollowed, defaultValue: true);
|
||||||
applyFilterToRelatedVideos = setting
|
applyFilterToRelatedVideos = setting
|
||||||
@@ -47,6 +51,9 @@ class RecommendFilter {
|
|||||||
minLikeRatioForRecommend * videoItem.stat.view) {
|
minLikeRatioForRecommend * videoItem.stat.view) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
for (var word in banWordList) {
|
||||||
|
if (word.isNotEmpty && videoItem.title.contains(word)) return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ class SettingBoxKey {
|
|||||||
minDurationForRcmd = 'minDurationForRcmd',
|
minDurationForRcmd = 'minDurationForRcmd',
|
||||||
minLikeRatioForRecommend = 'minLikeRatioForRecommend',
|
minLikeRatioForRecommend = 'minLikeRatioForRecommend',
|
||||||
exemptFilterForFollowed = 'exemptFilterForFollowed',
|
exemptFilterForFollowed = 'exemptFilterForFollowed',
|
||||||
|
banWordForRecommend = 'banWordForRecommend',
|
||||||
//filterUnfollowedRatio = 'filterUnfollowedRatio',
|
//filterUnfollowedRatio = 'filterUnfollowedRatio',
|
||||||
applyFilterToRelatedVideos = 'applyFilterToRelatedVideos',
|
applyFilterToRelatedVideos = 'applyFilterToRelatedVideos',
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user