Merge pull request #29 from jpmens/archive

Add support for archiving toots into JSON files
This commit is contained in:
Hugh Rundle 2020-06-30 09:14:06 +10:00 committed by GitHub
commit fe1358c7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -82,10 +82,10 @@ def checkToots(config, options, retry_count=0):
def jsondefault(obj):
if isinstance(obj, (date, datetime)):
return obj.isoformat()
def checkBatch(timeline, deleted_count=0):
for toot in timeline:
if 'id' in toot and 'archive' in config:
print(toot)
filename = os.path.join(config['archive'], str(toot['id']) + '.json')
with open(filename, "w") as f:
f.write(json.dumps(toot, indent=4, default=jsondefault))