Skip to content

Commit 990de38

Browse files
authored
Merge pull request #49 from scouttyg/scott/more-wahwah-parse-fixes
Adding a few more parsing fixes for various M4A and MP3 file types
2 parents 8c8b5b2 + 1249064 commit 990de38

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

lib/wahwah/helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def self.file_format_from_signature(io)
6262
# M4A is checked for first, since MP4 files start with a chunk size -
6363
# and that chunk size may incidentally match another signature.
6464
# No other formats would reasonably have "ftyp" as the next for bytes.
65-
return "m4a" if ["ftypM4A ".b, "ftyp3gp4".b].include?(signature[4...12])
65+
return "m4a" if ["ftypM4A ".b, "ftyp3gp4".b, "ftypmp42".b].include?(signature[4...12])
6666
# Handled separately simply because it requires two checks.
6767
return "wav" if signature.start_with?("RIFF".b) && signature[8...12] == "WAVE".b
6868
magic_numbers = {

lib/wahwah/mp3_tag.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def parse
5252
def parse_id3_tag
5353
@file_io.rewind
5454
signature = @file_io.read(6)
55+
@file_io.rewind
5556

5657
if signature.start_with?("ID3".b)
5758
id3_v2_tag = ID3::V2.new(@file_io)
@@ -72,7 +73,7 @@ def parse_duration
7273
@bitrate = (bytes_count * 8 / @duration / 1000).round unless @duration.zero?
7374
else
7475
@bitrate = mpeg_frame_header.frame_bitrate
75-
@duration = (file_size - (@id3_tag&.size || 0)) * 8 / (@bitrate * 1000).to_f unless @bitrate.zero?
76+
@duration = (file_size - (@id3_tag&.size || 0)) * 8 / (@bitrate * 1000).to_f unless @bitrate.to_i.zero?
7677
end
7778
end
7879

lib/wahwah/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module WahWah
4-
VERSION = "1.6.5"
4+
VERSION = "1.6.6"
55
end

0 commit comments

Comments
 (0)