From 75a242de2a61ed430daa393f4eef3dc5c2a0e67b Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Tue, 7 Jan 2025 12:18:00 +0800 Subject: [PATCH] mod: hot: filter like ratio Closes #108 Signed-off-by: bggRGjQaUbCoE --- lib/http/video.dart | 4 +++- lib/utils/recommend_filter.dart | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/http/video.dart b/lib/http/video.dart index 716e8371..4e886a5a 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -168,7 +168,9 @@ class VideoHttp { List blackMidsList = GStorage.blackMidsList; for (var i in res.data['data']['list']) { if (!blackMidsList.contains(i['owner']['mid']) && - !RecommendFilter.filterTitle(i['title'])) { + !RecommendFilter.filterTitle(i['title']) && + !RecommendFilter.filterLikeRatio( + i['stat']['like'], i['stat']['view'])) { list.add(HotVideoItemModel.fromJson(i)); } } diff --git a/lib/utils/recommend_filter.dart b/lib/utils/recommend_filter.dart index 57da0a4c..017be090 100644 --- a/lib/utils/recommend_filter.dart +++ b/lib/utils/recommend_filter.dart @@ -43,12 +43,7 @@ class RecommendFilter { if (videoItem.duration > 0 && videoItem.duration < minDurationForRcmd) { return true; } - if (videoItem.stat.view is int && - videoItem.stat.view > -1 && - videoItem.stat.like is int && - videoItem.stat.like > -1 && - videoItem.stat.like * 100 < - minLikeRatioForRecommend * videoItem.stat.view) { + if (filterLikeRatio(videoItem.stat.like, videoItem.stat.view)) { return true; } if (filterTitle(videoItem.title)) { @@ -57,6 +52,17 @@ class RecommendFilter { return false; } + static bool filterLikeRatio(like, view) { + if (view is int && + view > -1 && + like is int && + like > -1 && + like * 100 < minLikeRatioForRecommend * view) { + return true; + } + return false; + } + static bool filterTitle(String title, {bool? isFollowed}) { if (exemptFilterForFollowed && isFollowed == true) { return false;