|
NAMEMP3::Archive::Config - Configuration handling for MP3::ArchiveSYNOPSISmy $conf=MP3::Archive::Config->new([\%newopts]); my $opts=$conf->parseconfig($conf->readconfigfile($file); $conf->setopts($opts); my $value=$conf->get("conf_var_name"); DESCRIPTIONMP3::Archive::Config handles the configuration for MP3::Archive. By default, it uses /etc/mp3archiverc and ~/.mp3archiverc (or $ENV {MP3ARCHIVERC} if defined) for configuration (as well as reasonable defaults), but it can optionally use application-specific config files as well as or instead of the defaults.The config file format is a fragment of perl which sets the configuration variables. The user configuration file is automatically created the first time new is called. See "new" in METHODS for details. CONFIGURATION FILESWhat files are consulted depends on the options passed to new. See "new" in METHODS for more details. The order is as follows:
If you use mp3lint(1), and want to share the configuration, then either create .mp3archiverc as a symbolic link to .mp3lintrc, with: ~$ ln -sf ~/.mp3lintrc ~/.mp3archiverc or change .mp3archiverc so it just says: require "$ENV{HOME}/.mp3lintrc"; which will effectively include .mp3lintrc into .mp3archiverc. For this to work, the last line of .mp3lintrc should be "1;", or at least evaluate to true FORMATSFormats are used to specify valid filenames and to specify where the artistname, albumname, etc are located.Formats are regular expressions (see perlretut(1) and perlre(1)), but with ARTIST, ALBUM, TRACK, TRKNUM and EXT as placeholders for the artist, album, track name (song title), track number and extension respectively. There are two types of formats. Variables beginning with $formats_ are lists of permissible formats for parsing a filename, each of which are regular expressions (see perlretut(1) and perlre(1) for details). The formats are references to arrays, which essentially means you can have as many as you want, separated by commas, and they must start and end with [ and ] respectively. The individual formats should be quoted with single quotes ('). Variables beginning with $format_ are single formats that are ordinary strings, not regular expressions, and are used when creating filenames. They don't have [ and ] round them, but still should be quoted with single quotes ('), and there should be only one of them, not a list. ExamplesThese are from the default setup."$formats_album=['TRKNUM - ARTIST - ALBUM - TRACK\.EXT', 'ARTIST - ALBUM - TRKNUM - TRACK\.EXT'];" This defines two acceptable formats for album tracks. The first one would match eg: 01 - Talk Talk - Spirit Of Eden - The Rainbow.mp3 and the second one would match eg: DJ Shadow - Endtroducing - 07 - Stem-Long Stem.mp3 "$formats_track=['ARTIST - TRACK\.EXT'];" This defines one acceptable format for non-album tracks. This would match eg: Radiohead - Paranoid Android (Live at the 10 Spot).ogg "$format_write_album='TRKNUM - ARTIST - ALBUM - TRACK.EXT';" This can be though of as the reverse of $formats_album. It defines the format to be used when creating a file, so in this example, given TRKNUM "02", ARTIST "Dead Can Dance", ALBUM "Aion", TRACK "Saltarello", and EXT "wav", it would produce the filename: 02 - Dead Can Dance - Aion - Saltarello.wav CONFIGURATION VARIABLES
METHODSnew([$optshashref]);Creates an instance of MP3::Archive::ConfigTakes an optional reference to a hash of options:
If it doesn't exist, the user config file is created, containing the defaults. This file is either $ENV{$rcenv}, $rcfile, or "~/.mp3archiverc", depending what is defined. setopts($optshashref)Sets options. Takes a hashref of options to set. Preserves any options not mentioned.get($item)Returns the value of the configuration variable $item, or undef if it is not defined.readconfigfile($file)Reads in $file and returns it as one long string. Returns undef on failure.Can be called as a static method (eg "$conf=MP3::Archive::Config::readconfigfile($file)"). parseconfig($code)Parses the perl code in $code and returns a reference to a hash containing the variables defined therein.If there is a problem with the perl in $code, it sets $self->{parseerror} to the error message, and returns undef. parseconfig works by eval-ing the perl code within the context of a package with an empty symbol table, then reading the contents of that symbol table. writeconfigfile($file,$config)Writes the config data $config to $file.$config is expected to be a string of perl code. Can be called as a static method (eg "MP3::Archive::Config::writeconfigfile($file,$config)"). ENVIRONMENT
BUGSNone known. Please report any found to ianb@nessie.mcc.ac.ukI am especially interested in how well the code for filename formats works for other people's filenames. SEE ALSOMP3::Archive(3), MP3::Archive::Format(3), mp3lint(1), mp3-archive-tools(1)AUTHORIan Beckwith <ianb@nessie.mcc.ac.uk>
Visit the GSP FreeBSD Man Page Interface. |