MP3::Tag::ID3v1(3pm)
π MP3::Tag::ID3v1 β bestie's guide to reading + writing ID3v1 tags π
okay so this is MP3::Tag::ID3v1, from the User Contributed Perl Documentation corner of the perl-verse (perl v5.36.0, page dated 2022-12-30, if you're keeping receipts). It's the module that handles reading / writing ID3v1 tags of MP3 audio files. π
β¨ NAME β¨
MP3::Tag::ID3v1 β Module for reading / writing ID3v1 tags of MP3 audio files. that's it, that's the whole vibe. π
π¦ SYNOPSIS π¦
so MP3::Tag::ID3v1 is designed to be called from the MP3::Tag module. it's not a solo act, it's a feature. π«Ά
use MP3::Tag;
$mp3 = MP3::Tag->new($filename);
# read an existing tag
$mp3->get_tags();
$id3v1 = $mp3->{ID3v1} if exists $mp3->{ID3v1};
# or create a new tag
$id3v1 = $mp3->new_tag("ID3v1");
See MP3::Tag for information on the above used functions. (go look, it's right there, i'll wait π)
πΈ Reading the tag
print " Title: " .$id3v1->title . "\n";
print " Artist: " .$id3v1->artist . "\n";
print " Album: " .$id3v1->album . "\n";
print "Comment: " .$id3v1->comment . "\n";
print " Year: " .$id3v1->year . "\n";
print " Genre: " .$id3v1->genre . "\n";
print " Track: " .$id3v1->track . "\n";
# or at once
@tagdata = $mp3->all();
foreach $tag (@tagdata) {
print $tag;
}
π Changing / Writing the tag
$id3v1->comment("This is only a Test Tag");
$id3v1->title("testing");
$id3v1->artist("Artest");
$id3v1->album("Test it");
$id3v1->year("1965");
$id3v1->track("5");
$id3v1->genre("Blues");
# or at once
$id3v1->all("song title","artist","album","1900","comment",10,"Ska");
$id3v1->write_tag();
β Removing the tag from the file
$id3v1->remove_tag();
π AUTHOR π
Thomas Geffert, thg@users.sourceforge.net β shoutout to the icon who wrote this fr fr π
π DESCRIPTION π
π title(), artist(), album(), year(), comment(), track(), genre()
$artist = $id3v1->artist;
$artist = $id3v1->artist($artist);
$album = $id3v1->album;
$album = $id3v1->album($album);
$year = $id3v1->year;
$year = $id3v1->year($year);
$comment = $id3v1->comment;
$comment = $id3v1->comment($comment);
$track = $id3v1->track;
$track = $id3v1->track($track);
$genre = $id3v1->genre;
$genre = $id3v1->genre($genre);
Use these functions to retrieve the date of these fields, or to set the data. so like β call it with no args, you get the value. hand it an arg, you're setting it. main character energy, truly. β¨
$genre can be a string with the name of the genre, or a number describing the genre. both are valid, no gatekeeping. π¦
π all()
@tagdata = $id3v1->all;
@tagdata = $id3v1->all($title, $artist, $album, $year, $comment, $track, $genre);
Returns all information of the tag in a list. You can use this sub also to set the data of the complete tag. it's giving two-jobs-one-sub, obsessed. π
The order of the data is always title, artist, album, year, comment, track, and genre. genre has to be a string with the name of the genre, or a number identifying the genre.
π fits_tag()
warn "data truncated" unless $id3v1->fits_tag($hash);
Check whether the info in ID3v1 tag fits into the format of the file. vibe check on your metadata, basically. πΈ
π as_bin()
$str = $id3v1->as_bin();
Returns the ID3v1 tag as a string. raw bytes, no notes. π₯
π write_tag()
$id3v1->write_tag();
[old name: writeTag() . The old name is still available, but you should use the new name]
Writes the ID3v1 tag to the file. commit to the bit, bestie. β¨
π remove_tag()
$id3v1->remove_tag();
Removes the ID3v1 tag from the file. Returns negative on failure, FALSE if no tag was found.
Caveat, and listen up: only one tag is removed; some β broken β files may have many chain-loaded one after another; you may need to call remove_tag() in a loop to handle such beasts. π like, actually loop. don't come crying to me.
[old name: removeTag() . The old name is still available, but you should use the new name]
π genres()
@allgenres = $id3v1->genres;
$genreName = $id3v1->genres($genreID);
$genreID = $id3v1->genres($genreName);
Returns a list of all genres, or the according name or id to a given id or name. give it an id, get the name; give it a name, get the id. it does both, it ate. π
π new()
$id3v1 = MP3::Tag::ID3v1->new($mp3fileobj[, $create]);
Generally called from MP3::Tag, because a $mp3fileobj is needed. If $create is true, a new tag is created. Otherwise undef is returned, if no ID3v1 tag is found in the $mp3obj.
Please use
$mp3 = MP3::Tag->new($filename);
$id3v1 = $mp3->new_tag("ID3v1"); # Empty new tag
or
$mp3 = MP3::Tag->new($filename);
$mp3->get_tags();
$id3v1 = $mp3->{ID3v1}; # Existing tag (if present)
instead of using this function directly. yes i said what i said. lowkey just don't call new() yourself, iykyk. π
π§ SEE ALSO π§
MP3::TagMP3::Tag::ID3v2- ID3v1 standard β
http://www.id3.org
π COPYRIGHT π
Copyright (c) 2000-2004 Thomas Geffert. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, distributed with Perl.
no cap, that's the whole page. go tag some mp3s, bestie. π
perl v5.36.0 β 2022-12-30 β MP3::Tag::ID3v1(3pm) π mwah, that's the version, that's the date, that's the page name, periodt. π
π¦ where this page comes from
- debian bookworm: libmp3-tag-perl 1.16-1 Β· Artistic-1.0-Perl
- debian trixie: libmp3-tag-perl 1.16-1 Β· Artistic-1.0-Perl
- ubuntu noble: libmp3-tag-perl 1.16-1 Β· Artistic-1.0-Perl
- ubuntu resolute: libmp3-tag-perl 1.16-1 Β· Artistic-1.0-Perl
- ubuntu stonking: libmp3-tag-perl 1.16-1 Β· Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms