Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(YouTube - Hide layout components): Filter home/search results by keywords #2853

Merged

Conversation

LisoUseInAIKyrios
Copy link
Contributor

@LisoUseInAIKyrios LisoUseInAIKyrios commented Mar 8, 2024

Allows hiding videos from the feed/search based on keywords.

Keywords can be any text that appears in video titles, or the channel title of a YouTube creator.

This patch is not a replacement for hiding individual channels in the home feed, because that can already be done in YouTube (tap three dots on a video, then "Don't recommend channel"). This patch is to hide topics from the home feed and search, and to hide videos from specific channels from the search results.

Spacing and punctuation is important for keywords. If you want to hide Mr Beast from your search, then you need to add both Mr Beast (name used in video titles) and MrBeast (his channel name).

Screenshots

Search results unfiltered

Search results with keyword filters 'MrBeast' and 'Mr Beast'

Limitations

Shorts can still show up in the search results

If using a channel name as a keyword filter, then most Shorts from that channel will still show up in search results. This is because Shorts do not show the channel name, so the filter will not catch them.

Some UI layout residue will remain

Some extra UI components around a search result may not be hidden, such as the video chapter preview that appears below some search results.

Case sensitive keywords

Keywords are case sensitive, so if you use a filter of Mr Beast it will not filter any videos with titles that contain odd casing such as mr BEAst. This patch automatically includes common case variations, and entering Mr Beast automatically filters mr beast and MR BEAST. But if a keyword has unusual casing then you must enter the exact casing (ie: LeBlanc, TikTok).

Searching for a keyword phrase can show no search results

This is because the protobuffer for each search result includes your search text. So if you keyword filter Mr Beast and then search for Mr Beast, the patch will hide every search result. If you still want to search for a specific phrase you can get around this by searching for the same phrase but with odd casing -- ie: search for mr BEAst.

In a similar limitation, certain words cannot be used as filters and adding any of them will always hide all videos. These words includes google, youtube, video, android, avatar, and any other buffer text found in every video. This is because these words are used for layout components or are found in video data (such as googlevideo.com/initplayback used to start video playback). This patch checks for many of these restricted words, but it is not an exhaustive check and some keywords can still hide everything.

@LisoUseInAIKyrios
Copy link
Contributor Author

Closes
#1393
#1104

@LisoUseInAIKyrios
Copy link
Contributor Author

I initially thought performance might be an issue, but it appears performance is just fine.

Searching the protobuffer for each search result takes less than 1ms, which is too insignificant to make any difference.

@MarcaDian
Copy link
Contributor

MarcaDian commented Mar 8, 2024

Hello. Why i cant filter this channel from search?
I see that the channel avatar just disappeared in the search results, but not the video.
the filter only works by keywords, but I can't filter specifically by the channel link.

Screenshot_2024-03-08-13-23-08-945_app revanced android youtube
Screenshot_2024-03-08-13-23-39-615-edit_app revanced android youtube

@LisoUseInAIKyrios
Copy link
Contributor Author

LisoUseInAIKyrios commented Mar 8, 2024

Hello. Why i cant filter this channel from search?

Because you need to use the channel title name, and not the @ name.

channel title

@LisoUseInAIKyrios
Copy link
Contributor Author

Unicode is now supported in both keyword and custom filters.

I realized the byte array comparison is unaffected by unicode hurdles such as surrogate or combining characters. It's just a plain byte to byte comparison and it does not care or is affected by these issues.

@MarcaDian
Copy link
Contributor

MarcaDian commented Mar 8, 2024

can you add sorting = Sorting.UNSORTED, ? same issue like color seekbar

Edit: At first glance, everything works, in Unicode

@Leenkss
Copy link

Leenkss commented Mar 11, 2024

Hi, can you add buttons for automatic hide videos or channels name from searching ?
Pic from pc
���+��12���

@LisoUseInAIKyrios
Copy link
Contributor Author

can you add buttons for automatic hide videos or channels name from searching?

A flyout menu item to hide a chanel would be useful.

But as far as I know, adding layout items to litho has not yet been done by any patch. Someone would need to figure out how to add content to an existing layout and add a callback when the item is tapped.

@oSumAtrIX
Copy link
Member

It looks like, at least for short carousels, if a keyword is matched the entire carousel is blocked (example "beast"):
image
image

@LisoUseInAIKyrios
Copy link
Contributor Author

LisoUseInAIKyrios commented Mar 11, 2024

It looks like, at least for short carousels, if a keyword is matched the entire carousel is blocked

What is the full path for the carousel? Maybe the individual videos in the carousel can be filtered instead of the entire parent component.

Edit: the full path is shorts_shelf.eml|123|CellType|shorts_shelf_carousel.eml|123|CollectionType|shorts_lockup_cell.eml
and it it now filters out the individual Shorts from the carousel.

@LisoUseInAIKyrios
Copy link
Contributor Author

It looks like, at least for short carousels, if a keyword is matched the entire carousel is blocked (example "beast").

The carousel and Shorts shelf as a whole are not hidden if any of the enclosed Short are filtered. In that screenshot I think the entire group of Shorts was filtered away because every short had a title that matched a keyword.

The carousel Shorts path is the same for both search and the subscription feed, and this means it filters carousel Shorts in both search and the subscription tab (which may or may not be what the user wants).

I think the ideal fix is to add hooks to figure out what navigation tab is active, and then add setting switches to filter home/subscription/search items. The same hooks would also be useful for Alternatively thumbnails to do the same (apply only to home/subscriptions/search).

@oSumAtrIX
Copy link
Member

I think the entire group of Shorts was filtered away because every short had a title that matched a keyword.

To note, in the screenshot I added, the title of the first Short did not match the keyword, but likely the buffer string contained it. Nothing that can be done here though.

@LisoUseInAIKyrios LisoUseInAIKyrios force-pushed the filter_keyword_content branch 2 times, most recently from 0534cfc to f0a895d Compare March 21, 2024 12:16
@MarcaDian
Copy link
Contributor

MarcaDian commented Mar 24, 2024

After last commit. Also force pushed from filter_keyword_content branch to my, same error 🙃
Edit: this error maybe apear after 0de51bf

ReVanced Manager: 1.19.4-dev.2
Model: M2004J19C
Android version: 12
Supported architectures: arm64-v8a, armeabi-v7a, armeabi
Root permissions: No

- Patch Info
App: com.google.android.youtube v19.09.38 (Suggested: 19.08.36)
Patches version: test8
Patches added: Default
Patches removed: Announcements, Enable debugging
Default patch options changed: None

- Settings
Allow changing patch selection: true
Version compatibility check: false
Show universal patches: false
Patches source: MarcaDian/revanced-patches-old
Integration source: MarcaDian/revanced-integrations-old

