#!/usr/bin/env python3 import json import os import sys import unicodedata import ox import ox.api if __name__ == '__main__': if len(sys.argv) > 1: target = sys.argv[1] else: target = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Edits') if not target.endswith('/'): target += '/' site = 'pandora.cinemusespace.com' api = ox.api.signin('https://%s/api/' % site) keep = [] r = api.findEdits({ 'range': [0, 1000], 'keys': ['id'] }) for i in r['data']['items']: edit = api.getEdit(id=i['id'])['data'] if edit['status'] == 'private': continue path = i['id'].replace(':', '_').replace('/', '_') + '.json' path = ox.decode_html(path) path = os.path.join(target, path) ox.makedirs(os.path.dirname(path)) with open(path, 'w') as fd: json.dump(edit, fd, ensure_ascii=False, indent=4, sort_keys=True)