-
Notifications
You must be signed in to change notification settings - Fork 659
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
Create separate discovery crate #673
Conversation
1161a39
to
0879ef9
Compare
I left a more detailed comment in #648 w.r.t discovery/mdns being split out. I think this makes sense if we do go ahead and strim down librespot into a leaner library. |
cdadf29
to
7399c1d
Compare
(Just rebased it on top of #668 because they're somehow related and I don't want them to diverge) |
7399c1d
to
3ceaf21
Compare
412801f
to
1a26302
Compare
The change is not breaking anymore, so it would be eligible for a 0.2.x release. The de-/serializing of requests and responses became (too?) elaborate, but if you want so, I could restore the old parsing functions. While I find it pleasing to run What do you say? |
527e080
to
0ac5d1c
Compare
Would you feel more comfortable if I would split off e3e60bb from this PR? It would be much smaller then. |
+1 if I had anything to say about it.
|
This is more than opportunistic refactoring (-115 +1,037), and it's not strictly necessary. It would just make it easier if new functions are discovered in this small protocol, or if someone wants to reverse the functionality and use it as client to discover other devices. It might be good to keep it for later, but for now I'm going to remove this commit. |
0ac5d1c
to
ceab363
Compare
I left the tiniest review. Other than that, looks good to me and a good move to reduce coupling. |
You left no review. |
Forgot to push a big green button 🤦 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this may be nitpicking but I think you should update the version
field a few lines up to do the same. Or more specifically I think the version
field should be the librespot
version and libraryVersion
the discovery
crate version.
For librespot
this will likely be the same. If we want to be 100% goody two shoes about it, downstream applications should set the version
field to their version and use the librespot
version for libraryVersion
.
Again this is really nitpicking so unnecessary to spend too much time on it.
For reference a couple of strings I found from official Connect devices:
Denon HEOS 1:
{
"status":101,
"statusString":"OK",
"spotifyError":0,
"version":"2.3.0",
"deviceID":"c55c5eac1425934ea557ac129df7ad0fa00011a2",
"remoteName":"Sypialnia",
"activeUser":"xxx",
"publicKey":"gDPJ1G71jRxqxZHET/t081EF5cQ4IR/wE0WCeqTRtAb72OAooAqn8RdUnVTfxGPAI7eph69CDoamD15i91TutfrDvw7ALOUplwg7bjM3MAuWSwjimOoiPDNRdDPz8n0y",
"brandDisplayName":"HEOS by Denon",
"modelDisplayName":"HEOS 5",
"libraryVersion":"2.8.71-g9919e10f",
"resolverVersion":"1"
}
Autonomic:
{
"status":101,
"statusString":"ERROR-OK",
"spotifyError":0,
"version":"2.6.1",
"deviceID":"11224DB33B1B",
"deviceType":"SPEAKER",
"remoteName":"Kök",
"activeUser":null,
"publicKey":null,
"accountReq":null,
"brandDisplayName":"AC",
"modelDisplayName":"Media Control Server",
"libraryVersion":"5.35.20191025.0",
"resolverVersion":null,
"groupStatus":null,
"tokenType":null,
"clientID":null,
"scope":null,
"availability":null,
"autonomic_fqn":null
}
Asus Clique R100:
{
"status":101,
"statusString":"OK",
"spotifyError":0,
"version":"2.1.0",
"deviceID":"255720ef-e852-419f-a2f5-6443905b8cfd",
"remoteName":"Wohnzimmer",
"publicKey":"bTBzujQi9/JfWvZZIlhMnFy7MHwzTrHH1DC2B7Xtl3VJhFgZTywLD26VlsrqSv5jO5f6sLgZ01wrotShQpNPJ7varaZ9VJ/7Ch/tHegbeObCCAMMOAQkpWIp0/aPlI/g",
"activeUser":"xxx",
"accountReq":"PREMIUM",
"deviceType":"SPEAKER",
"brandDisplayName":"ASUS",
"modelDisplayName":"Clique_R100",
"libraryVersion":"1.20.0-g594175d4"
}
No, I don't think so. I'm really no expert in this regard, but 2.x.y could very well indicate the version of the protocol used. |
Neither am I so let's try it this way then. |
This PR splits out a new
librespot-discovery
crate out oflibrespot-connect
. The original rationale was the fact that discovery and spirc don't have many dependencies in common. Probably they only belong to the same crate because Spotify sells them as one feature.However, after the split was done, I wondered how the new crate could be improved and extended.
There might be other endpoints that we (at least I) don't know of, or they might be added in future, so my first aim was to make it easy to add them. I also thought of the possibility to add a client functionality to this crate. Therefore, I decided to create slightly overengineeredSerialize
andDeserialize
implementations for arguments and responses. Those can be found in the modulesrequest
andresponse
. I added unit tests to handle the additional complexity.I tried to create a neat API surface, and added documentation for all public items.
I don't want this to get merged before #665 is merged into dev, so I keep it as a draft for now. But I'd really like to hear you feedback before I continue working on it. Do you think it is a worthwhile change, or is it getting too complicated?This change is not breaking: The module
librespot_connect::discovery
remains as a compatibility layer for the new crate and will be deprecated. This module could be removed in a later breaking release.PS: There's one concrete improvement: The server does not panic anymore on certain malformed requests.Future possibilites
EDIT: After removing commit e3e60bb, most things don't apply anymore. It would be just a step into this direction.