-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_memos.py
28 lines (24 loc) · 924 Bytes
/
generate_memos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
def generate_memos(input_file, output_file):
with open(input_file, 'r', encoding='utf-8') as f:
statuses = json.load(f)
memos = []
for status in statuses:
memo = {
"created_at": status.get("created_at"),
"url": status.get("url"),
"content": status.get("content"),
"application": status.get("application"),
"media_attachments": [
{
"url": attachment.get("url"),
"preview_url": attachment.get("preview_url"),
} for attachment in status.get("media_attachments", [])
],
"tags": status.get("tags", []),
}
memos.append(memo)
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(memos, f, ensure_ascii=False, indent=4)
if __name__ == "__main__":
generate_memos('status.json', 'memos.json')