Skip to content

Commit

Permalink
Fix album art
Browse files Browse the repository at this point in the history
  • Loading branch information
soffes committed Dec 24, 2012
1 parent e6ece3e commit 38c9b52
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changelog.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Version 0.2.1 — December 24, 2012

* Fix album art in now playing

### Version 0.2.0 — December 24, 2012

* Add Loudness setting
Expand Down
1 change: 0 additions & 1 deletion Readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ There is a very limited CLI right now. You can run `sonos discover` to get the I
* Nonblocking calls with Celluloid::IO
* List other speakers
* Handle errors better
* Fix album art in `now_playing`
* Handle line-in in `now_playing`
* Better support for stero pairs
* CLI client for everything
Expand Down
9 changes: 8 additions & 1 deletion lib/sonos/endpoint/transport.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'uri'

module Sonos::Endpoint::Transport
TRANSPORT_ENDPOINT = '/MediaRenderer/AVTransport/Control'
TRANSPORT_XMLNS = 'urn:schemas-upnp-org:service:AVTransport:1'
Expand All @@ -9,6 +11,11 @@ def now_playing
body = response.body[:get_position_info_response]
doc = Nokogiri::XML(body[:track_meta_data])

art_path = doc.xpath('//upnp:albumArtURI').inner_text

# TODO: No idea why this is necessary. Maybe its a Nokogiri thing
art_path.sub!('/getaa?s=1=x-sonos-http', '/getaa?s=1&u=x-sonos-http')

{
title: doc.xpath('//dc:title').inner_text,
artist: doc.xpath('//dc:creator').inner_text,
Expand All @@ -17,7 +24,7 @@ def now_playing
track_duration: body[:track_duration],
current_position: body[:rel_time],
uri: body[:track_uri],
album_art: "http://#{self.ip}:#{PORT}#{doc.xpath('//upnp:albumArtURI').inner_text}"
album_art: "http://#{self.ip}:#{Sonos::PORT}#{art_path}"
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/sonos/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Sonos
VERSION = '0.2.0'
VERSION = '0.2.1'
end
1 change: 1 addition & 0 deletions sonos.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ Gem::Specification.new do |gem|
gem.require_paths = ['lib']

gem.add_dependency 'savon', '~> 2.0.2'
gem.add_dependency 'nokogiri'
gem.add_dependency 'thor'
end

0 comments on commit 38c9b52

Please sign in to comment.