diff --git a/lib/parsers/mp3_parser.rb b/lib/parsers/mp3_parser.rb index 203d2631..1e5e9a89 100644 --- a/lib/parsers/mp3_parser.rb +++ b/lib/parsers/mp3_parser.rb @@ -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 diff --git a/spec/fixtures/MP3/id3v2_with_empty_tag.mp3 b/spec/fixtures/MP3/id3v2_with_empty_tag.mp3 new file mode 100644 index 00000000..87b8de5b Binary files /dev/null and b/spec/fixtures/MP3/id3v2_with_empty_tag.mp3 differ diff --git a/spec/parsers/mp3_parser_spec.rb b/spec/parsers/mp3_parser_spec.rb index ce7ee9b3..e68cf276 100644 --- a/spec/parsers/mp3_parser_spec.rb +++ b/spec/parsers/mp3_parser_spec.rb @@ -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