Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple Wallabag -> Pocket conversion script
import time
import io
import csv
import sys
from datetime import datetime
csv.field_size_limit(sys.maxsize)
print("""<!DOCTYPE html>
<html>
<!--So long and thanks for all the fish-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Pocket Export</title>
</head>
<body>
<h1>Unread</h1>
<ul>
""")
with open(sys.argv[1]) as fp:
reader = csv.reader(fp, delimiter=';')
for i, row in enumerate(reader):
if i == 0:
continue
title = row[0]
url = row[1]
tags = row[3]
date = row[-1]
date = int(time.mktime(datetime.strptime(date, '%d/%m/%Y %H:%M:%S').timetuple()))
print('<li><a href="{url}" time_added="{time}" tags="{tags}">{title}</a></li>'.format(title=title, url=url, tags=tags, time=date))
print("""
</ul>
<h1>Read Archive</h1>
<ul>
</ul>
</body>
</html>""")
#Title;URL;Content;Tags;"MIME Type";Language;"Creation date"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment