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

In reply to MP3::Tag... losing some data on non-written tags by chback54

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.