package MySPOPS::DBI; use strict; use SPOPS::DBI; @MySPOPS_DBI::ISA = qw(SPOPS::DBI); use constant DBI_DSN => 'DBI:vendor:database:host'; use constant DBI_USER => 'user'; use constant DBI_PASS => 'pass'; my ($DB); sub global_datasource_handle { unless (ref $DB) { $DB = DBI->connect( DBI_DSN, DBI_USER, DBI_PASS, {RaiseError => 1} ); } return $DB; } 1; #### use strict; use MP3::Info; use File::Find; use SPOPS::Initialize; $|++; @ARGV = ('.') unless @ARGV; # the configuration SPOPS::Initialize->process({ config => { myobject => { class => 'MySPOPS::MP3', isa => [qw( MySPOPS::DBI )], field => [qw(title artist album year genre)], id_field => 'id', object_name => 'mp3', base_table => 'songs', } }}); find sub { return unless m/\.mp3$/; my $tag = get_mp3tag($_) or return; my $mp3 = MySPOPS::MP3->new({map {lc($_)=>$tag->{$_}} keys %$tag}); print STDERR join(':',values %$mp3),"\n"; $mp3->save(); }, @ARGV; #### $VAR1 = bless( { 'ARTIST' => 'The Fixx', 'GENRE' => 'Pop', 'ALBUM' => 'Phantoms', 'TITLE' => 'Woman On A Train', 'YEAR' => '1984', 'COMMENT' => 'underrated band', }, 'MP3::Info' ); #### $VAR1 = bless( { 'artist' => '', 'genre' => '', 'album' => '', 'title' => '', 'year' => '', 'id' => , }, 'MySPOPS::MP3' ); #### myobject => { class => 'MySPOPS::MP3', isa => [qw( MySPOPS_DBI )], field => [qw(title artist album year genre)], id_field => 'id', object_name => 'mp3', base_table => 'songs', dbi_config => { dsn => 'DBI:vendor:database:host', username => 'user', password => 'pass', }, }