Last active 1707676148

make pocket exports importable in linkwarden

pocketimport.pl Raw
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
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>Pocket bookmarks</H3>
22<DL><p>
23];
24
25while(<>) {
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
45print qq[</DL><p>
46];
47