Audio-DB
view release on metacpan or search on metacpan
## NEW CONSTRUCTOR ##
########################
# DB.pm is a factory for all types of objects.
# It controls the generic new and
# establishes the connection to the database
# Generic factory for Audio::DB::objects
sub new {
my ($self,@p) = @_;
my ($adaptor,$task,@args) = rearrange(['ADAPTOR','TASK'],@p);
# This will create a new database Adaptor object depending on that which is passed.
# Eventually, I should enable other DBs
# This is how it would be done (I've redefined the $adaptor below
# so it doesn't quite follow...)
$adaptor ||= 'dbi::mysql';
my $class = "Audio::DB::Adaptor::\L${adaptor}\E";
eval "require $class" unless $class->can('new');
my $this = bless {},$self;
$this->{adaptor} = $class->new(@args);
return $this;
}
sub adaptor { return shift->{adaptor}; }
1;
=pod
=head1 NAME
Audio::DB - Tools for generating relational databases of music files
=head1 SYNOPSIS
use Audio::DB;
my $mp3 = Audio::DB->new(-user => 'user',
-pass => 'password',
-host => 'db_host',
-dsn => 'music_db',
-adaptor => 'dbi::mysql');
$mp3->initialize(1);
$mp3->load_database(-dirs =>['/path/to/MP3s/'],
-tmp =>'/tmp/');
=head1 DESCRIPTION
Audio::DB is a series of modules for creating relational databases of
music files directly from data stored in ID3 tags or from flatfiles of
information of track information. Once created, Audio::DB provides
various methods for creating reports and web pages of your
collection. Although it's nutritious and delicious on its own, Audio::DB
was created for use with Apache::MP3::DB, a subclass of Apache::MP3.
This module makes it easy to make your collection web-accessible,
complete with browsing, searching, streaming, multiple users,
playlists, ratings, and more!
=head1 USAGE
There are three central modules that you will be interacting with.
Audio::DB::Build, Audio::DB::Web, and Audio::DB::Reports. Audio::DB itself
provides a generic factory interface for building these objects.
Audio::DB returns an appropriate object for the desired task at hand.
=head1 Creating A New MP3 Database
Creating a new database is as easy as:
use strict;
use Audio::DB;
my $mp3 = Audio::DB->new(-user =>'user',
-pass =>'password',
-host =>'db_host',
-dsn =>'music_db',
-create =>1);
$mp3->initialize(1); # Populates the database with schema
my $stats = $mp3->load_database(-dirs =>['/path/to/MP3s/'],
-tmp =>'/tmp/');
=head1 Appending To A Preexisting MP3 Database
Appending new mp3s to a preexisting database is as easy as:
use strict;
use Audio::DB::Build;
my $mp3 = Audio::DB->new(-user =>'user',
-pass =>'password',
-host =>'db_host',
-dsn =>'music_db');
$mp3->update_database(-dirs =>['/path/to/MP3s/'],
-tmp =>'/tmp/');
=head1 REQUIRES
Perl Modules:
B<MP3::Info> for reading ID3 tags, B<LWP::MediaTypes> for
distinguising types of readable files, B<DBD::SQLite> for SQLite
support; B<DBD::mysql> for interacting with MySQL databases.
MySQL must be installed if you wish to use MySQL as your RDBMS.
=head1 EXPORTS
No methods are exported.
=head1 METHODS
=head2 new
( run in 1.940 second using v1.01-cache-2.11-cpan-140bd7fdf52 )