librespot-org / librespot-java

The most up-to-date open source Spotify client
Apache License 2.0
375 stars 91 forks source link

ApiClient$StatusCodeException: 400 when use getMetadata4Album #835

Closed thedtvn closed 6 months ago

thedtvn commented 7 months ago

Describe the bug bug appear when get Track meta

To Reproduce session.api().getMetadata4Track(TrackId.fromUri("Track id to here"))

Expected behavior work without err

Screenshots/Stracktraces/Logs

xyz.gianlu.librespot.dealer.ApiClient$StatusCodeException: 400: 
    at xyz.gianlu.librespot.dealer.ApiClient$StatusCodeException.checkStatus(ApiClient.java:366)
    at xyz.gianlu.librespot.dealer.ApiClient$StatusCodeException.access$000(ApiClient.java:357)
    at xyz.gianlu.librespot.dealer.ApiClient.clientToken(ApiClient.java:345)
    at xyz.gianlu.librespot.dealer.ApiClient.buildRequest(ApiClient.java:79)
    at xyz.gianlu.librespot.dealer.ApiClient.send(ApiClient.java:114)
    at xyz.gianlu.librespot.dealer.ApiClient.send(ApiClient.java:131)
    at xyz.gianlu.librespot.dealer.ApiClient.getMetadata4Album(ApiClient.java:168)
    at org.librespotapis.Main.loadmeta(Main.java:265)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Version/Commit xyz.gianlu.librespot:librespot-lib:1.6.3

ShaikaJar commented 7 months ago

I also encountered this. Did Spotify change the api?

Lustyn commented 6 months ago

Likely cause: Your classpath is incorrect.

Version.java returns "versionString" as the current version of librespot-java, and if the package does not find a version it will populate ?.?.? which I'm guessing Spotify recently added validation against. I don't fully understand what is happening here.

To fix it, you should try switching your dependency from librespot-lib -> librespot-player. For me this made the version number populate correctly and the library began functioning again. You may also run into issues depending on how your Java build is packaged and ran. To validate that you don't encounter the issue, check Version.versionString() at runtime to see if it is set correctly.

devgianlu commented 6 months ago

I can confirm what @Lustyn is saying, they recently added a check on the version string probably to parse it for their own stuff.

I had to fix this in go-librespot too: https://github.com/devgianlu/go-librespot/commit/92ade8e23f0ccabf77594f7d470ed104cc04c306