Skip to content
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

Major player rewrite + event service implementation #155

Merged
merged 38 commits into from
Apr 27, 2020
Merged

Conversation

devgianlu
Copy link
Member

@devgianlu devgianlu commented Nov 27, 2019

This PR wants to implement the event-service framework because of librespot-org/librespot#342, in order to accomodate the required metrics a major player rewrite has also been done.

All requests are sent to hm://event-service/v1/events via a POST request. The request has three headers: X-ClientTimeStamp, Accept-Language, X-Offset. I'm yet to figure out what the last one does. The body of the request is generally as follows: some chars to identify the type of message and the actual data. The 0x09 character is used to separate various fields.

I have also enhanced the Wireshark scripts to parse event service requests: https://github.com/devgianlu/spotify-analyze

List of client events: https://gist.github.com/devgianlu/8371de4449e90fc18e9bef1a0745bd18

TODO:

  • Re-implement crossfade
  • Fix repeat track not working
  • Fix reporting when source end is different from trackdone
  • Implement known metrics

@backspac
Copy link

backspac commented Dec 6, 2019

Just a wild guess. Following this doc, X-Offset might be the track position in an album or a playlist.
https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/

@devgianlu
Copy link
Member Author

Just a wild guess. Following this doc, X-Offset might be the track position in an album or a playlist.
https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/

Doesn't look like the values are usually even higher than the playlist size.

@devgianlu
Copy link
Member Author

This is finally working!! Except when the "ended how" field is different from trackdone. There is probably some more research to do to figure out what those extra fields are for.

# Conflicts:
#	core/src/main/java/xyz/gianlu/librespot/connectstate/DeviceStateHandler.java
#	core/src/main/java/xyz/gianlu/librespot/core/Session.java
#	core/src/main/java/xyz/gianlu/librespot/player/Player.java
#	core/src/main/java/xyz/gianlu/librespot/player/PlayerRunner.java
@devgianlu devgianlu changed the title Event service implementation Major player rewrite + event service implementation Apr 21, 2020
@Yuhanun
Copy link

Yuhanun commented Apr 23, 2020

Hello,

Is there currently any way to report back to spotify that you listened to a song using the API that this daemon provides?

Right now I'm switching song because it should send the tracking stuff to spotify but it doesn't seem to register on spotify's side.

Thank you,
Yuhanun

@devgianlu
Copy link
Member Author

Is there currently any way to report back to spotify that you listened to a song using the API that this daemon provides?

Yes, when this is going to be merged the client will have complete reporting functionalities.

@Yuhanun
Copy link

Yuhanun commented Apr 23, 2020

Is there currently any way to report back to spotify that you listened to a song using the API that this daemon provides?

Yes, when this is going to be merged the client will have complete reporting functionalities.

Any ETA? Is there any way to do this with the current branch?

@devgianlu
Copy link
Member Author

@Yuhanun No idea when this will be finished. The protocol right know is under development.

@Yuhanun
Copy link

Yuhanun commented Apr 24, 2020

@devgianlu So right now there is absolutely no way to do the listen reports?

@devgianlu
Copy link
Member Author

There is, but why would you need it outside of the player?

@Yuhanun
Copy link

Yuhanun commented Apr 24, 2020

Because I'm building my own CLI tool and I'd like to contribute to the artist their stream count.

Copy link

@Yuhanun Yuhanun left a comment

Choose a reason for hiding this comment

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

Looks like you've got some infinite recursion going

edit: nevermind, nto the same class.

@devgianlu devgianlu merged commit 5f90a8e into dev Apr 27, 2020
@devgianlu devgianlu deleted the listen-reporting branch April 27, 2020 20:19
@Yuhanun
Copy link

Yuhanun commented May 5, 2020

Heyo this doesn't work for me, it doesn't report back "audio streams" (like the listens counters) to spotify, it never gest updated on their end even when listening for 60 seconds+

@hbouhadji
Copy link

+1 @Yuhanun

@humanperzeus
Copy link
Contributor

+1 still not fixed? anywhere to figure out and help to retrieve how the original workflow works?

@devgianlu
Copy link
Member Author

+1 still not fixed? anywhere to figure out and help to retrieve how the original workflow works?

It kind of works, but it's not perfect. If you want to try and analyze the request chain you need to hookup spotify-analyze and dump the Mercury requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants