mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 13:17:38 +02:00
fix(Spotify - Unlock Premium): Override additional attributes (#4651)
Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
This commit is contained in:
@ -1,3 +1,16 @@
|
||||
dependencies {
|
||||
compileOnly(project(":extensions:shared:library"))
|
||||
compileOnly(project(":extensions:spotify:stub"))
|
||||
compileOnly(libs.annotation)
|
||||
}
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
minSdk = 24
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
@ -2,38 +2,57 @@ package app.revanced.extension.spotify.misc;
|
||||
|
||||
import com.spotify.remoteconfig.internal.AccountAttribute;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
|
||||
/**
|
||||
* @noinspection unused
|
||||
*/
|
||||
public final class UnlockPremiumPatch {
|
||||
private static final Map<String, Object> OVERRIDES = Map.of(
|
||||
// Disables player and app ads.
|
||||
"ads", false,
|
||||
// Works along on-demand, allows playing any song without restriction.
|
||||
"player-license", "premium",
|
||||
// Disables shuffle being initially enabled when first playing a playlist.
|
||||
"shuffle", false,
|
||||
// Allows playing any song on-demand, without a shuffled order.
|
||||
"on-demand", true,
|
||||
// Make sure playing songs is not disabled remotely and playlists show up.
|
||||
"streaming", true,
|
||||
// Allows adding songs to queue and removes the smart shuffle mode restriction,
|
||||
// allowing to pick any of the other modes.
|
||||
"pick-and-shuffle", false,
|
||||
// Disables shuffle-mode streaming-rule, which forces songs to be played shuffled
|
||||
// and breaks the player when other patches are applied.
|
||||
"streaming-rules", "",
|
||||
// Enables premium UI in settings and removes the premium button in the nav-bar.
|
||||
"nft-disabled", "1"
|
||||
);
|
||||
|
||||
private static final Map<String, Object> OVERRIDES = new HashMap<>() {{
|
||||
// Disables player and app ads.
|
||||
put("ads", false);
|
||||
// Works along on-demand, allows playing any song without restriction.
|
||||
put("player-license", "premium");
|
||||
// Disables shuffle being initially enabled when first playing a playlist.
|
||||
put("shuffle", false);
|
||||
// Allows playing any song on-demand, without a shuffled order.
|
||||
put("on-demand", true);
|
||||
// Make sure playing songs is not disabled remotely and playlists show up.
|
||||
put("streaming", true);
|
||||
// Allows adding songs to queue and removes the smart shuffle mode restriction,
|
||||
// allowing to pick any of the other modes.
|
||||
put("pick-and-shuffle", false);
|
||||
// Disables shuffle-mode streaming-rule, which forces songs to be played shuffled
|
||||
// and breaks the player when other patches are applied.
|
||||
put("streaming-rules", "");
|
||||
// Enables premium UI in settings and removes the premium button in the nav-bar.
|
||||
put("nft-disabled", "1");
|
||||
// Enable Cross-Platform Spotify Car Thing.
|
||||
put("can_use_superbird", true);
|
||||
// Removes the premium button in the nav-bar for tablet users.
|
||||
put("tablet-free", false);
|
||||
}};
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static void overrideAttribute(Map<String, AccountAttribute> attributes) {
|
||||
for (var entry : OVERRIDES.entrySet()) {
|
||||
var attribute = Objects.requireNonNull(attributes.get(entry.getKey()));
|
||||
attribute.value_ = entry.getValue();
|
||||
try {
|
||||
for (var entry : OVERRIDES.entrySet()) {
|
||||
var key = entry.getKey();
|
||||
var attribute = attributes.get(key);
|
||||
if (attribute == null) {
|
||||
Logger.printException(() -> "Account attribute not found: " + key);
|
||||
} else {
|
||||
attribute.value_ = entry.getValue();
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "overrideAttribute failure", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user