Transform Facebook JSON exports to MF2 JSON
#!/usr/bin/env python | |
''' | |
Usage: | |
./transform <path-to-facebook-export.json> | |
This will transform everything using granary and then place | |
individual files into a directory called "mf2." | |
You can generate a full export from Facebook using this project: | |
https://github.com/danburzo/fb-export | |
Happy freedom from Facebook :) | |
''' | |
import json | |
import sys | |
import os | |
from granary import microformats2, facebook | |
from granary.facebook import Facebook | |
facebook = Facebook() | |
if __name__ == '__main__': | |
posts = json.loads(open(sys.argv[1], 'r').read()) | |
os.system('mkdir -p mf2') | |
for post in posts: | |
mf2 = microformats2.object_to_json(facebook.post_to_object(post)) | |
mf2_json = json.dumps(mf2, indent=2) | |
with open('mf2/%s.json' % mf2['properties']['published'][0], 'wb') as mf2_file: | |
mf2_file.write(mf2_json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment