Changeset 39 in mp3-find


Ignore:
Timestamp:
06/07/11 22:59:11 (13 years ago)
Author:
peter
Message:

Add the META.yml metadata file to version control

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/mp3find

    r27 r39  
    2626    printf      => $FORMAT, 
    2727    db_file     => catfile($ENV{HOME}, 'mp3.db'), 
    28     use_id3v2   => 1,  # search using ID3v2 tags by default 
    2928); 
    3029 
  • trunk/lib/MP3/Find/Base.pm

    r18 r39  
    66use Carp; 
    77 
     8#TODO: allow ID3v2 tags in printf format 
    89my %format_codes = ( 
    910    a => 'ARTIST', 
  • trunk/lib/MP3/Find/Filesystem.pm

    r36 r39  
    1212use MP3::Find::Util qw(get_mp3_metadata); 
    1313 
     14# XXX: this may or may not lead to faster searches 
    1415eval { 
    1516    require Sort::Key; 
     
    1819}; 
    1920my $USE_SORT_KEY = $@ ? 0 : 1; 
    20  
    21  
    22 eval { require MP3::Tag }; 
    23 my $CAN_USE_ID3V2 = $@ ? 0 : 1; 
    2421 
    2522use_winamp_genres(); 
     
    5249        } 
    5350    } 
    54      
    55     if ($$options{use_id3v2} and not $CAN_USE_ID3V2) { 
    56         # they want to use ID3v2, but don't have MP3::Tag 
    57         warn "MP3::Tag is required to search ID3v2 tags\n"; 
    58     } 
    59          
     51 
    6052    # run the actual find 
    6153    my @results; 
     
    10294    my $mp3 = get_mp3_metadata({ 
    10395        filename  => $filename, 
    104         use_id3v2 => $options->{use_id3v2}, 
    10596    }); 
    10697 
     
    139130L<File::Find>, L<MP3::Info>, L<Scalar::Util> 
    140131 
    141 L<MP3::Tag> is also needed if you want to search using ID3v2 tags. 
    142  
    143132=head1 DESCRIPTION 
    144133 
    145134This module implements the C<search> method from L<MP3::Find::Base> 
    146135using a L<File::Find> based search of the local filesystem. 
     136 
     137In addition to just the basic ID3v1 tags, you can search for files by their 
     138ID3v2 data, using the four-character frame names.  This isn't very useful if 
     139you are just search by artist or title, but if, for example, you have made use 
     140of the C<TOPE> ("Orignal Performer") frame, you could search for all the cover 
     141songs in your collection: 
     142 
     143    $finder->find_mp3s(query => { tope => '.' }); 
     144 
     145As with the basic query keys, ID3v2 query keys are converted to uppercase 
     146internally. 
    147147 
    148148=head2 Special Options 
     
    152152=item C<exclude_path> 
    153153 
    154 Scalar or arrayref; any file whose name matches any of these paths 
    155 will be skipped. 
    156  
    157 =item C<use_id3v2> 
    158  
    159 Boolean, defaults to false. If set to true, MP3::Find::Filesystem will 
    160 use L<MP3::Tag> to get the ID3v2 tag for each file. You can then search 
    161 for files by their ID3v2 data, using the four-character frame names.  
    162 This isn't very useful if you are just search by artist or title, but if, 
    163 for example, you have made use of the C<TOPE> ("Orignal Performer") frame, 
    164 you could search for all the cover songs in your collection: 
    165  
    166     $finder->find_mp3s(query => { tope => '.' }); 
    167  
    168 As with the basic query keys, ID3v2 query keys are converted to uppercase 
    169 internally. 
     154Scalar or arrayref; any file whose name matches any of these paths will be 
     155skipped. 
    170156 
    171157=back 
     
    181167=head1 COPYRIGHT AND LICENSE 
    182168 
    183 Copyright (c) 2006 by Peter Eichman. All rights reserved. 
     169Copyright (c) 2006-2008 by Peter Eichman. All rights reserved. 
    184170 
    185171This program is free software; you can redistribute it and/or 
  • trunk/lib/MP3/Find/Util.pm

    r29 r39  
    5151    my $mp3 = { 
    5252        FILENAME => $filename, 
    53         %{ get_mp3tag($filename)  || {} }, 
    54         %{ get_mp3info($filename) || {} }, 
     53        # ID3v2 tags, if present, override ID3v1 tags 
     54        %{ get_mp3tag($filename, 0, 2)  || {} }, 
     55        %{ get_mp3info($filename)       || {} }, 
    5556    }; 
    56      
    57     if ($CAN_USE_ID3V2 and $args->{use_id3v2}) { 
    58         # add ID3v2 tag info, if present 
    59         my $mp3_tags = MP3::Tag->new($filename); 
    60         unless (defined $mp3_tags) { 
    61             warn "Can't get MP3::Tag object for $filename\n"; 
    62         } else { 
    63             $mp3_tags->get_tags; 
    64             if (my $id3v2 = $mp3_tags->{ID3v2}) { 
    65                 for my $frame_id (keys %{ $id3v2->get_frame_ids }) { 
    66                     my ($info) = $id3v2->get_frame($frame_id); 
    67                     if (ref $info eq 'HASH') { 
    68                         # use the "Text" value as the value for this frame, if present 
    69                         $mp3->{$frame_id} = $info->{Text} if exists $info->{Text}; 
    70                     } else { 
    71                         $mp3->{$frame_id} = $info; 
    72                     } 
    73                 } 
    74             } 
    75         } 
    76     } 
    7757 
    7858    return $mp3; 
Note: See TracChangeset for help on using the changeset viewer.