#!/usr/bin/perl # jason thaxter # 2003 # * take opera browser's .adr bookmarks file on stdin # and puke a mozilla-style file on stdout # * works for opera 6, as far as I know # * firebird 0.7 imports it fine, as far as i can see # * this is public domain code # * use at your own risk my $line; my ( $name, $url ); # print header print < Bookmarks

Bookmarks

EOF $indent = ' '; while ( $line = ) { chomp $line; if ( $line =~ m/#FOLDER/ ) { while ($sub = ){ chomp $sub; last if $sub eq ''; if ($sub =~ /ID=(.*)/){ next } # don't know how to convert these elsif ($sub =~ /NAME=(.*)/){ $name = $1 } elsif ($sub =~ /CREATED=(.*)/){ $created = $1 } elsif ($sub =~ /ACTIVE|EXPANDED|TRASH/){ ; } else { warn "unparsed line: $sub"; } } $name ||= "Unknown"; $indent .= ' '; print $indent, "

$name

", "\n"; } elsif ( $line =~ m/#URL/ ) { while ($sub = ){ chomp $sub; last if $sub eq ''; if ( $sub =~ /ID=(.*)/ ) { next } # don't know how to convert these elsif ( $sub =~ /NAME=(.*)/ ) { $name = $1 } elsif ( $sub =~ /URL=(.*)/ ) { $url = $1 } elsif ( $sub =~ /CREATED=(.*)/ ) { $created = $1 } elsif ( $sub =~ /VISITED=(.*)/ ) { $visited = $1 } elsif ( $sub =~ /DESCRIPTION=(.*)/ ) { $description = $1 } else { warn "unparsed line: $sub"; } } $created ||= time; $visited ||= $created; print $indent, "
", "$name
\n"; next; } elsif ( $line =~ m/^-/ ) { # closing folder print "$indent

\n"; $indent =~ s/ //; } elsif ( $line eq ''){ ; } elsif ( $line =~ /Opera Hotlist version/) { print STDERR "VERSION: $line\n"; } elsif ($line =~ /Options:/){ print STDERR "OPTIONS: $line\n"; } elsif ($line =~ /ACTIVE|EXPANDED|TRASH/){ ; } else { warn "unparsed line: $line" } } print STDERR "Done.\n";