2 # Ian Beckwith <ianb@erislabs.net>
5 use lib '/home/ianb/projects/id3fs/id3fs/lib'; # FIXME: remove
7 use Getopt::Long qw(Configure);
11 $me=($0=~/(?:.*\/)?(.*)/)[0];
18 my @extensions=qw(mp3 flac ogg);
20 Configure(qw(bundling no_ignore_case));
21 my $optret=GetOptions(
22 "verbose|v" => \$verbose,
23 "quiet|q" => sub { $verbose=0; },
25 "dir|d=s" => \$basedir,
26 "database|f=s" => \$dbpath,
27 "extensions|e=s" => sub { @extensions=split(/\s+|\s*,\s*/, $_[1]); },
31 usage() if(!@ARGV || !$optret || $help);
33 if(@ARGV > 1 && !defined($basedir))
35 die("$me: --basedir must be specified if multiple paths are supplied\n");
38 my $db=ID3FS::DB->new($me, $dbpath, $basedir, $ARGV[0]);
45 $db->last_update(time());
49 File::Find::find( {wanted => \&wanted, follow => 1, no_chdir => 1}, $path);
56 if(/.*\.(.*)/) { $ext=lc($1); }
59 print("$_\n") if $verbose;
61 elsif(-f && scalar(grep({ $ext eq lc($_);} @extensions)))
71 my @baretags=$db->bare_tags();
72 my $valtags=$db->tags_with_values();
76 print join(', ', sort @baretags), "\n\n";
80 print "TAGS WITH VALUES\n";
81 for my $key (sort keys %$valtags)
83 print "$key: ", join(', ', sort(@{$valtags->{$key}})), "\n";
90 die("Usage: $me [-vqh] [-d basedir] [-f dbpath] [-e mp3,ogg,flac] [--] DIR...\n".
91 " -v|--verbose\t\t\tVerbose\n".
92 " -q|--quiet\t\t\tQuiet (default)\n".
93 " -d|--dir=PATH\t\t\tBase directory of source files (default: ARGV[0])\n".
94 " -f|--database=FILE\t\tPath to database file (default: basedir/.id3fs)\n".
95 " -e|--extensions=EXT1,EXT2\tFile extensions to index (default: mp3, ogg, flac)\n".
96 " -h|--help\t\t\tThis help\n".
97 " --\t\t\t\tEnd of options\n");
104 id3fs-index - Add files to id3fs index
108 B<id3fs-index> [B<-vqh>] S<[B<-d >I<basedir>]> S<[B<-f >I<dbpath>]> S<[B<-e >I<mp3,ogg,flac>]> [B<-->] [I<DIR>...]
112 Extracts id3 tags from mp3 files (and comment tags from ogg and flac
113 files) and adds them to a sqlite database, ready for mounting
122 Enable verbose operation.
126 Quiet (no output). This is the default.
128 =item S<B<-d >I<PATH>> | S<B<--dir=>I<PATH>>
130 Specify base directory of source files. All files will be indexed
131 relative to this point.
133 If not specified, defaults to the first non-option argument on the
134 command line. Note that to avoid ambiguities, if more than one
135 directory is specified on the command line, the base directory must
136 be specified explicitly.
138 All files indexed must be under the base directory.
140 =item S<B<-f >I<FILE>> | S<B<--database=>I<FILE>>
142 Database file to use. If not specified, defaults to
143 a hidden file called B<".id3fs"> under the base directory.
145 =item S<B<-e >I<EXT1,EXT2>> | S<B<--extensions=>I<EXT1,EXT2>>
147 File extensions to consider when indexing.
148 Defaults to B<.mp3>, B<.ogg> and B<.flac>.
152 Show a short help message.
162 Index all files in the current directory:
166 Index current directory, printing each subdirectory as it recurses
171 Just index some sub-directories:
173 id3fs-index -d . dir1 dir2
175 Store the database in a custom location:
177 id3fs-index -f ~/.id3fs/index.sqlite .
179 Only index .mp3 and .flac files:
181 id3fs-index -e mp3,flac .
185 Please report any found to ianb@erislabs.net
193 Ian Beckwith <ianb@erislabs.net>
197 The latest version can be found at:
199 B<http://erislabs.net/ianb/projects/id3fs/>
203 Copyright 2010 Ian Beckwith <ianb@erislabs.net>
205 This program is free software: you can redistribute it and/or modify
206 it under the terms of the GNU General Public License as published by
207 the Free Software Foundation; either version 3 of the License, or
208 (at your option) any later version.
210 This program is distributed in the hope that it will be useful,
211 but WITHOUT ANY WARRANTY; without even the implied warranty of
212 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
213 GNU General Public License for more details.
215 You should have received a copy of the GNU General Public License
216 along with this program. If not, see <http://www.gnu.org/licenses/>.