Skip to content

Instantly share code, notes, and snippets.

@elipapa
Created November 24, 2015 17:42
Show Gist options
  • Save elipapa/7d596ceeff02a682bc43 to your computer and use it in GitHub Desktop.
Save elipapa/7d596ceeff02a682bc43 to your computer and use it in GitHub Desktop.
converting journey android app entries to dayone entries using the the dayone-cli limited input options
#!/usr/bin/env python3
## converting journey android app entries to dayone entries using the the dayone-cli limited input options
# first download all single posts zip files and place them in the folder of the script. Then run
# unzip '*.zip'
# where quotes are important!
#
# Then run this script in the folder
import json
import os, glob
from subprocess import Popen, PIPE, STDOUT
import datetime
for f in glob.glob('*.json'):
with open(f,'r') as fh:
j = json.load(fh)
text = j['text']
date = j['date_journal']
dateobj = datetime.datetime.fromtimestamp(date/1000)
if j['photos']:
photo = j['photos'][0]
cmd = ['dayone', '-p=%s' % photo, '-d="%s"' % dateobj.strftime('%m/%d/%Y %H:%M'), 'new']
else:
cmd = ['dayone','-d="%s"' % dateobj.strftime('%m/%d/%Y %H:%M'), 'new']
print(' '.join(cmd))
p = Popen(cmd, stdin=PIPE)
stdout_data = p.communicate(input=str.encode(text))[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment