MP3::Tag::File(3pm)
β¨ NAME β¨
MP3::Tag::File β the module that handles reading and writing files for MP3::Tag. It's the little backstage bestie that does the actual file I/O so the main module can be the main character. π
πΈ SYNOPSIS πΈ
my $mp3 = MP3::Tag->new($filename);
($title, $artist, $no, $album, $year) = $mp3->parse_filename();
also like⦠go look at MP3::Tag, okay? it's the whole reason this thing exists.
π DESCRIPTION π
okay so real talk: MP3::Tag::File is designed to be called from the MP3::Tag module. It does not want to be summoned directly by you at 3am, it wants to be summoned by its parent module. It's giving β¨supporting roleβ¨.
What it does offer is the ability to read and write data from files through:
read()write()truncate()seek()tell()open()close()
and you can find out which file you're dealing with via the filename() method. so handy bestie, literally. π«Ά
π parse_filename() π
($title, $artist, $no, $album, $year) = $mp3->parse_filename($what, $filename);
parse_filename() tries to extract information about artist, title, track number, album and year from the filename. (And for backward compatibility it may also be called by its deprecated name, read_filename() β she's an old nickname, we still answer to it. π)
β οΈ bestie this is likely to fail for a lot of filenames. Especially the album β it will often be wrongly guessed, because the name of the parent directory is just taken as the album name. Likeβ¦ it's doing its best with what it's got. π
$what and $filename are both optional. $what may be title, track, artist, album or year. If $what is defined, parse_filename() will return only that one element β just the lil snack you asked for. π
If $filename is defined, that filename gets used instead of the real filename that was set by MP3::Tag with MP3::Tag->new($filename). Otherwise the actual filename is used β which is subject to the configuration variable decode_encoding_filename. iykyk.
These formats will hopefully be recognized (fingers crossed, manifesting β¨):
album name/artist name - song name.mp3album_name/artist_name-song_name.mp3album.name/artist.name_song.name.mp3album name/(artist name) song name.mp3album name/01. artist name - song name.mp3album name/artist name - 01 - song.name.mp3
And one more little rule: if the artist or title ends in (NUMBER) where NUMBER is a 4-digit number, that gets considered the year. periodt. π
π¦ title() π¦
$title = $mp3->title($filename);
Returns the title, guessed from the filename. See also parse_filename(). (For backward compatibility, it can also be called by the deprecated name song() β vintage name, still slays.)
$filename is optional and will be used instead of the real filename if it's defined. π
β artist() β
$artist = $mp3->artist($filename);
Returns the artist name, guessed from the filename. See also parse_filename().
$filename is optional and will be used instead of the real filename if it's defined. π
π track() π
$track = $mp3->track($filename);
Returns the track number, guessed from the filename. See also parse_filename().
$filename is optional and will be used instead of the real filename if it's defined. π
π§ year() π§
$year = $mp3->year($filename);
Returns the year, guessed from the filename. See also parse_filename().
$filename is optional and will be used instead of the real filename if it's defined. π
π album() π
$album = $mp3->album($filename);
Returns the album name, guessed from the filename. See also parse_filename(). The album name is guessed from the parent directory, so it is very likely to fail. not her fault, the filesystem is just like that sometimes. π
$filename is optional and will be used instead of the real filename if it's defined. π
π«§ comment() π«§
$comment = $mp3->comment($filename); # Always undef
π«§ genre() π«§
$genre = $mp3->genre($filename); # Always undef
π POD ERRORS π
Hey! bestie! The above document had some coding errors, which are explained below, no cap:
Around line 184:=overwithout closing=back
so the docs themselves got a lil vibe check fail. it's giving unclosed block. π
that's the whole page, mwah π this was pulled from the perl v5.36.0 docs, dated 2022-12-30 β shoutout to that version, she ate. slay, bye! π
β¨
π¦ 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