From be8ac2a7286b48798490fd49f9aab431b70ac474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9C=D0=B0=D0=B9=D0=BE=D1=80=D0=BE=D0=B2?= Date: Sun, 12 Nov 2023 09:49:32 +0300 Subject: [PATCH] add code --- .gitignore | 1 + keep-to-md.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 .gitignore create mode 100644 keep-to-md.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/keep-to-md.py b/keep-to-md.py new file mode 100644 index 0000000..670a050 --- /dev/null +++ b/keep-to-md.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +import os +import json +from datetime import datetime +txt = open('text.md', 'w', encoding='utf-8') +for file in os.listdir("E:\code\keep"): + if file.endswith(".json"): + with open(file, 'r', encoding='utf-8') as f: + text = json.load(f) + print(file) + if text['title'] != "": + txt.write('**' + text['title'] + '**' + '\n') + if 'textContent' in text: + txt.write(text['textContent'] + '\n') + if 'text' in text: + txt.write(text['text'] + '\n') + if 'labels' in text.keys(): + for i in text['labels']: + txt.write('`' + i['name'] + '`' + '\n') + ts = int(text['userEditedTimestampUsec'])//1000000 + t = datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') + txt.write('`' + t + '`' + '\n\n---\n') \ No newline at end of file