def reload
@header = {}
if @filename_or_io.is_a?(String)
@io_is_a_file = true
@io = File.new(@filename_or_io, "rb")
@io_size = @io.stat.size
@filename = @filename_or_io
elsif @filename_or_io.is_a?(StringIO)
@io_is_a_file = false
@io = @filename_or_io
@io_size = @io.size
@filename = nil
end
if @io_size == 0
raise(Mp3InfoError, "empty file or IO")
end
@io.extend(Mp3FileMethods)
@tag1 = @tag = @tag1_orig = @tag_orig = {}
@tag1.extend(HashKeys)
@tag2 = ID3v2.new(@id3v2_options)
begin
if @tag_parsing_enabled
parse_tags
@tag1_orig = @tag1.dup
if hastag1?
@tag = @tag1.dup
end
if hastag2?
@tag = {}
tag2_mapping = @tag2.version =~ /^2\.2/ ? TAG_MAPPING_2_2 : TAG_MAPPING_2_3
tag2_mapping.each do |key, tag2_name|
tag_value = (@tag2[tag2_name].is_a?(Array) ? @tag2[tag2_name].first : @tag2[tag2_name])
next unless tag_value
@tag[key] = tag_value.is_a?(Array) ? tag_value.first : tag_value
if %w{year tracknum}.include?(key)
@tag[key] = tag_value.to_i
end
if tag2_name == "TCO" && tag_value =~ /^\((\d+)\)$/
@tag["genre_s"] = GENRES[$1.to_i]
end
end
end
@tag.extend(HashKeys)
@tag_orig = @tag.dup
end
if @mp3_parsing_enabled
parse_mp3
end
ensure
if @io_is_a_file
@io.close
end
end
end