Skip to content

MP3 parser: Ignore ID3 tags with empty values #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/parsers/mp3_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def to_h
tag = __getobj__
MEMBERS.each_with_object({}) do |k, h|
value = tag.public_send(k)
h[k] = value if value
h[k] = value if value && !value.empty?
end
end
end
Expand Down
Binary file added spec/fixtures/MP3/id3v2_with_empty_tag.mp3
Binary file not shown.
8 changes: 8 additions & 0 deletions spec/parsers/mp3_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
expect(parsed.album).to be_nil
end
end

context 'when has an empty tag' do
let(:fpath) { fixtures_dir + '/MP3/id3v2_with_empty_tag.mp3' }

it 'ignores the empty tags' do
expect(parsed.intrinsics[:genre]).to eq('Rock')
end
end
end

it 'decodes and estimates duration for a CBR MP3' do
Expand Down