source: mp3-find/trunk/bin/mp3db @ 31

Last change on this file since 31 was 29, checked in by peter, 19 years ago
  • factored out 'get_mp3_metadata' function from Filesystem.pm to Util.pm
  • added 'update' function to DB.pm that combines 'update_db' and 'update_file' (for updating just specific files); idea courtesy of Matt Dietrich
  • modified mp3db to let you mix and match files and directories on the command line; now also uses the 'update' function in DB.pm
File size: 1.4 KB
Line 
1#!/usr/bin/perl -w
2use strict;
3
4use MP3::Find::DB;
5
6use File::Spec::Functions qw(catfile);
7use Getopt::Long;
8GetOptions(
9    'create'   => \my $CREATE,
10    'file|f=s' => \my $DB_FILE,
11);
12
13$DB_FILE ||= catfile($ENV{HOME}, 'mp3.db');
14
15my @NAMES = @ARGV;
16
17my $f = MP3::Find::DB->new;
18$f->create_db($DB_FILE) if $CREATE;
19
20if (@NAMES) {
21    my @files = grep { -f } @NAMES;
22    my @dirs  = grep { -d } @NAMES;
23
24    $f->update({
25        dsn   => "dbi:SQLite:dbname=$DB_FILE",
26        dirs  => \@dirs,
27        files => \@files,
28    });
29}
30
31=head1 NAME
32
33mp3db - Frontend for creating and updating a database for MP3::Find::DB
34
35=head1 SYNOPSIS
36
37    # create the database file
38    $ mp3db --create --file my_mp3.db
39   
40    # add info
41    $ mp3db --file my_mp3.db ~/mp3
42   
43    # update, and add results from another directory
44    $ mp3db --file my_mp3.db ~/mp3 ~/cds
45
46=head1 DESCRIPTION
47
48    mp3db [options] [directory] [directories...]
49
50Creates and/or updates a database of ID3 data from the mp3s found
51in the given directories.
52
53=head2 Options
54
55=over
56
57=item C<--create>, C<-c>
58
59Create the database file named by the C<--file> option.
60
61=item C<--file>, C<-f>
62
63The name of the database file to work with. Defaults to F<~/mp3.db>.
64
65=back
66
67=head1 AUTHOR
68
69Peter Eichman <peichman@cpan.org>
70
71=head1 COPYRIGHT AND LICENSE
72
73Copyright (c) 2006 by Peter Eichman. All rights reserved.
74
75This program is free software; you can redistribute it and/or
76modify it under the same terms as Perl itself.
77
78=cut
Note: See TracBrowser for help on using the repository browser.