Last active 1707676271

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

alexlehm's Avatar alexlehm revised this gist 1707676271. Go to revision

1 file changed, 46 insertions

tagpackerimport.pl(file created)

@@ -0,0 +1,46 @@
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 +
11 + print 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 +
20 + print qq[<DL><p>
21 + <HR><DT><H3>Tagpacker bookmarks</H3>
22 + <DL><p>
23 + ];
24 +
25 + while(<>) {
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 +
45 + print qq[</DL><p>
46 + ];
Newer Older