From bc488fb111fbf553a1b9ee08c11038ac5ff6364c Mon Sep 17 00:00:00 2001 From: Sen Date: Sun, 20 Apr 2014 16:20:34 -0400 Subject: [PATCH] Add method to get My Radio Stations. Turn the queue method into a generic method to get the contents of a ContentDirectory container (container_contents), then add a new queue method that calls that, plus a radio_stations method to get the My Radio Stations list and their information. --- lib/sonos/endpoint/content_directory.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/sonos/endpoint/content_directory.rb b/lib/sonos/endpoint/content_directory.rb index 543fa6a..dfc77f9 100644 --- a/lib/sonos/endpoint/content_directory.rb +++ b/lib/sonos/endpoint/content_directory.rb @@ -4,9 +4,19 @@ module Sonos::Endpoint::ContentDirectory # Get the current queue def queue(starting_index = 0, requested_count = 100) + container_contents "Q:0", starting_index, requested_count + end + + # Get the radio station listing ("My Radio Stations") + def radio_stations(starting_index = 0, requested_count = 100) + container_contents "R:0/0", starting_index, requested_count + end + + # Get the contents of a given content directory container + def container_contents(container, starting_index, requested_count) name = 'Browse' action = "#{CONTENT_DIRECTORY_XMLNS}##{name}" - message = %Q{Q:0BrowseDirectChildrendc:title,res,dc:creator,upnp:artist,upnp:album,upnp:albumArtURI#{starting_index}#{requested_count}} + message = %Q{#{container}BrowseDirectChildrendc:title,res,dc:creator,upnp:artist,upnp:album,upnp:albumArtURI#{starting_index}#{requested_count}} result = content_directory_client.call name, soap_action: action, message: message body = result.body[:browse_response]