pocketimport.pl
· 941 B · Perl
Raw
#! perl
#
# convert pocket 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>Pocket bookmarks</H3>
<DL><p>
];
while(<>) {
chop;
if(m@<li>(.*)</li>@) {
$msg=$1;
if($msg=~m@<a href="([^"]+)" time_added="([0-9]+)" tags="([^\"]*)".*>([^<]+)</a>@) {
$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 pocket 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>Pocket bookmarks</H3> |
22 | <DL><p> |
23 | ]; |
24 | |
25 | while(<>) { |
26 | chop; |
27 | |
28 | if(m@<li>(.*)</li>@) { |
29 | $msg=$1; |
30 | |
31 | if($msg=~m@<a href="([^"]+)" time_added="([0-9]+)" tags="([^\"]*)".*>([^<]+)</a>@) { |
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 |