mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: filter hot/rank video title
Closes #38 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -8,7 +8,7 @@ class RecommendFilter {
|
||||
static late int minLikeRatioForRecommend;
|
||||
static late bool exemptFilterForFollowed;
|
||||
static late bool applyFilterToRelatedVideos;
|
||||
static late List<String> banWordList;
|
||||
static late String banWords;
|
||||
RecommendFilter() {
|
||||
update();
|
||||
}
|
||||
@@ -21,9 +21,7 @@ class RecommendFilter {
|
||||
setting.get(SettingBoxKey.minDurationForRcmd, defaultValue: 0);
|
||||
minLikeRatioForRecommend =
|
||||
setting.get(SettingBoxKey.minLikeRatioForRecommend, defaultValue: 0);
|
||||
banWordList = (setting.get(SettingBoxKey.banWordForRecommend,
|
||||
defaultValue: '') as String)
|
||||
.split(' ');
|
||||
banWords = setting.get(SettingBoxKey.banWordForRecommend, defaultValue: '');
|
||||
exemptFilterForFollowed =
|
||||
setting.get(SettingBoxKey.exemptFilterForFollowed, defaultValue: true);
|
||||
applyFilterToRelatedVideos = setting
|
||||
@@ -51,8 +49,18 @@ class RecommendFilter {
|
||||
minLikeRatioForRecommend * videoItem.stat.view) {
|
||||
return true;
|
||||
}
|
||||
for (var word in banWordList) {
|
||||
if (word.isNotEmpty && videoItem.title.contains(word)) return true;
|
||||
if (filterTitle(videoItem.title)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool filterTitle(String title, {bool? isFollowed}) {
|
||||
if (exemptFilterForFollowed && isFollowed == true) {
|
||||
return false;
|
||||
}
|
||||
if (banWords.isNotEmpty && RegExp(banWords).hasMatch(title)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user