#!/usr/local/bin/perl # soif2mwi - convert SOIF record on STDIN to NWI record on STDOUT # # Author: andy powell # # $Id: soif2nwi,v 1.1 1997/06/24 22:07:18 lisap Exp $ $ENV{'HARVEST_HOME'} = "/usr/local/harvest" if (!defined($ENV{'HARVEST_HOME'})); unshift(@INC, "$ENV{'HARVEST_HOME'}/lib"); # use local files require "soif.pl"; use HTML::Entities (); # from LWP # SOIF to NWI mappings... # SOIF NWI # ---- --- # Abstract # Author # Body # Description # File-Size # Full-Text # Gatherer-Host # Gatherer-Name # Gatherer-Port # Gatherer-Version # Headings # Update-Time # Keywords # Last-Modification-Time # MD5 # Refresh-Rate # Time-to-Live # Title # Type # URL-References # # URL %Mappings = ( 'body', 'ip', 'file-size', 'by', 'full-text', 'ip', 'headings', 'dh', 'last-modification-time', 'dm', 'md5', 'md5', 'title', 'ti', 'type', 'ty', ); ($ttype,$url,%SOIF) = &soif'parse; $url =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; foreach (keys SOIF) { $value = $SOIF{$_}; tr/A-Z/a-z/; # if ($soif'debug == 1) { # $value =~ s/\s+/ /g; # print "SOIF-$_ = $value\n"; # } next unless ($Mappings{$_}); $value =~ s/\cM/ /; $value =~ s/\s+/ /g; if ($_ =~ /-time$/) { $value = localtime($value); } $value = HTML::Entities::encode_entities($value); $NWI{$Mappings{$_}} = $value; } $NWI{'avli'} = $url; unless ($NWI{'ti'}) { if ($NWI{'dh'}) { $NWI{'ti'} = $NWI{'dh'}; $NWI{'ti'} =~ s/\n.*//; } } print "\n"; print " ".$NWI{'ti'}."\n" if $NWI{'ti'}; print " ".$NWI{'dm'}."\n" if $NWI{'dm'}; if ($NWI{'by'} || $NWI{'md5'}) { print "\n"; print " ".$NWI{'by'}."\n" if $NWI{'by'}; print " ".$NWI{'md5'}."\n" if $NWI{'md5'}; print "\n"; } if ($NWI{'avli'} || $NWI{'ty'}) { print "\n"; print " ".$NWI{'avli'}."\n" if $NWI{'avli'}; print " ".$NWI{'ty'}."\n" if $NWI{'ty'}; print "\n"; } # Ignore Headings () for now. if ($NWI{'ip'}) { print "\n"; write; print "\n"; } print "\n"; exit 0; format = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ $NWI{'ip'} .