Query: mp3::tag::id3v2
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
MP3::Tag::ID3v2(3pm) User Contributed Perl Documentation MP3::Tag::ID3v2(3pm)NAMEMP3::Tag::ID3v2 - Read / Write ID3v2.x.y tags from mp3 audio filesSYNOPSISMP3::Tag::ID3v2 supports * Reading of ID3v2.2.0 and ID3v2.3.0 tags (some ID3v2.4.0 frames too) * Writing of ID3v2.3.0 tags MP3::Tag::ID3v2 is designed to be called from the MP3::Tag module. If you want to make calls from user code, please consider using highest-level wrapper code in MP3::Tag, such as update_tags() and select_id3v2_frame_by_descr(). Low-level creation code: use MP3::Tag; $mp3 = MP3::Tag->new($filename); # read an existing tag $mp3->get_tags(); $id3v2 = $mp3->{ID3v2} if exists $mp3->{ID3v2}; # or create a new tag $id3v2 = $mp3->new_tag("ID3v2"); See MP3::Tag for information on the above used functions. * Reading a tag, very low-level: $frameIDs_hash = $id3v2->get_frame_ids('truename'); foreach my $frame (keys %$frameIDs_hash) { my ($name, @info) = $id3v2->get_frames($frame); for my $info (@info) { if (ref $info) { print "$name ($frame): "; while(my ($key,$val)=each %$info) { print " * $key => $val "; } } else { print "$name: $info "; } } } * Adding / Changing / Removing a frame in memory (higher-level) $t = $id3v2->frame_select("TIT2", undef, undef); # Very flexible $c = $id3v2->frame_select_by_descr("COMM(fre,fra,eng,#0)[]"); $t = $id3v2->frame_select_by_descr("TIT2"); $id3v2->frame_select_by_descr("TIT2", "MyT"); # Set/Change $id3v2->frame_select_by_descr("RBUF", $n1, $n2, $n3); # Set/Change $id3v2->frame_select_by_descr("RBUF", "$n1;$n2;$n3"); # Set/Change $id3v2->frame_select_by_descr("TIT2", undef); # Remove * Adding / Changing / Removing a frame in memory (low-level) $id3v2->add_frame("TIT2", "Title of the audio"); $id3v2->change_frame("TALB","Greatest Album"); $id3v2->remove_frame("TLAN"); * Output the modified-in-memory version of the tag: $id3v2->write_tag(); * Removing the whole tag from the file $id3v2->remove_tag(); * Get information about supported frames %tags = $id3v2->supported_frames(); while (($fname, $longname) = each %tags) { print "$fname $longname: ", join(", ", @{$id3v2->what_data($fname)}), " "; }AUTHORThomas Geffert, thg@users.sourceforge.net Ilya Zakharevich, ilyaz@cpan.orgDESCRIPTIONget_frame_ids() $frameIDs = $tag->get_frame_ids; $frameIDs = $tag->get_frame_ids('truename'); [old name: getFrameIDs() . The old name is still available, but you should use the new name] get_frame_ids loops through all frames, which exist in the tag. It returns a hash reference with a list of all available Frame IDs. The keys of the returned hash are 4-character-codes (short names), the internal names of the frames, the according value is the english (long) name of the frame. You can use this list to iterate over all frames to get their data, or to check if a specific frame is included in the tag. If there are multiple occurences of a frame in one tag, the first frame is returned with its normal short name, following frames of this type get a '01', '02', '03', ... appended to this name. These names can then used with "get_frame" to get the information of these frames. These fake frames are not returned if 'truename' argument is set; one can still use "get_frames()" to extract the info for all of the frames with the given short name. get_frame() ($info, $name, @rest) = $tag->get_frame($ID); ($info, $name, @rest) = $tag->get_frame($ID, 'raw'); [old name: getFrame() . The old name is still available, but you should use the new name] get_frame gets the contents of a specific frame, which must be specified by the 4-character-ID (aka short name). You can use "get_frame_ids" to get the IDs of the tag, or use IDs which you hope to find in the tag. If the ID is not found, "get_frame" returns empty list, so $info and $name become undefined. Otherwise it extracts the contents of the frame. Frames in ID3v2 tags can be very small, or complex and huge. That is the reason, that "get_frame" returns the frame data in two ways, depending on the tag. If it is a simple tag, with only one piece of data, these data is returned directly as ($info, $name), where $info is the text string, and $name is the long (english) name of the frame. If the frame consist of different pieces of data, $info is a hash reference, $name is again the long name of the frame. The hash, to which $info points, contains key/value pairs, where the key is always the name of the data, and the value is the data itself. If the name starts with a underscore (as eg '_code'), the data is probably binary data and not printable. If the name starts without an underscore, it should be a text string and printable. If the second parameter is given as 'raw', the whole frame data is returned, but not the frame header. If the second parameter is 'intact', no mangling of embedded "