Changeset 22364


Ignore:
Timestamp:
2010-07-07T14:04:40+12:00 (11 years ago)
Author:
ak19
Message:

MediainfoOGVPlugin now includes the final changes Arnaud made to his plugin.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/MediainfoOGVPlugin.pm

    r22363 r22364  
    139139
    140140    # Retrieve the file metadata
    141 
    142     my $command = "mediainfo --inform=\"General;%Duration/String2%|%Duration%|%FileSize/String2%|%Performer%|%Title%|%Recorded_Date%|%Recorded/Location%|%Producer%|%Copyright%|%Publisher%\" \"$filename_full_path\"";
     141    my $command = "mediainfo --inform=\"General;%Duration/String2%|%Duration%|%FileSize/String2%|%Performer%|%Title%|%Recorded_Date%|%Recorded/Location%|%Producer%|%Copyright%|%LICENSE%|%Publisher%\" \"$filename_full_path\"";
    143142    print $outhandle "$command\n" if ($verbosity > 2);
    144143
    145144    # execute the mediainfo command and store the output of execution in $videodata
    146145    # my $video_metadata = `$command`; # backticks operator way
    147     # Another way to execute the command: better experience with this than
    148 with backticks operator above:
    149     # use open() to read the output of executing the command (which is
    150 piped through to a handle using the | operator)
     146    # Another way to execute the command: better experience with this than with backticks operator above:
     147    # use open() to read the output of executing the command (which is piped through to a handle using the | operator)
    151148    my $video_metadata;
    152149    if (open(VMIN,"$command|")) {
    153150        my $line;
    154151
    155     # we read a line of output at a time
     152    # we read a line of output at a time
    156153        while (defined ($line=<VMIN>)) {
    157             #print STDERR "***** line = $line\n";
    158 
    159             $video_metadata .= $line;
     154            #print STDERR "***** line = $line\n";
     155
     156            $video_metadata .= $line;
    160157        }
    161158
    162159        close(VMIN);
    163     } 
     160    }
    164161
    165162    print $outhandle "$video_metadata\n" if ($verbosity > 2);
    166163
    167164    # There are 10 fields separated by |, split these into ordered, individual-named variables
    168     my ($formattedduration,$duration,$mfilesize,$artist,$title,$date,$location,$organization,$copyright,$contact) = split(/\|/,$video_metadata);
    169     $duration = int($duration/1000);
    170     $artist =~ s/\\047/\'/g; # Perl's way of doing: $artist = `echo $artist | sed \"s/\\047/'/g\"`;
    171     $title =~ s/\\047/\'/g; # $title = `echo $title | sed \"s/\\047/'/g\"`;
    172 
    173     #print STDERR "**** RESULT = $formattedduration\n$duration\n$mfilesize\n$artist\n$title\n$date\n$location\n$organization\n$copyright\n$contact\n";
    174     print $outhandle "RESULT = $formattedduration\n$duration\n$mfilesize\n$artist\n$title\n$date\n$location\n$organization\n$copyright\n$contact\n" if ($verbosity > 2);
     165    my ($FormattedDuration,$Duration,$Filesize,$Artist,$Title,$Date,$Location,$Organization,$Copyright,$License,$Contact) = split(/\|/,$video_metadata);
     166    $Duration = int($Duration/1000);
     167    $Artist =~ s/\\047/\'/g; # Perl's way of doing: $artist = `echo $artist | sed \"s/\\047/'/g\"`;
     168    $Title =~ s/\\047/\'/g; # $title = `echo $title | sed \"s/\\047/'/g\"`;
     169
     170    print $outhandle "RESULT = $FormattedDuration\n$Duration\n$Filesize\n$Artist\n$Title\n$Date\n$Location\n$Organization\n$Copyright\n$License\n$Contact\n" if ($verbosity > 2);
    175171   
    176 
    177172    # Add the file as an associated file ...
    178173    my $section = $doc_obj->get_top_section();
     
    190185    $doc_obj->add_utf8_metadata ($section, $assoc_field, $doc_obj->get_source()); # Source metadata is already in utf8
    191186 
    192     $doc_obj->add_metadata ($section, "FormattedDuration", $formattedduration);
    193     $doc_obj->add_metadata ($section, "Duration", $duration);
     187    $doc_obj->add_metadata ($section, "FormattedDuration", $FormattedDuration);
     188    $doc_obj->add_metadata ($section, "Duration", $Duration);
    194189 
    195190    $doc_obj->add_metadata ($section, "srclink",
     
    198193    $doc_obj->add_metadata ($section, "/srclink", "</a>");
    199194
    200     $doc_obj->add_metadata($section,"mFileSize",$mfilesize);
    201     $doc_obj->add_utf8_metadata($section,"dc.Creator",$artist);
    202     $doc_obj->add_utf8_metadata($section,"Artist",$artist);
    203     $doc_obj->add_utf8_metadata($section,"dc.Title",$title);
    204     $doc_obj->add_utf8_metadata($section,"Title",$title);
    205     $doc_obj->add_utf8_metadata($section,"dc.Date",$date);
    206     $doc_obj->add_utf8_metadata($section,"Date",$date);
    207     $doc_obj->add_utf8_metadata($section,"Location",$location);
    208     $doc_obj->add_utf8_metadata($section,"dc.Publisher",$organization);
    209     $doc_obj->add_utf8_metadata($section,"Organization",$organization);
    210     $doc_obj->add_utf8_metadata($section,"Copyright",$copyright);
    211     $doc_obj->add_utf8_metadata($section,"Contact",$contact);
     195    $doc_obj->add_metadata($section,"FileSize",$Filesize);
     196    $doc_obj->add_utf8_metadata($section,"dc.Creator",$Artist);
     197    $doc_obj->add_utf8_metadata($section,"Artist",$Artist);
     198    $doc_obj->add_utf8_metadata($section,"dc.Title",$Title);
     199    $doc_obj->add_utf8_metadata($section,"Title",$Title);
     200    $doc_obj->add_utf8_metadata($section,"dc.Date",$Date);
     201    $doc_obj->add_utf8_metadata($section,"Date",$Date);
     202    $doc_obj->add_utf8_metadata($section,"dc.Coverage",$Location);
     203    $doc_obj->add_utf8_metadata($section,"Location",$Location);
     204    $doc_obj->add_utf8_metadata($section,"dc.Publisher",$Organization);
     205    $doc_obj->add_utf8_metadata($section,"Organization",$Organization);
     206    $doc_obj->add_utf8_metadata($section,"dc.Rights",$Copyright);
     207    $doc_obj->add_utf8_metadata($section,"Copyright",$Copyright);
     208    $doc_obj->add_utf8_metadata($section,"dc.accessRights",$License);
     209    $doc_obj->add_utf8_metadata($section,"License",$License);
     210    $doc_obj->add_utf8_metadata($section,"dc.Contributor",$Contact);
     211    $doc_obj->add_utf8_metadata($section,"Contact",$Contact);
    212212 
    213213    # we have no text - add dummy text and NoText metadata
Note: See TracChangeset for help on using the changeset viewer.