chback54 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I'm writing Perl lines using the MP3::Tag module in order to verify/modify some tags. I'm kinda new to Perl but I got a lot of things I wanted to work like reading tags, etc. I'm using ID3V2 tags.

Now, I want to write the "TPE2" frame (album artist) and I get this weird problem: every other filled tag of my file loses the last character. Ex: The artist tag set to "Rush" would become "Rus", "1981" becomes "198", etc. but the frame I write in is OK !

Here's my code, sorry if it's not very elegant and loaded with prints... I'm trying to make it work first. It might be useful (or not) for you to know that I want to use this frame as the band's country. I would basically insert an 3-letter ISO country code like USA or GER in the frame.

As you can see, first argument is the filename and second is my 3-letter ISO country code.
sub setCountry { my $myMP3 = $_[0]; my $myCountry = $_[1]; my $objMP3 = MP3::Tag->new($myMP3); $objMP3->get_tags(); if (exists $objMP3->{ID3v2}) { my $objMP3ID3v2 = $objMP3->{ID3v2}; my ($tmpStrAlbumArtist, $tmpStrLong) = $objMP3ID3v2->get_frame +("TPE2"); if (defined $tmpStrAlbumArtist) { if ($tmpStrAlbumArtist eq $myCountry) { print "was already $tmpStrAlbumArtist ... no update\n" +; } else { print "Tag exists but is different than expected = $tm +pStrAlbumArtist ... no update\n"; } } else { $objMP3ID3v2->add_frame("TPE2", $myCountry); my $result = $objMP3ID3v2->write_tag(); if ($result == 1) { print "Updated successfully to $tmpStrAlbumArtist ...\ +n"; } else { print "Error while updating ...\n"; } } } else { print "No existing ID3V2 tag ...\n"; } $objMP3->close(); }

Thanks for your help !

Charlieboy

Replies are listed 'Best First'.
Re: MP3::Tag... losing some data on non-written tags
by toolic (Bishop) on Jul 18, 2011 at 18:09 UTC
    This bug report on CPAN might be related to your MP3::Tag issue. If not, you could browse the other 28 open bug reports.

      I read the bug reports... thanks for pointing out, I wasn't aware of them.

      But, sadly, nothing that seems to be about my problem. I use a ID3v2.3 tag and not a v2.4. I tried the modifications anyway, didn't work. I tried using other frames for my data, nothing will do... keeps on flushing the last char of all the other tags when I use write_tag()

        Submit your own bug report, if you are convinced it is a bug.