From 730c58ccae8edbba08acf406f5f6ef43beffd5dc Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Tue, 11 Jun 2024 03:14:25 +0900 Subject: [PATCH] feat(YouTube/Hide feed components): separate the `Hide low views video` settings from `Hide recommended videos` settings --- .../patches/components/FeedVideoFilter.java | 16 +++++++++++----- .../integrations/youtube/settings/Settings.java | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/FeedVideoFilter.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/FeedVideoFilter.java index 8d2a8730d5..fed289d9b3 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/FeedVideoFilter.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/FeedVideoFilter.java @@ -16,11 +16,14 @@ public final class FeedVideoFilter extends Filter { null, "endorsement_header_footer" // videos with gray descriptions ); - private final ByteArrayFilterGroup homeFeedRecommendations = new ByteArrayFilterGroup( - null, - "g-highZ", // videos with less than 1000 views + private final ByteArrayFilterGroup videosForMembershipOnly = new ByteArrayFilterGroup( + Settings.HIDE_RECOMMENDED_VIDEO, "high-ptsZ" // videos for membership only ); + private final ByteArrayFilterGroup videosWithLowView = new ByteArrayFilterGroup( + Settings.HIDE_LOW_VIEWS_VIDEO, + "g-highZ" // videos with less than 1000 views + ); // In search results, vertical video with shorts labels mostly include videos with gray descriptions. // Filters without check process. private final StringFilterGroup inlineShorts; @@ -30,7 +33,7 @@ public final class FeedVideoFilter extends Filter { public FeedVideoFilter() { homeFeedVideoFilter = new StringFilterGroup( - Settings.HIDE_RECOMMENDED_VIDEO, + null, "home_video_with_context.eml" ); feedVideo = new StringFilterGroup( @@ -62,7 +65,10 @@ public boolean isFiltered(String path, @Nullable String identifier, String allVa return false; } if (matchedGroup == homeFeedVideoFilter) { - if (contentIndex != 0 || !homeFeedRecommendations.check(protobufBufferArray).isFiltered()) { + if (contentIndex != 0) { + return false; + } + if (!videosForMembershipOnly.check(protobufBufferArray).isFiltered() && !videosWithLowView.check(protobufBufferArray).isFiltered()) { return false; } } diff --git a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java index baed678799..62ee0beb57 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java @@ -107,6 +107,7 @@ public class Settings extends BaseSettings { parentsAny(HIDE_KEYWORD_CONTENT_HOME, HIDE_KEYWORD_CONTENT_SEARCH, HIDE_KEYWORD_CONTENT_SUBSCRIPTIONS, HIDE_KEYWORD_CONTENT_COMMENTS)); public static final BooleanSetting HIDE_RECOMMENDED_VIDEO = new BooleanSetting("revanced_hide_recommended_video", FALSE); + public static final BooleanSetting HIDE_LOW_VIEWS_VIDEO = new BooleanSetting("revanced_hide_low_views_video", TRUE); public static final BooleanSetting HIDE_VIDEO_BY_DURATION = new BooleanSetting("revanced_hide_video_by_duration", FALSE); public static final StringSetting HIDE_VIDEO_BY_DURATION_SHORTER_THAN = new StringSetting("revanced_hide_video_by_duration_shorter_than", "0:10", parent(HIDE_VIDEO_BY_DURATION));