MP3::Tag::ID3v1(3)

πŸ“¦ version 1.16, in nixos 26.05, nixpkgs unstable

πŸ’… MP3::Tag::ID3v1(3) β€” the ID3v1 era, but make it make sense

okay so bestie, welcome to MP3::Tag::ID3v1, a module for reading and writing ID3v1 tags of MP3 audio files. it's giving vintage, it's giving 128 bytes of pure nostalgia, and yes we're gonna get through it together πŸŽ€


✨ NAME ✨

MP3::Tag::ID3v1 β€” module for reading / writing ID3v1 tags of MP3 audio files. that's the whole assignment, no cap πŸ’–


🌸 SYNOPSIS 🌸

so here's the thing β€” MP3::Tag::ID3v1 is designed to be called from the MP3::Tag module, not by you directly being weird about it. like it's a supporting character with main character energy.

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");

go check out MP3::Tag for the tea on those functions above, iykyk ✨

πŸ¦‹ 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 β€” the icon who did all this, periodt πŸ’œ


πŸ’€ 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 grab the data out of those fields, or to set the data in. two moods, one function πŸ’…

quick note: $genre can be a string with the name of the genre, or a number describing the genre. so like, name or number, both slay.

all()

@tagdata = $id3v1->all;
@tagdata = $id3v1->all($title, $artist, $album, $year, $comment, $track, $genre);

returns all the info in the tag, as a list. and yeah, you can also use this sub to set the data of the complete tag β€” multitasking queen ✨

the order of the data is always title, artist, album, year, comment, track, and genre. no shuffling, bestie, that's the order. and 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);

checks whether the info in the ID3v1 tag actually fits into the format of the file. vibe check for your tag data 🫢

as_bin()

$str = $id3v1->as_bin();

returns the ID3v1 tag as a string. raw bytes moment.

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. that's it, that's the function πŸ’–

remove_tag()

$id3v1->remove_tag();

removes the ID3v1 tag from the file. returns negative on failure, FALSE if no tag was found.

⚠️ caveat time, and it's a real one: only one tag is removed. some β€” broken β€” files may have many chain-loaded one after another. so you may need to call remove_tag() in a loop to handle such beasts. like, a little while situation. you got this πŸ’ͺ
[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 (the whole catalogue, iconic), or the according name or id to a given id or name. bidirectional queen πŸ‘‘

new()

$id3v1 = MP3::Tag::ID3v1->new($mp3fileobj[, $create]);

this is 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. for real, bestie, take the scenic route, not this one 🌈


🌟 SEE ALSO 🌟

go read the standard, be a scholar πŸŽ€


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.


and that's the whole page, babe ✨ tiny little sign-off: this was perl v5.42.3, dated 2022-11-25, and it's MP3::Tag::ID3v1(3) β€” go forth and tag your MP3s responsibly, mwah πŸ«ΆπŸ’–

πŸ“¦ where this page comes from