songbirdsh 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/songbirdsh/library.rb +0 -1
- data/lib/songbirdsh/scrobbler.rb +10 -8
- metadata +2 -2
data/lib/songbirdsh/library.rb
CHANGED
data/lib/songbirdsh/scrobbler.rb
CHANGED
@@ -9,19 +9,20 @@ module Songbirdsh
|
|
9
9
|
def initialize preferences
|
10
10
|
@preferences = preferences
|
11
11
|
if preferences['lastfm']
|
12
|
-
|
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
|
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
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
:
|
68
|
-
:
|
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
|