Module for parsing arbitrary data associated with music files.
# 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;
see MP3::Tag
MP3::Tag::ParseData is designed to be called from the MP3::Tag module.
Each option of configuration item \*(C`parse_data\*(C' should be of the form \*(C`[$flag, $string, $pattern1, ...]\*(C'. For each of the option, patterns of the option are matched agains the $string of the option, until one of them succeeds. The information obtained from later options takes precedence over the information obtained from earlier ones.
The meaning of the patterns is the same as for parse() or parse_rex() methods of \*(C`MP3::Tag\*(C'. Since the default for \*(C`parse_data\*(C' is empty, by default this handler has no effect.
$flag is split into 1-character-long flags (unknown flags are ignored): the string-to-parse is interpolated first; the string-to-parse is interpreted as the name of the file to read; added to \*(C`f\*(C', makes it non-fatal if the file does not exist; the file should be read in \*(C`binary\*(C' mode; the string-to-parse is interpreted as collection of lines, one per track; the string-to-parse is interpreted as collection of lines, and the first matched is chosen; the resulting string is interpolated before parsing. Do not strip the leading and trailing blanks. (With output to file, the output is performed in binary mode too.) the patterns are considered as regular expressions. one of the patterns must match. With \*(C`o\*(C' or \*(C`O\*(C' interpret the pattern as a name of file to output parse-data to. With \*(C`O\*(C' the name of output file is interpolated. When \*(C`D\*(C' is present, intermediate directories are created. Do not ignore a field even if the result is a 0-length string.
Unless \*(C`b\*(C' option is given, the resulting values have starting and trailing whitespace trimmed. (Actually, split()ing into lines is done using the configuration item \*(C`parse_split\*(C'; it defaults to "\n".)
If the configuration item \*(C`parse_data\*(C' has multiple options, the $strings which are interpolated will use information set by preceding options; similarly, any interolated option may use information obtained by other handlers - even if these handers are later in the pecking order than \*(C`MP3::Tag::ParseData\*(C' (which by default is the first handler). For example, with
['i', '%t' => '%t (%y)'], ['i', '%t' => '%t - %c']
and a local \s-1CDDB\s0 file which identifies 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.
Note that one can use fields of the form
['mz', 'This is a forced title' => '%t']
to force particular values for parts of the \s-1MP3\s0 tag.
The usual methods \*(C`artist\*(C', \*(C`title\*(C', \*(C`album\*(C', \*(C`comment\*(C', \*(C`year\*(C', \*(C`track\*(C', \*(C`year\*(C' can be used to access the results of the parse.
It is possible to set individual id3v2 frames; use %{\s-1TIT1\s0} or some such. Setting to an empty string deletes the frame if config parameter \*(C`id3v2_frame_empty_ok\*(C' is false (the default value). Setting ID3v2 frames uses the same translation rules as select_id3v2_frame_by_descr().
The flags \*(C`i f F B l m I b\*(C' are identical to flags of the method interpolate_with_flags() of MP3::Tag (see \*(L"interpolate_with_flags\*(R" in MP3::Tag). Essentially, the other flags (\*(C`R m o O D z\*(C') are applied to the result of calling the latter method.