Changeset 29 in mp3-find for trunk/lib/MP3/Find/Filesystem.pm


Ignore:
Timestamp:
05/21/06 05:17:23 (18 years ago)
Author:
peter
Message:
  • factored out 'get_mp3_metadata' function from Filesystem.pm to Util.pm
  • added 'update' function to DB.pm that combines 'update_db' and 'update_file' (for updating just specific files); idea courtesy of Matt Dietrich
  • modified mp3db to let you mix and match files and directories on the command line; now also uses the 'update' function in DB.pm
File:
1 edited

Legend:

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

    r28 r29  
    99use MP3::Info; 
    1010use Scalar::Util qw(looks_like_number); 
     11 
     12use MP3::Find::Util qw(get_mp3_metadata); 
    1113 
    1214eval { 
     
    9799        return if $filename =~ $$options{exclude_path}; 
    98100    } 
    99      
    100     my $mp3 = { 
    101         FILENAME => $filename, 
    102         %{ get_mp3tag($filename)  || {} }, 
    103         %{ get_mp3info($filename) || {} }, 
    104     }; 
    105      
    106     if ($CAN_USE_ID3V2 and $$options{use_id3v2}) { 
    107         # add ID3v2 tag info, if present 
    108         my $mp3_tags = MP3::Tag->new($filename); 
    109         unless (defined $mp3_tags) { 
    110             warn "Can't get MP3::Tag object for $filename\n"; 
    111         } else { 
    112             $mp3_tags->get_tags; 
    113             if (my $id3v2 = $mp3_tags->{ID3v2}) { 
    114                 for my $frame_id (keys %{ $id3v2->get_frame_ids }) { 
    115                     my ($info) = $id3v2->get_frame($frame_id); 
    116                     if (ref $info eq 'HASH') { 
    117                         # use the "Text" value as the value for this frame, if present 
    118                         $mp3->{$frame_id} = $info->{Text} if exists $info->{Text}; 
    119                     } else { 
    120                         $mp3->{$frame_id} = $info; 
    121                     } 
    122                 } 
    123             } 
    124         } 
    125     } 
     101 
     102    my $mp3 = get_mp3_metadata({ 
     103        filename  => $filename, 
     104        use_id3v2 => $options->{use_id3v2}, 
     105    }); 
    126106 
    127107    for my $field (keys(%{ $query })) { 
Note: See TracChangeset for help on using the changeset viewer.