LOLastfm 0.0.3.5 → 0.0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/LOLastfm.rb CHANGED
@@ -263,7 +263,9 @@ class LOLastfm
263
263
  end
264
264
 
265
265
  def use (*args, &block)
266
- return if args.empty? && !block
266
+ if args.empty? && !block
267
+ raise ArgumentError, 'no name or block given'
268
+ end
267
269
 
268
270
  unless args.first.respond_to?(:to_hash) || block
269
271
  name = args.shift.to_sym
@@ -276,7 +278,9 @@ class LOLastfm
276
278
  rescue LoadError; end
277
279
  end
278
280
 
279
- block = self.class.checkers[name]
281
+ unless block = self.class.checkers[name]
282
+ raise ArgumentError, "#{name} checker could not be found"
283
+ end
280
284
  end
281
285
 
282
286
  if @checker
data/lib/LOLastfm/song.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  # 0. You just DO WHAT THE FUCK YOU WANT TO.
9
9
  #++
10
10
 
11
- require 'taglib'
11
+ require 'taglib2'
12
12
  require 'json'
13
13
  require 'yaml'
14
14
  require 'date'
@@ -69,45 +69,19 @@ class Song
69
69
  def fill!
70
70
  return if !@path || (@track && @title && @album && @artist && @comment && @length && @id)
71
71
 
72
- TagLib::FileRef.open(@path) {|f|
73
- if f.tag
74
- @track = f.tag.track && f.tag.track.to_i unless @track
75
- @title = f.tag.title unless @title
76
- @album = f.tag.album unless @album
77
- @artist = f.tag.artist unless @artist
78
- @comment = f.tag.comment unless @comment
79
- end
80
-
81
- if f.audio_properties
82
- @length = f.audio_properties.length.to_i unless @length
83
- end
84
- }
85
-
86
- unless @id
87
- TagLib::MPEG::File.new(@path).tap {|file|
88
- next unless tag = file.id3v2_tag
89
-
90
- if ufid = tag.frame_list('UFID').find { |u| u.owner == 'http://musicbrainz.org' }
91
- @id = ufid.identifier
92
- end
93
- }
94
- end
95
-
96
- unless @id
97
- TagLib::FLAC::File.new(@path).tap {|file|
98
- next unless tag = file.xiph_comment
99
-
100
- @id = tag.field_list_map['MUSICBRAINZ_TRACKID']
101
- }
102
- end
72
+ TagLib::File.new(@path).tap {|f|
73
+ @track = f.track && f.track.to_i if f.track && !@track
74
+ @title = f.title if f.title && !@title
75
+ @album = f.album if f.album && !@album
76
+ @artist = f.artist if f.artist && !@artist
77
+ @comment = f.comment if f.comment && !@comment
103
78
 
104
- unless @id
105
- TagLib::Ogg::Vorbis::File.new(@path).tap {|file|
106
- next unless tag = file.tag
79
+ begin
80
+ @length = f.length.to_i if f.length && !@length
81
+ rescue TagLib::BadAudioProperties; end
107
82
 
108
- @id = tag.field_list_map['MUSICBRAINZ_TRACKID']
109
- }
110
- end
83
+ f.close
84
+ }
111
85
  end
112
86
 
113
87
  def stream?; !!@stream; end
@@ -10,6 +10,6 @@
10
10
 
11
11
  class LOLastfm
12
12
  def self.version
13
- '0.0.3.5'
13
+ '0.0.3.6'
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: LOLastfm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.5
4
+ version: 0.0.3.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine