tagpackerimport.pl
· 953 B · Perl
Raw
#! perl
#
# convert tagpacker html export to a netscape html compatible format to make it importable in linkwarden
# the script is pretty sloppy, it will likely break for some lines
#
# alexlehm/at/gmail.com
#
# https://wiki.creativecommons.org/wiki/CC0
#
print qq[<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks Menu</H1>
];
print qq[<DL><p>
<HR><DT><H3>Tagpacker bookmarks</H3>
<DL><p>
];
while(<>) {
chop;
if(m@<DT>(<A[^<]*</A>)@i) {
$msg=$1;
if($msg=~m@<a href="([^"]+)" +add_date="([0-9]+)" +tags="([^\"]*)".*>([^<]+)</a>@i) {
$link=$1;
$added=$2;
$tags=$3;
$desc=$4;
print qq[<DT><A HREF="$link" ADD_DATE="$added" TAGS="$tags">$desc</A>
];
} else {
warn "failed to match line\n";
}
}
}
print qq[</DL><p>
];
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 | ]; |
47 |