feat(YouTube): Support version 19.12, 19.13, 19.14, 19.15 and 19.16 (#643)

This commit is contained in:
LisoUseInAIKyrios 2024-06-01 22:02:48 +04:00
parent a7e9390479
commit 4dce73a6fb
3 changed files with 39 additions and 30 deletions

View File

@ -4,7 +4,13 @@ import app.revanced.integrations.youtube.settings.Settings;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class HideAutoplayButtonPatch { public class HideAutoplayButtonPatch {
public static boolean isButtonShown() {
return !Settings.HIDE_AUTOPLAY_BUTTON.get(); private static final Boolean HIDE_AUTOPLAY_BUTTON_ENABLED = Settings.HIDE_AUTOPLAY_BUTTON.get();
/**
* Injection point.
*/
public static boolean hideAutoPlayButton() {
return HIDE_AUTOPLAY_BUTTON_ENABLED;
} }
} }

View File

@ -21,17 +21,20 @@ public final class LayoutComponentsFilter extends Filter {
private static final String VIDEO_ACTION_BAR_PATH_PREFIX = "video_action_bar.eml"; private static final String VIDEO_ACTION_BAR_PATH_PREFIX = "video_action_bar.eml";
private static final String ANIMATED_VECTOR_TYPE_PATH = "AnimatedVectorType"; private static final String ANIMATED_VECTOR_TYPE_PATH = "AnimatedVectorType";
private final StringTrieSearch exceptions = new StringTrieSearch(); private static final StringTrieSearch mixPlaylistsExceptions = new StringTrieSearch(
private static final StringTrieSearch mixPlaylistsExceptions = new StringTrieSearch(); "V.ED", // Playlist browse id.
"java.lang.ref.WeakReference"
);
private static final ByteArrayFilterGroup mixPlaylistsExceptions2 = new ByteArrayFilterGroup( private static final ByteArrayFilterGroup mixPlaylistsExceptions2 = new ByteArrayFilterGroup(
null, null,
"cell_description_body" "cell_description_body"
); );
private static final ByteArrayFilterGroup mixPlaylists = new ByteArrayFilterGroup( private static final ByteArrayFilterGroup mixPlaylists = new ByteArrayFilterGroup(
Settings.HIDE_MIX_PLAYLISTS, Settings.HIDE_MIX_PLAYLISTS,
"&list=" "&list="
); );
private final StringTrieSearch exceptions = new StringTrieSearch();
private final StringFilterGroup searchResultShelfHeader; private final StringFilterGroup searchResultShelfHeader;
private final StringFilterGroup inFeedSurvey; private final StringFilterGroup inFeedSurvey;
private final StringFilterGroup notifyMe; private final StringFilterGroup notifyMe;
@ -44,13 +47,6 @@ public final class LayoutComponentsFilter extends Filter {
private final StringFilterGroup likeSubscribeGlow; private final StringFilterGroup likeSubscribeGlow;
private final StringFilterGroup horizontalShelves; private final StringFilterGroup horizontalShelves;
static {
mixPlaylistsExceptions.addPatterns(
"V.ED", // Playlist browse id.
"java.lang.ref.WeakReference"
);
}
@RequiresApi(api = Build.VERSION_CODES.N) @RequiresApi(api = Build.VERSION_CODES.N)
public LayoutComponentsFilter() { public LayoutComponentsFilter() {
exceptions.addPatterns( exceptions.addPatterns(
@ -353,24 +349,31 @@ public final class LayoutComponentsFilter extends Filter {
* Called from a different place then the other filters. * Called from a different place then the other filters.
*/ */
public static boolean filterMixPlaylists(final Object conversionContext, @Nullable final byte[] bytes) { public static boolean filterMixPlaylists(final Object conversionContext, @Nullable final byte[] bytes) {
if (bytes == null) { try {
Logger.printDebug(() -> "bytes is null"); if (bytes == null) {
return false; Logger.printDebug(() -> "bytes is null");
return false;
}
// Prevent playlist items being hidden, if a mix playlist is present in it.
if (mixPlaylistsExceptions.matches(conversionContext.toString())) {
return false;
}
// Prevent hiding the description of some videos accidentally.
if (mixPlaylistsExceptions2.check(bytes).isFiltered()) {
return false;
}
if (mixPlaylists.check(bytes).isFiltered()) {
Logger.printDebug(() -> "Filtered mix playlist");
return true;
}
} catch (Exception ex) {
Logger.printException(() -> "filterMixPlaylists failure", ex);
} }
// Prevent playlist items being hidden, if a mix playlist is present in it. return false;
if (mixPlaylistsExceptions.matches(conversionContext.toString()))
return false;
if (!mixPlaylists.check(bytes).isFiltered())
return false;
// Prevent hiding the description of some videos accidentally.
if (mixPlaylistsExceptions2.check(bytes).isFiltered())
return false;
Logger.printDebug(() -> "Filtered mix playlist");
return true;
} }
/** /**

View File

@ -70,8 +70,8 @@ public final class RestoreOldVideoQualityMenuPatch {
* *
* Used to force the creation of the advanced menu item for the Shorts quality flyout. * Used to force the creation of the advanced menu item for the Shorts quality flyout.
*/ */
public static boolean forceAdvancedVideoQualityMenuCreation() { public static boolean forceAdvancedVideoQualityMenuCreation(boolean original) {
return Settings.RESTORE_OLD_VIDEO_QUALITY_MENU.get(); return Settings.RESTORE_OLD_VIDEO_QUALITY_MENU.get() || original;
} }
/** /**