songbirdsh 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -82,7 +82,6 @@ private
82
82
  end
83
83
 
84
84
  def append_to_track track, row
85
- debug row.inspect
86
85
  case row[:property_id]
87
86
  when 1; track.track = row[:obj_searchable]
88
87
  when 2; track.album = row[:obj_searchable]
@@ -9,19 +9,20 @@ module Songbirdsh
9
9
  def initialize preferences
10
10
  @preferences = preferences
11
11
  if preferences['lastfm']
12
- @scrobbler = SimpleScrobbler.new *%w{api_key secret user session_key}.map{|k| [k]}
12
+ debug "Configuring scrobbler with #{preferences['lastfm'].inspect}"
13
+ @scrobbler = SimpleScrobbler.new *%w{api_key secret user session_key}.map{|k| preferences['lastfm'][k]}
13
14
  end
14
15
  end
15
16
 
16
17
  def scrobble track
17
18
  return unless @scrobbler
18
- debug "Scrobbling to last fm: #{track.inspect}"
19
+ debug "Scrobbling to last fm: #{track}"
19
20
  send_to_scrobbler :submit, track
20
21
  end
21
22
 
22
23
  def update track
23
24
  return unless @scrobbler
24
- debug "Updating now listening with last fm: #{track.inspect}"
25
+ debug "Updating now listening with last fm: #{track}"
25
26
  send_to_scrobbler :now_playing, track
26
27
  end
27
28
 
@@ -61,11 +62,12 @@ module Songbirdsh
61
62
  private
62
63
  def send_to_scrobbler message, track
63
64
  begin
64
- @scrobbler.send message, track[:artist],
65
- track[:track],
66
- :length => track[:duration],
67
- :album => track[:album],
68
- :track_number => track[:number]
65
+ debug %w{artist track duration album number}.map {|k| "#{k}=#{track.send(k)}"}.join(',')
66
+ @scrobbler.send message, track.artist,
67
+ track.track,
68
+ :length => track.duration,
69
+ :album => track.album,
70
+ :track_number => track.number
69
71
  rescue Exception => e
70
72
  puts "Failed to scrobble: #{e}"
71
73
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mark Ryall