sweeper 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ v0.2.4. More robust XSD error handling.
3
+
2
4
  v0.2.3. Rescue another OpenURI error.
3
5
 
4
6
  v0.2.2. Avoid error with too many open files.
data/lib/sweeper.rb CHANGED
@@ -94,7 +94,7 @@ class Sweeper
94
94
 
95
95
  rescue Problem => e
96
96
  tries += 1 and retry if tries < 2
97
- puts "Skipped (#{e.message}): #{File.basename(filename)}"
97
+ puts "Skipped (#{e.message.gsub('\n', ' ')}): #{File.basename(filename)}"
98
98
  @failed += 1
99
99
  end
100
100
  end
@@ -154,16 +154,16 @@ class Sweeper
154
154
  response = `./#{File.basename(binary)} #{filename.inspect} 2> #{@errf.path}`
155
155
  object = begin
156
156
  XSD::Mapping.xml2obj(response)
157
- rescue REXML::ParseException
158
- raise Problem, "Server sent invalid response"
157
+ rescue Object => e
158
+ raise Problem, "#{e.class.name} - #{e.message}"
159
159
  end
160
- raise Problem, "Fingerprint failed or not found" unless object
160
+ raise Problem, "Fingerprint failed" unless object
161
161
 
162
162
  tags = {}
163
163
  song = Array(object.track).first
164
164
 
165
165
  BASIC_KEYS.each do |key|
166
- tags[key] = song.send(key) if song.respond_to? key
166
+ tags[key] = song.send(key) if song.respond_to? key
167
167
  end
168
168
  tags
169
169
  end
@@ -175,11 +175,18 @@ class Sweeper
175
175
 
176
176
  response = begin
177
177
  open("http://ws.audioscrobbler.com/1.0/artist/#{URI.encode(tags['artist'])}/toptags.xml").read
178
- rescue OpenURI::HTTPError, URI::InvalidURIError
178
+ rescue Object => e
179
+ puts "Open-URI error: #{e.class.name} - #{e.message}" if ENV['DEBUG']
179
180
  return DEFAULT_GENRE
180
181
  end
181
182
 
182
- object = XSD::Mapping.xml2obj(response)
183
+ begin
184
+ object = XSD::Mapping.xml2obj(response)
185
+ rescue Object => e
186
+ puts "XSD error: #{e.class.name} - #{e.message}" if ENV['DEBUG']
187
+ return DEFAULT_GENRE
188
+ end
189
+
183
190
  return DEFAULT_GENRE if !object.respond_to? :tag
184
191
 
185
192
  genres = Array(object.tag)[0..(GENRE_COUNT - 1)].map(&:name)
data/sweeper.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
 
2
- # Gem::Specification for Sweeper-0.2.3
2
+ # Gem::Specification for Sweeper-0.2.4
3
3
  # Originally generated by Echoe
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{sweeper}
7
- s.version = "0.2.3"
7
+ s.version = "0.2.4"
8
8
 
9
9
  s.specification_version = 2 if s.respond_to? :specification_version=
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sweeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Weaver
metadata.gz.sig CHANGED
Binary file