ruby-mp3info 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/History.txt +5 -0
  2. data/lib/mp3info.rb +14 -12
  3. metadata +2 -2
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.6.9 / 2008-09-16
2
+
3
+ * now correctly remove trailing whitespaces form tag1 values
4
+ * bugfix #21687 included: 'tweaked the MP3 frame synch code to parse certain mp3 files'
5
+
1
6
  === 0.6.8 / 2008-08-20
2
7
 
3
8
  * support for MPEG 2.5 (thanks to Oleguer Huguet Ibars)
data/lib/mp3info.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # coding:utf-8
2
- # $Id: mp3info.rb 94 2008-08-19 13:34:18Z moumar $
2
+ # $Id: mp3info.rb 98 2008-09-16 11:07:31Z moumar $
3
3
  # License:: Ruby
4
4
  # Author:: Guillaume Pierronnet (mailto:moumar_AT__rubyforge_DOT_org)
5
5
  # Website:: http://ruby-mp3info.rubyforge.org/
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  class Mp3Info
20
20
 
21
- VERSION = "0.6.8"
21
+ VERSION = "0.6.9"
22
22
 
23
23
  LAYER = [ nil, 3, 2, 1]
24
24
  BITRATE = {
@@ -333,16 +333,18 @@ class Mp3Info
333
333
 
334
334
  def get_frames_infos(head)
335
335
  # be sure we are in sync
336
- if (head & 0xffe00000 != 0xffe00000) || # 11 bit MPEG frame sync
337
- (head & 0x00060000 == 0x00060000) || # 2 bit layer type
338
- (head & 0x0000f000 == 0x0000f000) || # 4 bit bitrate
339
- (head & 0x0000f000 == 0x00000000) || # free format bitstream
340
- (head & 0x00000c00 == 0x00000c00) || # 2 bit frequency
341
- (head & 0xffff0000 == 0xfffe0000)
336
+ if ((head & 0xffe00000) != 0xffe00000) || # 11 bit MPEG frame sync
337
+ ((head & 0x00060000) == 0x00060000) || # 2 bit layer type
338
+ ((head & 0x0000f000) == 0x0000f000) || # 4 bit bitrate
339
+ ((head & 0x0000f000) == 0x00000000) || # free format bitstream
340
+ ((head & 0x00000c00) == 0x00000c00) || # 2 bit frequency
341
+ ((head & 0xffff0000) == 0xfffe0000)
342
342
  raise Mp3InfoInternalError
343
343
  end
344
344
  mpeg_version = [2.5, nil, 2, 1][bits(head, 20,19)]
345
+
345
346
  layer = LAYER[bits(head, 18,17)]
347
+ raise Mp3InfoInternalError if layer == nil || mpeg_version == nil
346
348
  { :layer => layer,
347
349
  :bitrate => BITRATE[mpeg_version][layer-1][bits(head, 15,12)-1],
348
350
  :samplerate => SAMPLERATE[mpeg_version][bits(head, 11,10)],
@@ -548,9 +550,9 @@ private
548
550
  ### assumes @file is pointing to char after "TAG" id
549
551
  def gettag1
550
552
  @tag1_parsed = true
551
- @tag1["title"] = @file.read(30).sub(/\0*$/, '')
552
- @tag1["artist"] = @file.read(30).sub(/\0*$/, '')
553
- @tag1["album"] = @file.read(30).sub(/\0*$/, '')
553
+ @tag1["title"] = @file.read(30).unpack("A*").first
554
+ @tag1["artist"] = @file.read(30).unpack("A*").first
555
+ @tag1["album"] = @file.read(30).unpack("A*").first
554
556
  year_t = @file.read(4).to_i
555
557
  @tag1["year"] = year_t unless year_t == 0
556
558
  comments = @file.read(30)
@@ -558,7 +560,7 @@ private
558
560
  @tag1["tracknum"] = comments.getbyte(-1).to_i
559
561
  comments.chop! #remove the last char
560
562
  end
561
- @tag1["comments"] = comments.sub(/\0*$/, '')
563
+ @tag1["comments"] = comments.unpack("A*").first
562
564
  @tag1["genre"] = @file.getbyte
563
565
  @tag1["genre_s"] = GENRES[@tag1["genre"]] || ""
564
566
 
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.8
4
+ version: 0.6.9
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-08-20 00:00:00 +02:00
12
+ date: 2008-09-16 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency