simple_scrobbler 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_scrobbler/version.rb +1 -1
- data/lib/simple_scrobbler.rb +10 -7
- metadata +2 -2
data/lib/simple_scrobbler.rb
CHANGED
@@ -81,6 +81,7 @@ class SimpleScrobbler
|
|
81
81
|
# :mb_trackid :: MusicBrainz Track ID
|
82
82
|
#
|
83
83
|
def submit(artist, track, options={})
|
84
|
+
enforce_keys options, :time, :length, :album, :track_number, :mb_trackid
|
84
85
|
if @source == "P" && !options[:length]
|
85
86
|
raise DataError, "Track length must be specified if source is P"
|
86
87
|
end
|
@@ -110,6 +111,7 @@ class SimpleScrobbler
|
|
110
111
|
# :mb_trackid :: MusicBrainz Track ID
|
111
112
|
#
|
112
113
|
def now_playing(artist, track, options={})
|
114
|
+
enforce_keys options, :length, :album, :track_number, :mb_trackid
|
113
115
|
handshake
|
114
116
|
parameters =
|
115
117
|
generate_scrobbling_parameters(false,
|
@@ -163,16 +165,11 @@ private
|
|
163
165
|
query_string = sort_parameters(parameters).
|
164
166
|
map{ |k, v| "#{k}=#{CGI.escape(v)}" }.
|
165
167
|
join("&")
|
166
|
-
Net::HTTP.get_response(
|
167
|
-
URI.parse(url + "?" + query_string)
|
168
|
-
).body
|
168
|
+
Net::HTTP.get_response(URI.parse(url + "?" + query_string)).body
|
169
169
|
end
|
170
170
|
|
171
171
|
def post(url, parameters)
|
172
|
-
Net::HTTP.post_form(
|
173
|
-
URI.parse(url),
|
174
|
-
parameters
|
175
|
-
).body
|
172
|
+
Net::HTTP.post_form(URI.parse(url), parameters).body
|
176
173
|
end
|
177
174
|
|
178
175
|
def md5(s)
|
@@ -215,4 +212,10 @@ private
|
|
215
212
|
hash
|
216
213
|
}
|
217
214
|
end
|
215
|
+
|
216
|
+
def enforce_keys(hash, *keys)
|
217
|
+
if (extras = hash.keys - keys).any?
|
218
|
+
raise DataError, "Unknown hash key(s): #{extras.inspect}"
|
219
|
+
end
|
220
|
+
end
|
218
221
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_scrobbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Battley
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-07-
|
12
|
+
date: 2010-07-11 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|