mirror of
https://github.com/hughrun/ephemetoot
synced 2025-02-18 12:40:41 +01:00
Merge pull request #29 from jpmens/archive
Add support for archiving toots into JSON files
This commit is contained in:
commit
fe1358c7c3
@ -82,10 +82,10 @@ def checkToots(config, options, retry_count=0):
|
|||||||
def jsondefault(obj):
|
def jsondefault(obj):
|
||||||
if isinstance(obj, (date, datetime)):
|
if isinstance(obj, (date, datetime)):
|
||||||
return obj.isoformat()
|
return obj.isoformat()
|
||||||
|
|
||||||
def checkBatch(timeline, deleted_count=0):
|
def checkBatch(timeline, deleted_count=0):
|
||||||
for toot in timeline:
|
for toot in timeline:
|
||||||
if 'id' in toot and 'archive' in config:
|
if 'id' in toot and 'archive' in config:
|
||||||
print(toot)
|
|
||||||
filename = os.path.join(config['archive'], str(toot['id']) + '.json')
|
filename = os.path.join(config['archive'], str(toot['id']) + '.json')
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
f.write(json.dumps(toot, indent=4, default=jsondefault))
|
f.write(json.dumps(toot, indent=4, default=jsondefault))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user