ruby-mp3info 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.6.4 / 2008-04-16
2
+
3
+ * added @tag2["disc_number"] and @tag2["disc_total"] mirroring TPOS attribute (thanks to Harry Ohlsen)
4
+
1
5
  === 0.6.3 / 2008-03-28
2
6
 
3
7
  * some internals modifications for the compatibility with ruby-audioinfo
data/lib/mp3info.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: mp3info.rb 74 2008-03-28 15:11:04Z moumar $
1
+ # $Id: mp3info.rb 77 2008-04-16 20:04:35Z moumar $
2
2
  # License:: Ruby
3
3
  # Author:: Guillaume Pierronnet (mailto:moumar_AT__rubyforge_DOT_org)
4
4
  # Website:: http://ruby-mp3info.rubyforge.org/
@@ -17,7 +17,7 @@ end
17
17
 
18
18
  class Mp3Info
19
19
 
20
- VERSION = "0.6.3"
20
+ VERSION = "0.6.4"
21
21
 
22
22
  LAYER = [ nil, 3, 2, 1]
23
23
  BITRATE = [
data/lib/mp3info/id3v2.rb CHANGED
@@ -101,6 +101,8 @@ class ID3v2 < DelegateClass(Hash)
101
101
  # for read and write tag2 values.
102
102
  attr_reader :options
103
103
 
104
+ # you can access this object like an hash, with [] and []= methods
105
+ # special cases are ["disc_number"] and ["disc_total"] mirroring TPOS attribute
104
106
  def initialize(options = {})
105
107
  @options = {
106
108
  :lang => "ENG",
@@ -265,44 +267,9 @@ class ID3v2 < DelegateClass(Hash)
265
267
  #size = @io.get_syncsafe #this seems to be a bug
266
268
  size = @io.get32bits
267
269
  @io.read(2)
268
- =begin
269
- size_str = @io.read(4)
270
-
271
- @io.getc #flags part 1
272
- # just read the unsync bit
273
- b = @io.getc
274
- unsync = ((b >> 1) & 1) == 1
275
-
276
- if unsync
277
- size = (size_str[0] << 21) + (size_str[1] << 14) + (size_str[2]<< 7) + size_str[3]
278
- else
279
- size = size_str.unpack("N").first
280
- end
281
- require "to_b"
282
- =end
283
270
  puts "name '#{name}' size #{size}" if $DEBUG
284
271
  #@io.seek(2, IO::SEEK_CUR) # skip flags
285
272
  add_value_to_tag2(name, size)
286
- # case name
287
- # when /^T/
288
- # puts "tag is text. reading" if $DEBUG
289
- ## data = read_id3_string(size-1)
290
- ## add_value_to_tag2(name, data)
291
- # else
292
- # decode_tag(
293
- # #@file.seek(size-1, IO::SEEK_CUR)
294
- # puts "tag is binary, skipping" if $DEBUG
295
- # @io.seek(size, IO::SEEK_CUR)
296
- # end
297
-
298
- # case name
299
- # #FIXME DRY
300
- # when "COMM"
301
- # data = read_id3v2_frame(size)
302
- # lang = data[0,3]
303
- # data = data[3,-1]
304
- # else
305
- # end
306
273
  end
307
274
  break if @io.pos >= @tag_length # 2. reach length from header
308
275
  end
@@ -333,6 +300,12 @@ class ID3v2 < DelegateClass(Hash)
333
300
  raise("tag size too big for tag #{name.inspect} unsync #{@unsync} ") if size > 50_000_000
334
301
  data_io = @io.read(size)
335
302
  data = decode_tag(name, data_io)
303
+
304
+ if self["TPOS"] =~ /(\d+)\s*\/\s*(\d+)/
305
+ self["disc_number"] = $1.to_i
306
+ self["disc_total"] = $2.to_i
307
+ end
308
+
336
309
  if self.keys.include?(name)
337
310
  unless self[name].is_a?(Array)
338
311
  self[name] = self[name].to_a
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-mp3info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Pierronnet
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-28 00:00:00 +01:00
12
+ date: 2008-04-16 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency