Last active 1707676271

convert tagpacker html explort to netscape format to import it to linkwarden

Revision 7c3a2e8fb9b6062f4d8e066865c64d5e33ad1912

tagpackerimport.pl Raw
1#! perl
2#
3# convert tagpacker html export to a netscape html compatible format to make it importable in linkwarden
4# the script is pretty sloppy, it will likely break for some lines
5#
6# alexlehm/at/gmail.com
7#
8# https://wiki.creativecommons.org/wiki/CC0
9#
10
11print qq[<!DOCTYPE NETSCAPE-Bookmark-file-1>
12<!-- This is an automatically generated file.
13 It will be read and overwritten.
14 DO NOT EDIT! -->
15<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
16<TITLE>Bookmarks</TITLE>
17<H1>Bookmarks Menu</H1>
18];
19
20print qq[<DL><p>
21<HR><DT><H3>Tagpacker bookmarks</H3>
22<DL><p>
23];
24
25while(<>) {
26 chop;
27
28 if(m@<DT>(<A[^<]*</A>)@i) {
29 $msg=$1;
30
31 if($msg=~m@<a href="([^"]+)" +add_date="([0-9]+)" +tags="([^\"]*)".*>([^<]+)</a>@i) {
32 $link=$1;
33 $added=$2;
34 $tags=$3;
35 $desc=$4;
36
37 print qq[<DT><A HREF="$link" ADD_DATE="$added" TAGS="$tags">$desc</A>
38];
39 } else {
40 warn "failed to match line\n";
41 }
42 }
43}
44
45print qq[</DL><p>
46];
47