Skip to content

Instantly share code, notes, and snippets.

@phretor
Created May 4, 2020 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phretor/021757dd97686a275e390a39213eb32c to your computer and use it in GitHub Desktop.
Save phretor/021757dd97686a275e390a39213eb32c to your computer and use it in GitHub Desktop.
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