Skip to content

feat(Spotify): Add Change lyrics provider patch #4937

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

Open
wants to merge 42 commits into
base: dev
Choose a base branch
from

Conversation

Brosssh
Copy link
Member

@Brosssh Brosssh commented May 10, 2025

The user will enter an URL. This URL will be used when fetching lyrics.
The implemented logic is the same as https://github.com/Natoune/SpotifyMobileLyricsAPI/blob/main/scripts/xmanager.patch.js.

Closes #4906

@LisoUseInAIKyrios LisoUseInAIKyrios linked an issue May 10, 2025 that may be closed by this pull request
3 tasks
Copy link
Member

@oSumAtrIX oSumAtrIX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon skimming the patch I am not sure whats going on in a fair amount of time. The complexity needs to be addressed. Organize the code into blocks of related code and add // region comments and comments explaining the strategy, magic constants etc

@Brosssh Brosssh marked this pull request as draft May 11, 2025 14:15
@Brosssh
Copy link
Member Author

Brosssh commented May 12, 2025

After more tests, I noticed that 2 changes were not needed for the patch to work, so they have been removed. I have added comments both in the fingerprint file and in the execute file, explaining what is being done. Most of the comments above have been resolved, I've left open the one that to me are still to clarify.

@Brosssh Brosssh marked this pull request as ready for review May 12, 2025 07:04
Brosssh added 2 commits May 12, 2025 10:36
Added default value (lyrics.natanchiodi.fr)
Added domain resolver check
@Brosssh Brosssh requested a review from LisoUseInAIKyrios May 12, 2025 08:55
@Brosssh Brosssh requested a review from oSumAtrIX May 14, 2025 19:59
@Brosssh
Copy link
Member Author

Brosssh commented May 16, 2025

Should this has use = false btw? It shouldn't be on as default.

@drobotk
Copy link
Contributor

drobotk commented May 25, 2025

Fails on 46.496

SEVERE: "Change lyrics provider" failed:
app.revanced.patcher.patch.PatchException: Failed to match the fingerprint: app.revanced.patcher.Fingerprint@5a6af2c4
        at app.revanced.patcher.Fingerprint.getException(Fingerprint.kt:254)
        at app.revanced.patcher.Fingerprint.getMatch(Fingerprint.kt:263)
        at app.revanced.patcher.Fingerprint.getStringMatches(Fingerprint.kt:410)
        at app.revanced.patches.spotify.misc.lyrics.ChangeLyricsProviderPatchKt.changeLyricsProviderPatch$lambda$10$lambda$9(ChangeLyricsProviderPatch.kt:73)
        at app.revanced.patcher.patch.Patch.execute(Patch.kt:71)

@Brosssh Brosssh marked this pull request as draft May 28, 2025 16:02
@Brosssh Brosssh marked this pull request as ready for review May 28, 2025 19:13
@Brosssh Brosssh requested a review from LisoUseInAIKyrios May 28, 2025 19:13
@LisoUseInAIKyrios
Copy link
Contributor

@oSumAtrIX you want to re-review or is this ready to merge?

parameters()
custom { method, _ ->
method.indexOfFirstInstruction {
getReference<MethodReference>() == httpClientBuilderFingerprint.originalMethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeatedly calls the getter of originalMethod property, should set the return value to a variable

Comment on lines +86 to +96

MutableMethod(method).apply {
name = "patch_getCustomLyricsProviderHttpClient"
classDef.methods.add(this)
}.also {
method.addInstruction(
urlBuilderIndex - 1,
"const-string v$urlRegister, \"$lyricsProviderHost\""
)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MutableMethod(method).apply {
name = "patch_getCustomLyricsProviderHttpClient"
classDef.methods.add(this)
}.also {
method.addInstruction(
urlBuilderIndex - 1,
"const-string v$urlRegister, \"$lyricsProviderHost\""
)
}
}
MutableMethod(method).apply {
name = "patch_getCustomLyricsProviderHttpClient"
addInstruction(
urlBuilderIndex - 1,
"const-string v$urlRegister, \"$lyricsProviderHost\""
)
}.apply(classDef.methods::add)
}

classDef.methods.add(this)
}.also {
method.addInstruction(
urlBuilderIndex - 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still add the instruction to the original method because the implementation is copied by reference when you call MutableMethod()

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.

feat(Spotify): Allow using custom api as a lyrics provider
5 participants