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.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 | |
by chback54 (Initiate) on Jul 18, 2011 at 19:55 UTC | |
by toolic (Bishop) on Jul 18, 2011 at 20:29 UTC |