Show
Ignore:
Timestamp:
03/16/07 10:17:16 (2 years ago)
Author:
jm3
Message:

import fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • feedmelinks/bin/import-bookmarks.pl

    r1382 r1424  
    22use lib "/home/fml/public_html/lib"; 
    33use FeedMeLinks::Environment; 
     4#use strict; 
     5 
     6my ($debug, $link, $tag, @tags, @links, @folks, $url, $hideGarbage, $dd, $glc, $mandatory_tag, $path, $filename, $bin, $format, $cmd, $depth, $folksPath, $lastDepth, $lastFolder, $description); 
    47 
    58$glc = 0; 
    6  
    7 my ($link, $tag, @tags, @links, @folks, $hideGarbage, $dd, $glc, $mandatory_tag, $path, $bin, $format); 
     9$debug = 0; 
    810 
    911$link = $tag = undef; 
    10 $hideGarbage = true;  
     12$hideGarbage = 1;  
    1113$glc = 0;  
    1214push @folks, "ROOT"; 
     
    1820# extract the user name from the file path (this practice oculd be considered a bit shady...) 
    1921$path = $filename = $ARGV[0]; 
    20 $parser     = $ARGV[1]; 
    21 $link_xslt  = $ARGV[2]; 
    22 $tag_xslt   = $ARGV[3]; 
     22my $parser     = $ARGV[1]; 
     23my $link_xslt  = $ARGV[2]; 
     24my $tag_xslt   = $ARGV[3]; 
    2325$path =~ s:\/([^/]+)$::; #strip filename 
    2426$bin ="/home/fml/public_html/bin"; 
    2527 
    26 $success_code = ""; 
    27  
    28 $converted = "/tmp/import-" . int(rand(1000)); 
     28my $success_code = ""; 
     29 
     30my $converted = "/tmp/import-" . int(rand(1000)); 
    2931# one of: delicious-hybrid, netscape, delicious-API 
    3032$format = detect_bookmarks_format( $bin, $filename ); 
    31 if( $format == "delicious-hybrid" ) { 
    32         print "converting from hybrid format:\n"; 
     33 
     34print "format: |$format|\n" if( $debug ); 
     35 
     36if( $format eq "delicious-hybrid" ) { 
     37        print "converting from hybrid format:\n" if( $debug ); 
    3338        $cmd = "$bin/hybrid-to-xml.pl $filename > $converted"; 
    3439        print "cmd: $cmd\n"; 
     
    3641        $filename = $converted; 
    3742        #print "new converted xml output is in $filename\n"; 
    38         $out = `cat $filename`; 
    39         print "$filename contains: \n$out\n\n"
     43        my $out = `cat $filename`; 
     44        print "$filename contains: \n</code><form><textarea rows='40' cols='150'>$out</textarea></form><code>\n\n" if( $debug )
    4045        $success_code = "converted from hybrid to stock xml"; 
     46 
     47        #magic format swap-eroo now that we've converted 
     48        $format = "delicious-API"; 
    4149} 
    4250 
    4351while( <> ) { 
    44         $line = $_; 
    45  
    46         # EITHER THE FUCKING PERL REGEX SYNTAX CHANGED OR RP HAS A BROKEN PERL 
    47         if( $line =~ m/xml version/ ) { 
    48         #<?xml version='1.0' standalone='yes'?> 
    49                  
     52        my $line = $_; 
     53 
     54        if( $format eq "delicious-API" ) { 
     55 
    5056                $cmd = "xsltproc $link_xslt $filename > $path/LINKS.RAW\n"; 
    51                 print "$cmd\n"
    52                 $out = `$cmd`; 
     57                print "cmd:<br>$cmd\n" if( $debug )
     58                my $out = `$cmd`; 
    5359                print "cmd output was: $out\n"; 
    5460                 
     
    143149        my $cmd = "$bin/detect-bookmarks-file-format.sh $filename"; 
    144150        my $out = `$cmd`; 
     151        chomp( $out ); 
    145152        return $out; 
    146153} 
     
    158165 
    159166sub get_folks_path() { 
    160         $folksPath = ""; 
     167        my $folksPath = ""; 
    161168        foreach( @folks ) { 
    162                 $f = $_; 
     169                my $f = $_; 
    163170                $folksPath = "$folksPath / $f"; 
    164171        } 
     
    168175 
    169176sub strip_first { 
    170         $fp = $_[0]; 
     177        my $fp = $_[0]; 
    171178        $fp =~ s/ \/ /$dd/g; 
    172179        $fp =~ s/^ROOT/$mandatory_tag/; 
     
    175182 
    176183sub add_pending_link_or_tag() { 
     184        my $s; 
    177185        if( $link ) { 
    178                 $tag_list = strip_first( $folksPath); 
     186                my $tag_list = strip_first( $folksPath); 
    179187                $s = $url . $dd . $link . $dd . $tag_list; 
    180                 #p( $s ); 
    181188                push @links, $s; 
    182  
    183                 #p( "INSERT INTO links VALUES( NULL, '$url', $link, NULL, NULL, NEED_USER_HERE_TBD, NULL, 1 );" ); 
    184  
    185189                $link = $description = undef; 
    186190        } elsif( $tag ) { 
    187191                $s = $tag; 
    188                 #p( $s ); 
    189192                push @tags, $s; 
    190193                $tag = undef;