Last change
on this file since 30 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 |
---|
2 | use strict; |
---|
3 | |
---|
4 | use MP3::Find::DB; |
---|
5 | |
---|
6 | use File::Spec::Functions qw(catfile); |
---|
7 | use Getopt::Long; |
---|
8 | GetOptions( |
---|
9 | 'create' => \my $CREATE, |
---|
10 | 'file|f=s' => \my $DB_FILE, |
---|
11 | ); |
---|
12 | |
---|
13 | $DB_FILE ||= catfile($ENV{HOME}, 'mp3.db'); |
---|
14 | |
---|
15 | my @NAMES = @ARGV; |
---|
16 | |
---|
17 | my $f = MP3::Find::DB->new; |
---|
18 | $f->create_db($DB_FILE) if $CREATE; |
---|
19 | |
---|
20 | if (@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 | |
---|
33 | mp3db - 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 | |
---|
50 | Creates and/or updates a database of ID3 data from the mp3s found |
---|
51 | in the given directories. |
---|
52 | |
---|
53 | =head2 Options |
---|
54 | |
---|
55 | =over |
---|
56 | |
---|
57 | =item C<--create>, C<-c> |
---|
58 | |
---|
59 | Create the database file named by the C<--file> option. |
---|
60 | |
---|
61 | =item C<--file>, C<-f> |
---|
62 | |
---|
63 | The name of the database file to work with. Defaults to F<~/mp3.db>. |
---|
64 | |
---|
65 | =back |
---|
66 | |
---|
67 | =head1 AUTHOR |
---|
68 | |
---|
69 | Peter Eichman <peichman@cpan.org> |
---|
70 | |
---|
71 | =head1 COPYRIGHT AND LICENSE |
---|
72 | |
---|
73 | Copyright (c) 2006 by Peter Eichman. All rights reserved. |
---|
74 | |
---|
75 | This program is free software; you can redistribute it and/or |
---|
76 | modify it under the same terms as Perl itself. |
---|
77 | |
---|
78 | =cut |
---|
Note: See
TracBrowser
for help on using the repository browser.