Re: Firefox bookmarks.html convertor for Dillo
Nick Warne <nick-ucsffw2X/[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 14 May 2016 13:19:30 +0100 Nick Warne <nick-ucsffw2X/[email protected]> wrote: > Attached is a short perl script that converts FF bookmarks.html (which > can be exported within FF itself) to Dillo format bm.txt. > > Simple to use, and the code has brief instructions. > > The only thing I am not sure about is if different versions of FF use > the same bookmarks.html format. A slightly improved version that doesn't strip all white space in the URL 'name', and also ignores rss feeds. I also forgot to mention that any bookmarks in the root (i.e. no section) get stuffed into the last section parsed - these can easily be handled in Dillos' bookmark menu 'modify'. Nick -- Gosh that takes me back... or is it forward? That's the trouble with time travel, you never can tell." -- Doctor Who "Androids of Tara" _______________________________________________ Dillo-dev mailing list [email protected] http://lists.dillo.org/cgi-bin/mailman/listinfo/dillo-dev
ff_to_bm.pl
(application/x-perl, 1.1 KB)
#!/usr/bin/perl -w
# Copywrite Nick Warne 14/05/2016
# Licence: Public Domain
# Firefox bookmarks.html converter for Dillo bm.txt
#
# To use: place this script in the same directory as your
# saved Firefox bookmarks.html file, and run 'perl ff_to_bm.pl'
# Output to stdout: when happy, add the results to your bm.txt
my @urls;
my $line;
my $name;
# Assume Dillo user already has :s0: bookmark section
# This can be changed to suit: set it to the last :sn: section in bm.txt
# i.e. if your last bm section is :s5:, set this to 5.
my $count = 0;
open (BM, "< bookmarks.html");
@urls= <BM>;
close (BM);
foreach $line (@urls) {
$line =~ s/^\s+$//;
# ignore rss feeds.
if ($line =~ /FEEDURL/) {
next;
}
if ($line =~ /\<\/H3\>/i) {
$count = $count+1;
$line =~ s/.*\<.*\"\>//gi;
$line =~ s/\<\/H3\>//gi;
$line = ":s".$count.": ".$line;;
print $line;
}
if ($line =~ /HREF/) {
$line =~ s/.*HREF\=\"//gi;
$name = $line;
$line =~ s/\" ADD.*//gi;
chomp($line);
$name =~ s/.*\"\>//gi;
$name =~ s/\<\/A\>//gi;
$line = "s".$count." ".$line." ".$name;
print $line;
}
}