node-sonos-discovery icon indicating copy to clipboard operation
node-sonos-discovery copied to clipboard

Media browsing

Open matiasgarciaisaia opened this issue 10 years ago • 7 comments

Preface

One of the things that mosts annoys me from Sonos is that it's search engine offers me inaccessible songs when people leaves my office. I think it's pretty straightforward to filter out music from inaccessible network libraries.

Issue

Implement media browsing in sonos-discovery. It not just is really useful as-is, but also it enables us to implement some heartbeat ping system to add this capability, and provide a better Sonos experience from http-api or web-controller.

I've already started playing a bit with this, but I've no experience with UPnP at all.

This issue may be a bit of a self-reminder - but I'll be glad to know you're in, too :)

matiasgarciaisaia avatar Feb 24 '14 14:02 matiasgarciaisaia

Hi, I'm not really sure what you are trying to achieve. If you have indexed locations that are located on your co-workers laptops, and they would be unavailable, Sonos wouldn't know this unless it rescans the data. Even if you would have media-browsing in sonos-discovery, you would still receive tracks that are unavailable.

Are you talking about a separate search client (web based perhaps) to search and queue tracks, and filter the result based on the accessibility of the hosting computer (where the tracks reside)?

jishi avatar Feb 24 '14 20:02 jishi

As Sonos doesn't do that, sonos-discovery could regullarly ping those network devices to know if they are accessible or not. And, having media browsing enabled, sonos-discovery could provide that search functionality, even improved.

It most likely will be consumed by the web-controller, to emulate the Sonos search feature, but it will be able to filter the results.

I imagine UPnP provides some search functionality to avoid having to scan the whole library at sonos-discovery level, right?

Anyway, media browsing is required for a full web-controller.

matiasgarciaisaia avatar Feb 24 '14 20:02 matiasgarciaisaia

Well, the library is in the players so it is searchable the same way as on the controller. The core functionality for this is already in place, because it is the same UPnP action as fetching the queue and the favorites.

One big improvement is that you could probably utilize all players for querying and maybe speed things up (I do that when I fetch album art), as well as doing some sort of "mixed" search (like, search for artist and track title at the same time and display the result).

jishi avatar Feb 24 '14 21:02 jishi

I've tried making a Player.prototype.getAll() function analogous to Player.prototype.getFavourites() (just querying for "S:" instead of "FV:2"), but needed to adapt the parsing of the response, and maybe anything else that I don't remember now.

Do you say there currently is a function to get a player's library? Could you elaborate a bit on this?

Thanks for your time :)

matiasgarciaisaia avatar Feb 24 '14 22:02 matiasgarciaisaia

Yes, I have a generic browse method which is overloaded by getFavorites and getQueue.

So in your getAll function you could just invoke:

this.browse("S:", null, null, function (success, result) { // ... do some stuff here? });

Where result will have been XML parsed into an array of javascript objects. Remember that the player will only return approx 600 items at max, you need to invoke it multiple times if the result is bigger than that (check result.totalMatches). It doesn't support filtering atm, but that might not be needed (I think that just limits the fields returned in the XML).

Other examples are: A:ALBUMARTIST:T (search albums starting with T) A:TRACKS:The (tracks starting with "The") A:ALBUM:The (albums starting with "The")

I think you get the drift. :)

However, avoid doing to specialized methods. If it is generically helpful, I would consider merging it. The browse method is public so you can invoke it from the outside if you have some special need.

jishi avatar Feb 24 '14 22:02 jishi

You've saved me like hours playing around with Wireshark and the like. I'll see what I can do (and when, he :)).

Having Sonos only at work makes things a little more slow than what I wished.

matiasgarciaisaia avatar Feb 24 '14 22:02 matiasgarciaisaia

Well, it's never a bad thing to wireshark stuff anyway to get a better understanding of how they interact :)

jishi avatar Feb 25 '14 10:02 jishi