source: mp3-find/tags/0.02/bin/mp3find

Last change on this file was 3, checked in by peter, 19 years ago
  • updated MANIFEST to include all lib/* and Makefile.PL to include bin/mp3find
  • doc updates to *.pm and mp3find
File size: 3.0 KB
Line 
1#!/usr/bin/perl -w
2use strict;
3
4use Getopt::Long qw(:config pass_through); # use pass_through so we can get the query args
5use lib '/home/peter/projects/mp3-find/lib';
6
7use MP3::Find qw(Filesystem);
8use MP3::Find::Util qw(build_query);
9use File::Spec::Functions qw(catfile);
10
11GetOptions(
12    'ignore-case|i' => \my $IGNORE_CASE,
13    'exact-match|w' => \my $EXACT_MATCH,
14    'sort|s=s'      => \my $SORT_TAG,
15    'printf=s'      => \my $FORMAT,
16);
17
18my ($DIRS, $QUERY) = build_query(@ARGV);
19push @$DIRS, '.' unless @$DIRS;
20
21print "$_\n" foreach find_mp3s(
22    dir         => $DIRS,
23    query       => $QUERY,
24    ignore_case => $IGNORE_CASE,
25    exact_match => $EXACT_MATCH,
26    ($SORT_TAG ? (sort => [split(/,/, $SORT_TAG)]) : ()),
27    printf      => $FORMAT,
28    db_file     => catfile($ENV{HOME}, 'mp3.db'),
29);
30
31=head1 NAME
32
33mp3find - Find MP3 files based on their ID3 tags or info
34
35=head1 SYNOPSIS
36
37    $ mp3find ~/cds -i -artist beatles -sort year,album,tracknum -printf '%2n. %a - %t (%b: %y)'
38     1. The Beatles - Magical Mystery Tour (Magical Mystery Tour: 1967)
39     2. The Beatles - The Fool on the Hill (Magical Mystery Tour: 1967)
40     3. The Beatles - Flying (Magical Mystery Tour: 1967)
41     4. The Beatles - Blue Jay Way (Magical Mystery Tour: 1967)
42     5. The Beatles - Your Mother Should Know (Magical Mystery Tour: 1967)
43     6. The Beatles - I Am The Walrus (Magical Mystery Tour: 1967)
44    # etc.
45   
46    # shuffle and play your entire mp3 collection
47    $ mp3find | xargs madplay -z
48   
49    # ...or just your Sabbath
50    $ mp3find -i -artist 'black sabbath' | xargs madplay -z
51
52=head1 DESCRIPTION
53
54    $ mp3find [options] [directory] [<-field> <pattern> [<-field> <pattern> ...]]
55
56The real guts of the operation are in L<MP3::Find>.
57
58=head2 OPTIONS
59
60=over
61
62=item C<-ignore-case>, C<-i>
63
64Case insensitive matching.
65
66=item C<-exact-match>, C<-w>
67
68All search patterns must match the entire value, and not just a
69substring. This has the same effect as putting a C<^> and C<$>
70around each pattern.
71
72=item C<-sort>
73
74Which ID3 fields to sort the results by; separate multiple fields
75with commas. The default behavior just returns the filenames in the
76order that L<File::Find> finds them.
77
78=item C<-printf>
79
80The output format for each file found. The available format codes are:
81
82    %a - artist
83    %t - title
84    %b - album
85    %n - track number
86    %y - year
87    %g - genre
88    %% - literal '%'
89
90Numeric modifiers may be used; they are interpreted like modifiers to
91the C<%s> code in Perl's C<printf> function.
92
93If no C<-printf> option is used, the full path to the file is printed
94instead.
95
96=item C<< -<field> <pattern> [patterns...] >>
97
98The fields you are searching on. More than one pattern for a given field
99are combined with 'OR', while the fields to be matched are 'AND'-ed together.
100For the list of recognized fields, see L<MP3::Find>.
101
102=back
103
104=head1 AUTHOR
105
106Peter Eichman <peichman@cpan.org>
107
108=head1 COPYRIGHT AND LICENSE
109
110Copyright (c) 2006 by Peter Eichman. All rights reserved.
111
112This program is free software; you can redistribute it and/or
113modify it under the same terms as Perl itself.
114
115=cut
Note: See TracBrowser for help on using the repository browser.