ruby-mp3info 0.6.11 → 0.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
 - data/lib/mp3info.rb +7 -12
 - metadata +3 -3
 
    
        data/History.txt
    CHANGED
    
    
    
        data/lib/mp3info.rb
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ end 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            class Mp3Info
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              VERSION = "0.6. 
     | 
| 
      
 21 
     | 
    
         
            +
              VERSION = "0.6.12"
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
              LAYER = [ nil, 3, 2, 1]
         
     | 
| 
       24 
24 
     | 
    
         
             
              BITRATE = {
         
     | 
| 
         @@ -301,33 +301,28 @@ class Mp3Info 
     | 
|
| 
       301 
301 
     | 
    
         
             
                    samples_per_frame = SAMPLES_PER_FRAME[@layer][@mpeg_version] 
         
     | 
| 
       302 
302 
     | 
    
         
             
            	@length = frame_count * samples_per_frame / Float(@samplerate)
         
     | 
| 
       303 
303 
     | 
    
         | 
| 
       304 
     | 
    
         
            -
            	@bitrate = (((stream_size/frame_count)*@samplerate)/144)  
     | 
| 
      
 304 
     | 
    
         
            +
            	@bitrate = (((stream_size/frame_count)*@samplerate)/144) / 1024
         
     | 
| 
       305 
305 
     | 
    
         
             
            	@vbr = true
         
     | 
| 
       306 
306 
     | 
    
         
             
                  else
         
     | 
| 
       307 
307 
     | 
    
         
             
            	# for cbr, calculate duration with the given bitrate
         
     | 
| 
       308 
308 
     | 
    
         
             
            	stream_size = @file.stat.size - (hastag1? ? TAG1_SIZE : 0) - (@tag2.io_position || 0)
         
     | 
| 
       309 
309 
     | 
    
         
             
            	@length = ((stream_size << 3)/1000.0)/@bitrate
         
     | 
| 
      
 310 
     | 
    
         
            +
                    full_scan_occured = false
         
     | 
| 
       310 
311 
     | 
    
         
             
                    # read the first 100 frames and decide if the mp3 is vbr and needs full scan
         
     | 
| 
       311 
312 
     | 
    
         
             
                    begin
         
     | 
| 
       312 
313 
     | 
    
         
             
                      bitrate, length = frame_scan(100)
         
     | 
| 
       313 
314 
     | 
    
         
             
                      if @bitrate != bitrate
         
     | 
| 
       314 
315 
     | 
    
         
             
                        @vbr = true
         
     | 
| 
       315 
316 
     | 
    
         
             
                        @bitrate, @length = frame_scan
         
     | 
| 
      
 317 
     | 
    
         
            +
                        full_scan_occured = true
         
     | 
| 
       316 
318 
     | 
    
         
             
                      end
         
     | 
| 
       317 
319 
     | 
    
         
             
                    rescue Mp3InfoInternalError
         
     | 
| 
       318 
320 
     | 
    
         
             
                    end
         
     | 
| 
       319 
     | 
    
         
            -
            	if @tag2["TLEN"]
         
     | 
| 
      
 321 
     | 
    
         
            +
            	if (tlen = @tag2["TLEN"]) && !full_scan_occured
         
     | 
| 
       320 
322 
     | 
    
         
             
            	  # but if another duration is given and it isn't close (within 5%)
         
     | 
| 
       321 
323 
     | 
    
         
             
            	  #  assume the mp3 is vbr and go with the given duration
         
     | 
| 
       322 
     | 
    
         
            -
            	   
     | 
| 
       323 
     | 
    
         
            -
            	   
     | 
| 
       324 
     | 
    
         
            -
            	  if percent_diff.abs > 0.05
         
     | 
| 
       325 
     | 
    
         
            -
            	    # without the xing header, this is the best guess without reading
         
     | 
| 
       326 
     | 
    
         
            -
            	    # every single frame
         
     | 
| 
       327 
     | 
    
         
            -
            	    @vbr = true
         
     | 
| 
       328 
     | 
    
         
            -
            	    @length = @tag2["TLEN"].to_i/1000
         
     | 
| 
       329 
     | 
    
         
            -
            	    @bitrate = (stream_size / @bitrate) >> 10
         
     | 
| 
       330 
     | 
    
         
            -
            	  end
         
     | 
| 
      
 324 
     | 
    
         
            +
            	  @length = (tlen.is_a?(Array) ? tlen.last : tlen).to_i/1000
         
     | 
| 
      
 325 
     | 
    
         
            +
            	  @bitrate = (stream_size / @bitrate) / 1024
         
     | 
| 
       331 
326 
     | 
    
         
             
            	end
         
     | 
| 
       332 
327 
     | 
    
         
             
                  end
         
     | 
| 
       333 
328 
     | 
    
         
             
                ensure
         
     | 
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.12
         
     | 
| 
       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: 2009- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2009-02-23 00:00:00 +01:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -20,7 +20,7 @@ dependencies: 
     | 
|
| 
       20 
20 
     | 
    
         
             
                requirements: 
         
     | 
| 
       21 
21 
     | 
    
         
             
                - - ">="
         
     | 
| 
       22 
22 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       23 
     | 
    
         
            -
                    version: 1. 
     | 
| 
      
 23 
     | 
    
         
            +
                    version: 1.8.3
         
     | 
| 
       24 
24 
     | 
    
         
             
                version: 
         
     | 
| 
       25 
25 
     | 
    
         
             
            description: "* written in pure ruby  * read low-level informations like bitrate, length, samplerate, etc... * read, write, remove id3v1 and id3v2 tags * correctly read VBR files (with or without Xing header) * only 2.3 version is supported for writings id3v2 tags  == SYNOPSIS:  a good exercise is to read the test.rb to understand how the library works deeper  require \"mp3info\" # read and display infos & tags Mp3Info.open(\"myfile.mp3\") do |mp3info| puts mp3info end  # read/write tag1 and tag2 with Mp3Info#tag attribute # when reading tag2 have priority over tag1 # when writing, each tag is written. Mp3Info.open(\"myfile.mp3\") do |mp3| puts mp3.tag.title    puts mp3.tag.artist    puts mp3.tag.album puts mp3.tag.tracknum mp3.tag.title = \"track title\" mp3.tag.artist = \"artist name\" end  Mp3Info.open(\"myfile.mp3\") do |mp3| # you can access four letter v2 tags like this puts mp3.tag2.TIT2 mp3.tag2.TIT2 = \"new TIT2\" # or like that mp3.tag2[\"TIT2\"] # at this time, only COMM tag is processed after reading and before writing # according to ID3v2#options hash mp3.tag2.options[:lang] = \"FRE\" mp3.tag2.COMM = \"my comment in french, correctly handled when reading and writing\" end"
         
     | 
| 
       26 
26 
     | 
    
         
             
            email: moumar@rubyforge.org
         
     |