Created
May 4, 2020 06:53
-
-
Save phretor/021757dd97686a275e390a39213eb32c to your computer and use it in GitHub Desktop.
A simple Wallabag -> Pocket conversion script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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