Changeset 14 in mp3-find for trunk/lib/MP3/Find


Ignore:
Timestamp:
03/27/06 19:34:43 (19 years ago)
Author:
peter
Message:
  • added support for searching by ID3v2 frames using MP3::Tag to the Filesystem.pm backend
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/MP3/Find/Filesystem.pm

    r12 r14  
    7676        %{ get_mp3info($filename) || {} }, 
    7777    }; 
     78     
     79    if ($$options{use_id3v2}) { 
     80        require MP3::Tag; 
     81        # add ID3v2 tag info, if present 
     82        my $mp3_tags = MP3::Tag->new($filename); 
     83        $mp3_tags->get_tags; 
     84        if (my $id3v2 = $mp3_tags->{ID3v2}) { 
     85            for my $frame_id (keys %{ $id3v2->get_frame_ids }) { 
     86                my ($info) = $id3v2->get_frame($frame_id); 
     87                if (ref $info eq 'HASH') { 
     88                    #TODO: how should we handle these? 
     89                } else { 
     90                    $mp3->{$frame_id} = $info; 
     91                } 
     92            } 
     93        } 
     94    } 
     95 
    7896    for my $field (keys(%{ $query })) { 
    7997        my $value = $mp3->{uc($field)}; 
     
    110128L<File::Find>, L<MP3::Info>, L<Scalar::Util> 
    111129 
     130L<MP3::Tag> is also needed if you want to search using ID3v2 tags. 
     131 
    112132=head1 DESCRIPTION 
    113133 
     
    123143Scalar or arrayref; any file whose name matches any of these paths 
    124144will be skipped. 
     145 
     146=item C<use_id3v2> 
     147 
     148Boolean, defaults to false. If set to true, MP3::Find::Filesystem will 
     149use L<MP3::Tag> to get the ID3v2 tag for each file. You can then search 
     150for files by their ID3v2 data, using the four-character frame names.  
     151This isn't very useful if you are just search by artist or title, but if, 
     152for example, you have made use of the C<TOPE> ("Orignal Performer") frame, 
     153you could search for all the cover songs in your collection: 
     154 
     155    $finder->find_mp3s(query => { tope => '.' }); 
     156 
     157As with the basic query keys, ID3v2 query keys are converted to uppercase 
     158internally. 
     159 
     160=back 
    125161 
    126162=head1 SEE ALSO 
Note: See TracChangeset for help on using the changeset viewer.