diff --git a/lib/wahwah/helper.rb b/lib/wahwah/helper.rb index b2cef96..dc43fe8 100644 --- a/lib/wahwah/helper.rb +++ b/lib/wahwah/helper.rb @@ -62,7 +62,7 @@ def self.file_format_from_signature(io) # M4A is checked for first, since MP4 files start with a chunk size - # and that chunk size may incidentally match another signature. # No other formats would reasonably have "ftyp" as the next for bytes. - return "m4a" if ["ftypM4A ".b, "ftyp3gp4".b].include?(signature[4...12]) + return "m4a" if ["ftypM4A ".b, "ftyp3gp4".b, "ftypmp42".b].include?(signature[4...12]) # Handled separately simply because it requires two checks. return "wav" if signature.start_with?("RIFF".b) && signature[8...12] == "WAVE".b magic_numbers = { diff --git a/lib/wahwah/mp3_tag.rb b/lib/wahwah/mp3_tag.rb index e8dfe37..a207114 100644 --- a/lib/wahwah/mp3_tag.rb +++ b/lib/wahwah/mp3_tag.rb @@ -52,6 +52,7 @@ def parse def parse_id3_tag @file_io.rewind signature = @file_io.read(6) + @file_io.rewind if signature.start_with?("ID3".b) id3_v2_tag = ID3::V2.new(@file_io) @@ -72,7 +73,7 @@ def parse_duration @bitrate = (bytes_count * 8 / @duration / 1000).round unless @duration.zero? else @bitrate = mpeg_frame_header.frame_bitrate - @duration = (file_size - (@id3_tag&.size || 0)) * 8 / (@bitrate * 1000).to_f unless @bitrate.zero? + @duration = (file_size - (@id3_tag&.size || 0)) * 8 / (@bitrate * 1000).to_f unless @bitrate.to_i.zero? end end diff --git a/lib/wahwah/version.rb b/lib/wahwah/version.rb index d4060c6..d1affd2 100644 --- a/lib/wahwah/version.rb +++ b/lib/wahwah/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module WahWah - VERSION = "1.6.5" + VERSION = "1.6.6" end