backup edits
This commit is contained in:
parent
0f6e1530c8
commit
a09fcaaa86
1 changed files with 39 additions and 0 deletions
39
backup_edits.py
Executable file
39
backup_edits.py
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/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)
|
||||
|
Loading…
Reference in a new issue