@@ -58,10 +58,9 @@ static ClienttokenHttp.ClientTokenRequest buildSpoofedClientTokenRequest(String
58
58
59
59
@ Nullable
60
60
static ClienttokenHttp .ClientTokenResponse fetchClientToken (
61
- @ NonNull String androidUserAgent ,
62
61
@ NonNull ClienttokenHttp .ClientTokenRequest originalClientTokenRequest
63
62
) throws IOException {
64
- String iosUserAgent = getIOSUserAgent (androidUserAgent );
63
+ String iosUserAgent = getIOSUserAgent ();
65
64
if (iosUserAgent == null ) {
66
65
return null ;
67
66
}
@@ -102,17 +101,17 @@ static HttpURLConnection createProtobufRequestConnection(String url) throws IOEx
102
101
}
103
102
104
103
@ Nullable
105
- static String getIOSUserAgent (@ NonNull String androidUserAgent ) {
106
- Pattern iosSpotifyVersionPattern = Pattern .compile ("Spotify/ (\\ d+\\ .\\ d+\\ .\\ d+)\\ .\\ d+" );
107
- Matcher androidSpotifyVersionMatcher = iosSpotifyVersionPattern .matcher (androidUserAgent );
104
+ static String getIOSUserAgent () {
105
+ Pattern iosSpotifyVersionPattern = Pattern .compile ("iphone- (\\ d+\\ .\\ d+\\ .\\ d+)\\ .\\ d+" );
106
+ Matcher iosSpotifyVersionMatcher = iosSpotifyVersionPattern .matcher (getClientVersion () );
108
107
109
- if (!androidSpotifyVersionMatcher .find ()) {
110
- Logger .printException (() -> "Failed to match iOS Spotify version from original android User-Agent. " +
111
- "Original User-Agent: " + androidUserAgent );
108
+ if (!iosSpotifyVersionMatcher .find ()) {
109
+ Logger .printException (() -> "Failed to match iOS Spotify version from the client version " +
110
+ getClientVersion () );
112
111
return null ;
113
112
}
114
113
115
- String iosSpotifyVersion = androidSpotifyVersionMatcher .group (1 );
114
+ String iosSpotifyVersion = iosSpotifyVersionMatcher .group (1 );
116
115
return "Spotify/" + iosSpotifyVersion + " iOS/" +
117
116
getSystemVersion () + " (" +
118
117
getHardwareMachine () + ")" ;
0 commit comments