Skip to content

Commit

Permalink
Merge branch 'dev' into revanced-extended
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Dec 21, 2024
2 parents 2b0f12c + 23a8941 commit 0384907
Show file tree
Hide file tree
Showing 255 changed files with 11,472 additions and 4,018 deletions.
27 changes: 9 additions & 18 deletions README-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,28 @@ Example:
{
"name": "Alternative thumbnails",
"description": "Adds options to replace video thumbnails using the DeArrow API or image captures from the video.",
"compatiblePackages":[
{
"name": "com.google.android.youtube",
"versions": "COMPATIBLE_PACKAGE_YOUTUBE"
}
],
"use":true,
"compatiblePackages": {
"com.google.android.youtube": "COMPATIBLE_PACKAGE_YOUTUBE"
},
"options": []
},
{
"name": "Bitrate default value",
"description": "Sets the audio quality to 'Always High' when you first install the app.",
"compatiblePackages": [
{
"name": "com.google.android.apps.youtube.music",
"versions": "COMPATIBLE_PACKAGE_MUSIC"
}
],
"use":true,
"compatiblePackages": {
"com.google.android.apps.youtube.music": "COMPATIBLE_PACKAGE_MUSIC"
},
"options": []
},
{
"name": "Hide ads",
"description": "Adds options to hide ads.",
"compatiblePackages": [
{
"name": "com.reddit.frontpage",
"versions": "COMPATIBLE_PACKAGE_REDDIT"
}
],
"use":true,
"compatiblePackages": {
"com.reddit.frontpage": "COMPATIBLE_PACKAGE_REDDIT"
},
"options": []
}
]
Expand Down
284 changes: 138 additions & 146 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import androidx.annotation.NonNull;

import app.revanced.extension.music.settings.Settings;
import app.revanced.extension.music.utils.VideoUtils;

@SuppressWarnings("unused")
public class ActionBarPatch {
Expand Down Expand Up @@ -40,15 +39,6 @@ public static void hideLikeDislikeButton(View view) {
);
}

public static void inAppDownloadButtonOnClick(View view) {
if (!Settings.EXTERNAL_DOWNLOADER_ACTION_BUTTON.get()) {
return;
}

if (buttonType.equals(ActionButton.DOWNLOAD.name))
view.setOnClickListener(imageView -> VideoUtils.launchExternalDownloader());
}

public static void setButtonType(@NonNull Object obj) {
final String buttonType = obj.toString();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package app.revanced.extension.music.patches.components;

import androidx.annotation.Nullable;

import app.revanced.extension.music.settings.Settings;
import app.revanced.extension.shared.patches.components.ByteArrayFilterGroup;
import app.revanced.extension.shared.patches.components.ByteArrayFilterGroupList;
import app.revanced.extension.shared.patches.components.Filter;
import app.revanced.extension.shared.patches.components.StringFilterGroup;

@SuppressWarnings("unused")
public final class ActionButtonsFilter extends Filter {
private static final String VIDEO_ACTION_BAR_PATH_PREFIX = "video_action_bar.eml";

private final StringFilterGroup actionBarRule;
private final StringFilterGroup bufferFilterPathRule;
private final ByteArrayFilterGroupList bufferButtonsGroupList = new ByteArrayFilterGroupList();

public ActionButtonsFilter() {
actionBarRule = new StringFilterGroup(
null,
VIDEO_ACTION_BAR_PATH_PREFIX
);
addIdentifierCallbacks(actionBarRule);

bufferFilterPathRule = new StringFilterGroup(
null,
"|ContainerType|button.eml|"
);
final StringFilterGroup downloadButton = new StringFilterGroup(
Settings.HIDE_ACTION_BUTTON_DOWNLOAD,
"music_download_button.eml"
);
final StringFilterGroup likeDislikeContainer = new StringFilterGroup(
Settings.HIDE_ACTION_BUTTON_LIKE_DISLIKE,
"segmented_like_dislike_button.eml"
);
addPathCallbacks(
bufferFilterPathRule,
downloadButton,
likeDislikeContainer
);

bufferButtonsGroupList.addAll(
new ByteArrayFilterGroup(
Settings.HIDE_ACTION_BUTTON_COMMENT,
"yt_outline_message_bubble"
),
new ByteArrayFilterGroup(
Settings.HIDE_ACTION_BUTTON_ADD_TO_PLAYLIST,
"yt_outline_list_add"
),
new ByteArrayFilterGroup(
Settings.HIDE_ACTION_BUTTON_SHARE,
"yt_outline_share"
),
new ByteArrayFilterGroup(
Settings.HIDE_ACTION_BUTTON_RADIO,
"yt_outline_youtube_mix"
)
);
}

private boolean isEveryFilterGroupEnabled() {
for (StringFilterGroup group : pathCallbacks)
if (!group.isEnabled()) return false;

for (ByteArrayFilterGroup group : bufferButtonsGroupList)
if (!group.isEnabled()) return false;

return true;
}

@Override
public boolean isFiltered(String path, @Nullable String identifier, String allValue, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (!path.startsWith(VIDEO_ACTION_BAR_PATH_PREFIX)) {
return false;
}
if (matchedGroup == actionBarRule && !isEveryFilterGroupEnabled()) {
return false;
}
if (matchedGroup == bufferFilterPathRule && !bufferButtonsGroupList.check(protobufBufferArray).isFiltered()) {
return false;
}

return super.isFiltered(path, identifier, allValue, protobufBufferArray, matchedGroup, contentType, contentIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,16 @@ private enum FlyoutPanelComponent {
ADD_TO_QUEUE("QUEUE_MUSIC", Settings.HIDE_FLYOUT_MENU_ADD_TO_QUEUE.get()),
SAVE_TO_LIBRARY("LIBRARY_ADD", Settings.HIDE_FLYOUT_MENU_SAVE_TO_LIBRARY.get()),
REMOVE_FROM_LIBRARY("LIBRARY_REMOVE", Settings.HIDE_FLYOUT_MENU_REMOVE_FROM_LIBRARY.get()),
SAVE_TO_PLAYLIST("ADD_TO_PLAYLIST", Settings.HIDE_FLYOUT_MENU_SAVE_TO_PLAYLIST.get()),
REMOVE_FROM_PLAYLIST("REMOVE_FROM_PLAYLIST", Settings.HIDE_FLYOUT_MENU_REMOVE_FROM_PLAYLIST.get()),
DOWNLOAD("OFFLINE_DOWNLOAD", Settings.HIDE_FLYOUT_MENU_DOWNLOAD.get()),
SAVE_TO_PLAYLIST("ADD_TO_PLAYLIST", Settings.HIDE_FLYOUT_MENU_SAVE_TO_PLAYLIST.get()),
GO_TO_EPISODE("INFO", Settings.HIDE_FLYOUT_MENU_GO_TO_EPISODE.get()),
GO_TO_PODCAST("BROADCAST", Settings.HIDE_FLYOUT_MENU_GO_TO_PODCAST.get()),
GO_TO_ALBUM("ALBUM", Settings.HIDE_FLYOUT_MENU_GO_TO_ALBUM.get()),
GO_TO_ARTIST("ARTIST", Settings.HIDE_FLYOUT_MENU_GO_TO_ARTIST.get()),
VIEW_SONG_CREDIT("PEOPLE_GROUP", Settings.HIDE_FLYOUT_MENU_VIEW_SONG_CREDIT.get()),
PIN_TO_SPEED_DIAL("KEEP", Settings.HIDE_FLYOUT_MENU_PIN_TO_SPEED_DIAL.get()),
UNPIN_FROM_SPEED_DIAL("KEEP_OFF", Settings.HIDE_FLYOUT_MENU_UNPIN_FROM_SPEED_DIAL.get()),
SHARE("SHARE", Settings.HIDE_FLYOUT_MENU_SHARE.get()),
DISMISS_QUEUE("DISMISS_QUEUE", Settings.HIDE_FLYOUT_MENU_DISMISS_QUEUE.get()),
HELP("HELP_OUTLINE", Settings.HIDE_FLYOUT_MENU_HELP.get()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package app.revanced.extension.music.patches.misc;

import app.revanced.extension.music.settings.Settings;

@SuppressWarnings("unused")
public class DrcAudioPatch {

public static float disableDrcAudio(float original) {
if (!Settings.DISABLE_DRC_AUDIO.get()) {
return original;
}
return 0f;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import app.revanced.extension.music.patches.misc.client.AppClient.ClientType;
import app.revanced.extension.music.settings.Settings;
import app.revanced.extension.shared.patches.BlockRequestPatch;

@SuppressWarnings("unused")
public class SpoofClientPatch {
private static final boolean SPOOF_CLIENT_ENABLED = Settings.SPOOF_CLIENT.get();
private static final ClientType clientType = ClientType.IOS_MUSIC;
public class SpoofClientPatch extends BlockRequestPatch {
private static final ClientType CLIENT_TYPE = Settings.SPOOF_CLIENT_TYPE.get();

/**
* Injection point.
*/
public static int getClientTypeId(int originalClientTypeId) {
if (SPOOF_CLIENT_ENABLED) {
return clientType.id;
if (SPOOF_CLIENT) {
return CLIENT_TYPE.id;
}

return originalClientTypeId;
Expand All @@ -23,8 +23,8 @@ public static int getClientTypeId(int originalClientTypeId) {
* Injection point.
*/
public static String getClientVersion(String originalClientVersion) {
if (SPOOF_CLIENT_ENABLED) {
return clientType.clientVersion;
if (SPOOF_CLIENT) {
return CLIENT_TYPE.clientVersion;
}

return originalClientVersion;
Expand All @@ -34,8 +34,8 @@ public static String getClientVersion(String originalClientVersion) {
* Injection point.
*/
public static String getClientModel(String originalClientModel) {
if (SPOOF_CLIENT_ENABLED) {
return clientType.deviceModel;
if (SPOOF_CLIENT) {
return CLIENT_TYPE.deviceModel;
}

return originalClientModel;
Expand All @@ -45,8 +45,8 @@ public static String getClientModel(String originalClientModel) {
* Injection point.
*/
public static String getOsVersion(String originalOsVersion) {
if (SPOOF_CLIENT_ENABLED) {
return clientType.osVersion;
if (SPOOF_CLIENT) {
return CLIENT_TYPE.osVersion;
}

return originalOsVersion;
Expand All @@ -56,8 +56,8 @@ public static String getOsVersion(String originalOsVersion) {
* Injection point.
*/
public static String getUserAgent(String originalUserAgent) {
if (SPOOF_CLIENT_ENABLED) {
return clientType.userAgent;
if (SPOOF_CLIENT) {
return CLIENT_TYPE.userAgent;
}

return originalUserAgent;
Expand All @@ -67,16 +67,19 @@ public static String getUserAgent(String originalUserAgent) {
* Injection point.
*/
public static boolean isClientSpoofingEnabled() {
return SPOOF_CLIENT_ENABLED;
return SPOOF_CLIENT;
}

/**
* Injection point.
* <p>
* When spoofing the client to iOS, the playback speed menu is missing from the player response.
* This fix is required because playback speed is not available in YouTube Music Podcasts.
* <p>
* Return true to force create the playback speed menu.
*/
public static boolean forceCreatePlaybackSpeedMenu(boolean original) {
if (SPOOF_CLIENT_ENABLED) {
if (SPOOF_CLIENT) {
return true;
}
return original;
Expand Down
Loading

0 comments on commit 0384907

Please sign in to comment.