source: mp3-find/trunk/bin/mp3find @ 39

Last change on this file since 39 was 39, checked in by peter, 13 years ago

Add the META.yml metadata file to version control

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