- Logs
Reading APK
Decoding app manifest
Loading patches
Merging integrations
Deleting existing temporary files directory
Decoding resources
Executing patches
Applied 59 patches
Hide layout components failed: app.revanced.patcher.patch.PatchException: 'Hide layout components' depends on 'NavigationBarHookPatch' that raised an exception:
app.revanced.patcher.patch.PatchException: Failed to resolve NavigationBarHookCallbackFingerprint
	at app.revanced.util.BytecodeUtilsKt.getException(BytecodeUtils.kt:27)
	at app.revanced.util.BytecodeUtilsKt.resultOrThrow(BytecodeUtils.kt:19)
	at app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch.execute(NavigationBarHookPatch.kt:98)
	at app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch.execute(NavigationBarHookPatch.kt:25)
	at app.revanced.patcher.Patcher$apply$1.invokeSuspend$executePatch(Unknown Source:190)
	at app.revanced.patcher.Patcher$apply$1.invokeSuspend$executePatch(Unknown Source:91)
	at app.revanced.patcher.Patcher$apply$1.invokeSuspend(Unknown Source:292)
	at app.revanced.patcher.Patcher$apply$1.invoke(SourceFile:1)
	at app.revanced.patcher.Patcher$apply$1.invoke(SourceFile:2)
	at b6.f.b(Unknown Source:2)
	at b6.a.a(Unknown Source:71)
	at app.revanced.manager.flutter.MainActivity$runPatcher$1$patcherResult$1$2.invokeSuspend(Unknown Source:76)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:11)
	at y5.o0.run(Unknown Source:93)
	at y5.u0.P(Unknown Source:46)
	at y5.e.t0(Unknown Source:23)
	at y5.h.a(Unknown Source:73)
	at y5.g.c(Unknown Source:0)
	at y5.h.b(Unknown Source:6)
	at y5.g.d(Unknown Source:0)
	at app.revanced.manager.flutter.MainActivity.runPatcher$lambda$34(Unknown Source:470)
	at app.revanced.manager.flutter.MainActivity.k(Unknown Source:0)
	at app.revanced.manager.flutter.f.run(Unknown Source:20)
	at java.lang.Thread.run(Thread.java:920)

	at app.revanced.patcher.Patcher$apply$1.invokeSuspend$executePatch(Unknown Source:148)
	at app.revanced.patcher.Patcher$apply$1.invokeSuspend(Unknown Source:292)
	at app.revanced.patcher.Patcher$apply$1.invoke(SourceFile:1)
	at app.revanced.patcher.Patcher$apply$1.invoke(SourceFile:2)
	at b6.f.b(Unknown Source:2)
	at b6.a.a(Unknown Source:71)
	at app.revanced.manager.flutter.MainActivity$runPatcher$1$patcherResult$1$2.invokeSuspend(Unknown Source:76)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:11)
	at y5.o0.run(Unknown Source:93)
	at y5.u0.P(Unknown Source:46)
	at y5.e.t0(Unknown Source:23)
	at y5.h.a(Unknown Source:73)
	at y5.g.c(Unknown Source:0)
	at y5.h.b(Unknown Source:6)
	at y5.g.d(Unknown Source:0)
	at app.revanced.manager.flutter.MainActivity.runPatcher$lambda$34(Unknown Source:470)
	at app.revanced.manager.flutter.MainActivity.k(Unknown Source:0)
	at app.revanced.manager.flutter.f.run(Unknown Source:20)
	at java.lang.Thread.run(Thread.java:920)
Navigation buttons failed: app.revanced.patcher.patch.PatchException: 'Navigation buttons' depends on 'NavigationBarHookPatch' that raised an exception:
app.revanced.patcher.patch.PatchException: 'NavigationBarHookPatch' did not succeed previously
	at app.revanced.patcher.Patcher$apply$1.invokeSuspend$executePatch(Unknown Source:45)
	at app.revanced.patcher.Patcher$apply$1.invokeSuspend$executePatch(Unknown Source:91)
	at app.revanced.patcher.Patcher$apply$1.invokeSuspend(Unknown Source:292)
	at app.revanced.patcher.Patcher$apply$1.invoke(SourceFile:1)
	at app.revanced.patcher.Patcher$apply$1.invoke(SourceFile:2)
	at b6.f.b(Unknown Source:2)
	at b6.a.a(Unknown Source:71)
	at app.revanced.manager.flutter.MainActivity$runPatcher$1$patcherResult$1$2.invokeSuspend(Unknown Source:76)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:11)
	at y5.o0.run(Unknown Source:93)
	at y5.u0.P(Unknown Source:46)
	at y5.e.t0(Unknown Source:23)
	at y5.h.a(Unknown Source:73)
	at y5.g.c(Unknown Source:0)
	at y5.h.b(Unknown Source:6)
	at y5.g.d(Unknown Source:0)
	at app.revanced.manager.flutter.MainActivity.runPatcher$lambda$34(Unknown Source:470)
	at app.revanced.manager.flutter.MainActivity.k(Unknown Source:0)
	at app.revanced.manager.flutter.f.run(Unknown Source:20)
	at java.lang.Thread.run(Thread.java:920)

	at app.revanced.patcher.Patcher$apply$1.invokeSuspend$executePatch(Unknown Source:148)
	at app.revanced.patcher.Patcher$apply$1.invokeSuspend(Unknown Source:292)
	at app.revanced.patcher.Patcher$apply$1.invoke(SourceFile:1)
	at app.revanced.patcher.Patcher$apply$1.invoke(SourceFile:2)
	at b6.f.b(Unknown Source:2)
	at b6.a.a(Unknown Source:71)
	at app.revanced.manager.flutter.MainActivity$runPatcher$1$patcherResult$1$2.invokeSuspend(Unknown Source:76)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:11)
	at y5.o0.run(Unknown Source:93)
	at y5.u0.P(Unknown Source:46)
	at y5.e.t0(Unknown Source:23)
	at y5.h.a(Unknown Source:73)
	at y5.g.c(Unknown Source:0)
	at y5.h.b(Unknown Source:6)
	at y5.g.d(Unknown Source:0)
	at app.revanced.manager.flutter.MainActivity.runPatcher$lambda$34(Unknown Source:470)
	at app.revanced.manager.flutter.MainActivity.k(Unknown Source:0)
	at app.revanced.manager.flutter.f.run(Unknown Source:20)
	at java.lang.Thread.run(Thread.java:920)
