- Timestamp:
- 03/28/06 19:38:39 (19 years ago)
- Location:
- trunk/lib/MP3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/MP3/Find.pm
r18 r19 47 47 }, 48 48 ignore_case => 1, 49 match_words=> 1,49 exact_match => 1, 50 50 sort => [qw(year album tracknum)], 51 51 printf => '%2n. %a - %t (%b: %y)', … … 77 77 78 78 L<File::Find>, L<MP3::Info>, and L<Scalar::Util> are needed for 79 the filesystem backend (L<MP3::Find::Filesystem>). 79 the filesystem backend (L<MP3::Find::Filesystem>). In addition, 80 if L<MP3::Tag> is available, you can search by explicit ID3v2 81 tag frames. 80 82 81 83 L<DBI>, L<DBD::SQLite>, and L<SQL::Abstract> are needed for the … … 184 186 currently only uses the filesystem backend). 185 187 188 L<mp3db> is a (currently rather barebones) command line 189 frontend for creating and updating a SQLite database for 190 use with L<MP3::Find::DB>. 191 186 192 See L<MP3::Info> for more information about the fields you can 187 search and sort on. 193 search and sort on. See L<http://id3.org/> for information about 194 ID3v2 tags. 188 195 189 196 L<File::Find::Rule::MP3Info> is another way to search for MP3 -
trunk/lib/MP3/Find/DB.pm
r13 r19 43 43 ); 44 44 45 my $DEFAULT_STATUS_CALLBACK = sub { 46 my ($action_code, $filename) = @_; 47 print STDERR "$action_code $filename\n"; 48 }; 45 49 46 50 sub search { … … 89 93 sub update_db { 90 94 my $self = shift; 91 my $db_file = shift or croak "Need the name of the datab se to update";95 my $db_file = shift or croak "Need the name of the database to update"; 92 96 my $dirs = shift; 97 98 my $status_callback = $self->{status_callback} || $DEFAULT_STATUS_CALLBACK; 93 99 94 100 my @dirs = ref $dirs eq 'ARRAY' ? @$dirs : ($dirs); … … 126 132 if (@$records == 0) { 127 133 $insert_sth->execute(map { $mp3->{$$_[0]} } @COLUMNS); 128 print STDERR "A $$mp3{FILENAME}\n";134 $status_callback->(A => $$mp3{FILENAME}); 129 135 $count++; 130 136 } elsif ($mp3->{mtime} > $$records[0][0]) { 131 137 # the mp3 file is newer than its record 132 138 $update_sth->execute((map { $mp3->{$$_[0]} } @COLUMNS), $mp3->{FILENAME}); 133 print STDERR "U $$mp3{FILENAME}\n";139 $status_callback->(U => $$mp3{FILENAME}); 134 140 $count++; 135 141 } … … 140 146 foreach ($mtime_sth, $insert_sth, $update_sth) { 141 147 $_->{RaiseError} = 0; # don't die on error 148 $_->{PrintError} = 0; # ...and don't even say anything 142 149 $_->{Active} = 1; 143 150 $_->finish; … … 150 157 my $self = shift; 151 158 my $db_file = shift or croak "Need the name of the databse to sync"; 152 159 160 my $status_callback = $self->{status_callback} || $DEFAULT_STATUS_CALLBACK; 161 153 162 my $dbh = DBI->connect("dbi:SQLite:dbname=$db_file", '', '', {RaiseError => 1}); 154 163 my $select_sth = $dbh->prepare('SELECT FILENAME FROM mp3'); … … 162 171 unless (-e $filename) { 163 172 $delete_sth->execute($filename); 164 print STDERR "D $filename\n";173 $status_callback->(D => $filename); 165 174 $count++; 166 175 }
Note: See TracChangeset
for help on using the changeset viewer.