From 71159bdcaa0e3e165fc0443b7d872d407044aa1e Mon Sep 17 00:00:00 2001 From: Brian Hardisty Date: Sat, 1 Jul 2017 03:53:19 -0700 Subject: [PATCH] Fix Pinboard JSON duplicate timestamps error If the JSON exported by Pinboard contains duplicate timestamps, Python returns a TypeError exception: `TypeError: argument of type 'float' is not iterable` This is because `time.mktime()` returns a floating point number. Encasing `time.mktime()` in `str()` fixes the data type not being iterable. `time.mktime()` has also been encased in `int()` to remove the unnecessary decimal value (`.0`) that gets returned for each time value, and to keep the script consistent with the other export functions. --- archive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/archive.py b/archive.py index 71f71730..83363307 100755 --- a/archive.py +++ b/archive.py @@ -114,8 +114,8 @@ def parse_json_export(json_file): 'url': erg['href'], 'domain': erg['href'].replace('http://', '').replace('https://', '').split('/')[0], 'base_url': erg['href'].replace('https://', '').replace('http://', '').split('?')[0], - 'time': datetime.fromtimestamp(time.mktime(time.strptime(erg['time'].split(',')[0], '%Y-%m-%dT%H:%M:%SZ'))), - 'timestamp': time.mktime(time.strptime(erg['time'].split(',')[0], '%Y-%m-%dT%H:%M:%SZ')), + 'time': datetime.fromtimestamp(int(time.mktime(time.strptime(erg['time'].split(',')[0], '%Y-%m-%dT%H:%M:%SZ')))), + 'timestamp': str(int(time.mktime(time.strptime(erg['time'].split(',')[0], '%Y-%m-%dT%H:%M:%SZ')))), 'tags': erg['tags'], 'title': erg['description'].replace(' — Readability', ''), }