Compiling patched dex files
Compiled 8 dex files
Compiling modified resources
Aligning APK
Signing APK
Patched APK

@oSumAtrIX
Copy link
Member

Nothing that can cause your exception has been changed

@LisoUseInAIKyrios
Copy link
Contributor Author

After last commit. Also force pushed from filter_keyword_content branch to my, same error

It is patching correctly for me. The failing fingerprint is for an Integrations method.

Verify you are building with the integrations branch for this PR.

@oSumAtrIX oSumAtrIX self-requested a review March 26, 2024 03:55
@LisoUseInAIKyrios LisoUseInAIKyrios merged commit 5916204 into ReVanced:dev Mar 27, 2024
2 checks passed
@LisoUseInAIKyrios LisoUseInAIKyrios deleted the filter_keyword_content branch March 27, 2024 07:27
revanced-bot pushed a commit that referenced this pull request Mar 27, 2024
# [4.4.0-dev.14](v4.4.0-dev.13...v4.4.0-dev.14) (2024-03-27)

### Features

* **YouTube - Hide layout components:** Filter home/search results by keywords ([#2853](#2853)) ([5916204](5916204))
@MarcaDian

This comment was marked as resolved.

@LisoUseInAIKyrios

This comment was marked as resolved.

revanced-bot pushed a commit that referenced this pull request Mar 27, 2024
# [4.4.0](v4.3.0...v4.4.0) (2024-03-27)

### Bug Fixes

* **TikTok:** Hook application context earlier to prevent crash ([#2893](#2893)) ([395ccda](395ccda))
* **YouTube - Client spoof:** Spoof all user agents ([44a8a13](44a8a13))
* **YouTube - Downloads:** Use new task context ([#2841](#2841)) ([6d88cb4](6d88cb4))
* **YouTube - Hide ads:** Prevent app crash if hiding fullscreen ads is not possible ([#2910](#2910)) ([9f50470](9f50470))
* **YouTube Music:** Fix compatibility with latest versions ([#2924](#2924)) ([8378c84](8378c84))
* **YouTube:** Fix video playback by switching to ReVanced GmsCore vendor ([#2907](#2907)) ([33ea122](33ea122))
* **YouTube:** Move setting to correct screen ([a16eda8](a16eda8))

### Features

* **Instagram - Hide timeline ads:** Make compatible with latest versions ([a212f29](a212f29))
* **Mi Fitness:** Add `Force English locale` and `Fix login` patch ([#2734](#2734)) ([7a25791](7a25791))
* **Sync for Lemmy:** Add `Disable ads` patch ([#2872](#2872)) ([0785819](0785819))
* **YouTube - Downloads:** Use external downloader when selecting 'Download' in home feed flyout menu ([#2881](#2881)) ([10afc8c](10afc8c))
* **YouTube - External downloader:** Add ability to use in-app download button ([d900011](d900011))
* **YouTube - Hide layout components:** Filter home/search results by keywords ([#2853](#2853)) ([5916204](5916204))
* **YouTube - Hide Shorts components:** Hide like and dislike buttons ([2df0892](2df0892))
* **YouTube - Hide Shorts components:** Hide sound metadata label ([ea7d1e0](ea7d1e0))
* **YouTube - Hide Shorts components:** Hide title and full video link label ([e7b64e1](e7b64e1))
* **YouTube - Hide Shorts components:** Selectively hide Shorts for home / subscription / search ([#2925](#2925)) ([497c067](497c067))
* **YouTube :** Remove `HDR auto brightness` patch ([#2863](#2863)) ([b4c7bf4](b4c7bf4))
* **YouTube Vanced:** Remove `Hide ads` patch ([87887e4](87887e4))
* **YouTube:** Support version `19.05`, `19.06`, `19.07`, `19.08` and `19.09` ([#2862](#2862)) ([f044dde](f044dde))
E85Addict pushed a commit to E85Addict/revanced-patches that referenced this pull request Mar 27, 2024
# [4.4.0](v4.3.0...v4.4.0) (2024-03-27)

### Bug Fixes

* **TikTok:** Hook application context earlier to prevent crash ([ReVanced#2893](https://github.com/E85Addict/revanced-patches/issues/2893)) ([395ccda](395ccda))
* **YouTube - Client spoof:** Spoof all user agents ([44a8a13](44a8a13))
* **YouTube - Downloads:** Use new task context ([ReVanced#2841](https://github.com/E85Addict/revanced-patches/issues/2841)) ([6d88cb4](6d88cb4))
* **YouTube - Hide ads:** Prevent app crash if hiding fullscreen ads is not possible ([ReVanced#2910](https://github.com/E85Addict/revanced-patches/issues/2910)) ([9f50470](9f50470))
* **YouTube Music:** Fix compatibility with latest versions ([ReVanced#2924](https://github.com/E85Addict/revanced-patches/issues/2924)) ([8378c84](8378c84))
* **YouTube:** Fix video playback by switching to ReVanced GmsCore vendor ([ReVanced#2907](https://github.com/E85Addict/revanced-patches/issues/2907)) ([33ea122](33ea122))
* **YouTube:** Move setting to correct screen ([a16eda8](a16eda8))

### Features

* **Instagram - Hide timeline ads:** Make compatible with latest versions ([a212f29](a212f29))
* **Mi Fitness:** Add `Force English locale` and `Fix login` patch ([ReVanced#2734](https://github.com/E85Addict/revanced-patches/issues/2734)) ([7a25791](7a25791))
* **Sync for Lemmy:** Add `Disable ads` patch ([ReVanced#2872](https://github.com/E85Addict/revanced-patches/issues/2872)) ([0785819](0785819))
* **YouTube - Downloads:** Use external downloader when selecting 'Download' in home feed flyout menu ([ReVanced#2881](https://github.com/E85Addict/revanced-patches/issues/2881)) ([10afc8c](10afc8c))
* **YouTube - External downloader:** Add ability to use in-app download button ([d900011](d900011))
* **YouTube - Hide layout components:** Filter home/search results by keywords ([ReVanced#2853](https://github.com/E85Addict/revanced-patches/issues/2853)) ([5916204](5916204))
* **YouTube - Hide Shorts components:** Hide like and dislike buttons ([2df0892](2df0892))
* **YouTube - Hide Shorts components:** Hide sound metadata label ([ea7d1e0](ea7d1e0))
* **YouTube - Hide Shorts components:** Hide title and full video link label ([e7b64e1](e7b64e1))
* **YouTube - Hide Shorts components:** Selectively hide Shorts for home / subscription / search ([ReVanced#2925](https://github.com/E85Addict/revanced-patches/issues/2925)) ([497c067](497c067))
* **YouTube :** Remove `HDR auto brightness` patch ([ReVanced#2863](https://github.com/E85Addict/revanced-patches/issues/2863)) ([b4c7bf4](b4c7bf4))
* **YouTube Vanced:** Remove `Hide ads` patch ([87887e4](87887e4))
* **YouTube:** Support version `19.05`, `19.06`, `19.07`, `19.08` and `19.09` ([ReVanced#2862](https://github.com/E85Addict/revanced-patches/issues/2862)) ([f044dde](f044dde))

### Performance Improvements

* Personal Logo && Add upstream sync ([5022724](5022724))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants