librespot-org / librespot-java

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

Run Websocket connection simultaneously to the Session connect #322

Open devgianlu opened 3 years ago

devgianlu commented 3 years ago

With the login5 token endpoint we can save time in the startup time by requesting a token via login5 and use it to start the websocket along with the REST API, we can then start the internal Hermes connection using the same token or with username/password.

The Hermes API should be used as little as possible as it's not going to live in the future. This probably addresses #308 partially.

sashahilton00 commented 3 years ago

Someone asked be earlier about loginv5, I don't suppose you've looked into it to see how the hashcash stuff is solved? Also, after opening the issue a few days back about updating the protobuf definitions, I poked around in the latest client, and a significant number of the calls that were being made over Hermes have been moved to HTTP. I'm hoping to have time to start writing things up in the coming days

devgianlu commented 3 years ago

@sashahilton00 I have indeed figured out how the hashcash is solved. Just haven't published it anywhere since it was useless for out user case until today I come up with this idea that could help in some way.

I've been inspecting the Hermes requests too, but I think all I do with Hermes in this library hasn't moved. I should probably double check all the requests I am making.

PouleR commented 3 years ago

@sashahilton00 I have indeed figured out how the hashcash is solved. Just haven't published it anywhere since it was useless for out use until today I come up with this idea that could help in some way.

I've been inspecting the Hermes requests too, but I think all I do with Hermes in this library hasn't moved. I should probably double check all the requests I am making.

Hi @devgianlu, maybe this is the wrong issue to ask; but can you maybe share the knowledge about the HashCash?

I’m working on a PHP application for the Spotify Artists data and I am using the proto files from this repository. Just to generate all the entities needed for the login5 API. However now I’m struggling to get the actual token since the 2nd request should contain the hashcash if I’m correct.

devgianlu commented 3 years ago

@PouleR Here you go: https://github.com/librespot-org/librespot-java/blob/dev/lib/src/main/java/xyz/gianlu/librespot/core/Login5Api.java

PouleR commented 3 years ago

@devgianlu wow thanks a lot! I’m going to use this to port it to a PHP bundle.

Thanks! Much appreciated