Show
Ignore:
Timestamp:
02.10.2012 05:41:18 (7 years ago)
Author:
davidb
Message:

Some minor tweaks to allow the plugin to be used under Cygwin

Location:
gs3-extensions/audioDB/trunk/src/perllib/plugins
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gs3-extensions/audioDB/trunk/src/perllib/plugins/AudioDBPlugin.pm

    r24399 r26275  
    9090    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments}); 
    9191    push(@{$hashArgOptLists->{"OptList"}},$options); 
    92  
    9392     
    9493    my $ffte_self = new FFTExtractor($pluginlist, $inputargs, $hashArgOptLists,1); 
     94 
     95    my $jsme_self  = undef; 
     96    eval("require MusicIRPlugin"); 
     97    if ($@) { 
     98    # Useful debugging statement below if there is a syntax error in the plugin 
     99    # and you expecting jSongMinerExtractor to be found 
     100    # print STDERR "$@\n"; 
     101    } 
     102    else { 
     103    print STDERR "Dynamically loading jSongMinerExtractor\n"; 
     104    push(@AudioDBPlugin::ISA,"MusicIRPlugin"); 
     105    $jsme_self = new MusicIRPlugin($pluginlist, $inputargs, $hashArgOptLists); 
     106    } 
     107 
    95108    my $base_self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists); 
    96109 
    97     my $self = BasePlugin::merge_inheritance($ffte_self,$base_self); 
     110    my $self = BasePlugin::merge_inheritance($ffte_self,$jsme_self,$base_self); 
     111 
     112    $self->{'jSongMinerExtractor-found'} = (defined $jsme_self) ? 1 : 0; 
    98113 
    99114    return bless $self, $class; 
     
    181196    } 
    182197     
    183     #we have no text - adds dummy text and NoText metadata 
    184     $self->add_dummy_text($doc_obj, $doc_obj->get_top_section()); 
     198 
     199    if ($self->{'jSongMinerExtractor-found'}) { 
     200    # calling this version of process has the side effect of setting dummy text 
     201    $self->MusicIRPlugin::process($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli); 
     202    } 
     203    else { 
     204    #we have no text - adds dummy text and NoText metadata 
     205    $self->add_dummy_text($doc_obj, $doc_obj->get_top_section()); 
     206    } 
    185207 
    186208    return 1; 
     
    189211 
    190212 
     213sub post_process_doc_obj { 
     214    my $self = shift (@_);   
     215    my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_; 
     216 
     217    my $outhandle = $self->{'outhandle'}; 
     218    my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file); 
     219 
     220    # Opportunity to use jAudioMinerExtractor if dynamically and loaded 
     221    # 
     222    if ($self->{'retrieve_mir_metadata'} eq "true") { 
     223    my $top_section = $doc_obj->get_top_section(); 
     224 
     225    my $id3_titles = $doc_obj->get_metadata($top_section,"ex.ID3.Title"); 
     226    # my $id3_title = shift @$id3_titles || "Unknown"; 
     227    my $id3_title = shift @$id3_titles || undef; 
     228 
     229    my $id3_artists = $doc_obj->get_metadata($top_section,"ex.ID3.Artist"); 
     230    # my $id3_artist = shift @$id3_artists || "Unknown"; 
     231    my $id3_artist = shift @$id3_artists || undef; 
     232 
     233    my ($metadata_acexml_filename,$metadata_txt_filename)  
     234        = $self->retrieve_metadata($filename_full_path,$id3_title,$id3_artist); 
     235     
     236    if (-e $metadata_txt_filename) { 
     237        $self->parse_txt_metadata($doc_obj,$metadata_txt_filename); 
     238    } 
     239 
     240    $doc_obj->associate_file($metadata_acexml_filename, "jsongminer.xml",  
     241                 "text/xml", $top_section); 
     242    } 
     243 
     244 
     245    return 1; 
     246} 
     247 
     248 
    1912491; 
    192250 
  • gs3-extensions/audioDB/trunk/src/perllib/plugins/FFTExtractor.pm

    r24399 r26275  
    9494    } 
    9595 
     96    my $native_source_file_path = $source_file_path; 
     97 
     98    my $native_target_file_path = $target_file_path; 
     99    if ($^O eq "cygwin") { 
     100    # Only get ffmpeg as native Windows binary => need to use Windows style path 
     101    $native_source_file_path=`cygpath -w \"$source_file_path\"`; 
     102    $native_target_file_path=`cygpath -w \"$target_file_path\"`; 
     103    $native_source_file_path =~ s/\s+$//; 
     104    $native_target_file_path =~ s/\s+$//; 
     105    } 
     106 
    96107    # Setup and run the ffmpeg command 
    97108    my $ffmpeg_cmd = "ffmpeg -y $convert_options"; 
    98     $ffmpeg_cmd .= " -i \"$source_file_path\""; 
    99     $ffmpeg_cmd .= " \"$target_file_path\""; 
     109    $ffmpeg_cmd .= " -i \"$native_source_file_path\""; 
     110    $ffmpeg_cmd .= " \"$native_target_file_path\""; 
    100111         
    101112##    print STDERR "****** cmd = $ffmpeg_cmd\n"; 
     
    161172    $fftExtract_cmd .= " \"$source_file_path\" \"$target_file_path\""; 
    162173         
     174##    $fftExtract_cmd =~ s/\\/\//g;  
     175 
    163176##    print STDERR "**** cmd = $fftExtract_cmd\n"; 
    164177