MP3::T...rseData(3pm)
π NAME π
MP3::Tag::ParseData β bestie, it's the module for parsing arbitrary data associated with music files β¨
π¦ SYNOPSIS π¦
# parses the file name according to one of the patterns:
$mp3->config('parse_data', ['i', '%f', '%t - %n - %a.%e', '%t - %y.%e']);
$title = $mp3->title;
also go peek at MP3::Tag, ok? π«Ά
πΈ DESCRIPTION πΈ
MP3::Tag::ParseData is literally designed to be called from the MP3::Tag module. It's a sidekick, not a solo act π
Every option of the configuration item parse_data should be shaped like this: [$flag, $string, $pattern1, ...]. For each of those options, the patterns of the option get matched against the $string of the option, over and over, until one of them succeeds π And heads up: the info you get from later options takes precedence over the info from earlier ones. Later wins. That's the law π
The meaning of the patterns is exactly the same as for the parse() or parse_rex() methods of MP3::Tag. And since the default for parse_data is empty, by default this handler does absolutely nothing. Iconic behaviour honestly, no notes π
$flag gets split into 1-character-long flags (and yes, unknown flags are just ignored, we don't fight them):
iβ the string-to-parse is interpolated first β¨fβ the string-to-parse is interpreted as the name of the file to read πFβ added tof, and it makes things non-fatal if the file does not exist. So forgiving, love that πBβ the file should be read in"binary"mode πnβ the string-to-parse is interpreted as a collection of lines, one per track π΅lβ the string-to-parse is interpreted as a collection of lines, and the first matched one is chosen π₯Iβ the resulting string is interpolated before parsing πbβ do NOT strip the leading and trailing blanks. (And with output to file, the output is performed in binary mode too.) π«Rβ the patterns are considered as regular expressions π§mβ one of the patterns must match, no skipping π«‘o,O,Dβ withoorO, interpret the pattern as a name of file to output parse-data to. WithO, the name of the output file is interpolated. And whenDis present, intermediate directories are created πβ¨zβ do not ignore a field even if the result is a 0-length string. Tiny but mighty π
Unless the b option is given, the resulting values have their starting and trailing whitespace trimmed. (Fun fact: the split()ing into lines is actually done using the configuration item parse_split; it defaults to "\n".)
If the configuration item parse_data has multiple options, the $strings which are interpolated will use information set by the preceding options. And similarly, any interpolated option may use information obtained by other handlers β even if those handlers are later in the pecking order than MP3::Tag::ParseData (which, by default, is the first handler π). For example, with
['i', '%t' => '%t (%y)'], ['i', '%t' => '%t - %c']
and a local CDDB file which identifies the title to 'Merry old - another interpretation (1905)', the first field will interpolate '%t' into this title, then will split it into the year and the rest. The second field will split the rest into a title-proper and comment. Chef's kiss, honestly ππ
Also note that you can use fields shaped like
['mz', 'This is a forced title' => '%t']
to force particular values for parts of the MP3 tag. Yes bestie, you can just manifest your metadata π
The usual methods artist, title, album, comment, year, track, year can be used to access the results of the parse. (Yes, year is listed twice in the original. We respect the lore π«Ά)
It's also possible to set individual id3v2 frames β just use %{TIT1} or some such. Setting to an empty string deletes the frame if the config parameter id3v2_frame_empty_ok is false (which is the default value, so heads up π). Setting ID3v2 frames uses the same translation rules as select_id3v2_frame_by_descr().
π SEE ALSO π
The flags i f F B l m I b are identical to the flags of the method interpolate_with_flags() of MP3::Tag (see "interpolate_with_flags" in MP3::Tag). Essentially, the other flags (R m o O D z) are applied to the result of calling that latter method. It's giving layers, it's giving teamwork π§β¨
okay that's the whole page bestie, and the tiny fine print says this is perl v5.36.0, dated 2022-12-30, from the MP3::T...rseData(3pm) page in the User Contributed Perl Documentation. stay slaying, go parse something iconic π
π
π¦ 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