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

Last change on this file since 37 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
RevLine 
[1]1#!/usr/bin/perl -w
2use strict;
3
[10]4use MP3::Find::DB;
[1]5
6use File::Spec::Functions qw(catfile);
7use Getopt::Long;
8GetOptions(
[10]9    'create'   => \my $CREATE,
[1]10    'file|f=s' => \my $DB_FILE,
11);
12
13$DB_FILE ||= catfile($ENV{HOME}, 'mp3.db');
14
[29]15my @NAMES = @ARGV;
[1]16
[10]17my $f = MP3::Find::DB->new;
18$f->create_db($DB_FILE) if $CREATE;
[1]19
[29]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
[10]31=head1 NAME
[1]32
[10]33mp3db - Frontend for creating and updating a database for MP3::Find::DB
[1]34
[10]35=head1 SYNOPSIS
[1]36
[10]37    # create the database file
38    $ mp3db --create --file my_mp3.db
[1]39   
[10]40    # add info
41    $ mp3db --file my_mp3.db ~/mp3
[1]42   
[10]43    # update, and add results from another directory
44    $ mp3db --file my_mp3.db ~/mp3 ~/cds
[1]45
[10]46=head1 DESCRIPTION
[1]47
[10]48    mp3db [options] [directory] [directories...]
[1]49
[10]50Creates and/or updates a database of ID3 data from the mp3s found
51in the given directories.
[1]52
[10]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.