Created
January 24, 2024 13:18
-
-
Save qaqland/560dcd6ae032dd9141c859415470c59e to your computer and use it in GitHub Desktop.
Export data of purewriter time machine 导出纯纯写作时光机数据
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unpack file.pwb and get the db file | |
# edit $your-sqlite-db-file to yours path | |
# use pipe to export to txt | |
import sqlite3, datetime, json | |
conn = sqlite3.connect("your-sqlite-db-file") | |
conn.row_factory = sqlite3.Row | |
cur = conn.cursor() | |
query = "SELECT content, createdTime FROM UserMessage ORDER BY createdTime" | |
rows = cur.execute(query).fetchall() | |
msgs = [dict(row) for row in rows] | |
conn.close() | |
for msg in msgs: | |
timestamp = msg["createdTime"] | |
timestamp = datetime.datetime.fromtimestamp(timestamp / 1000.0) | |
timestamp = timestamp.strftime("%Y-%m-%d %H:%M:%S") | |
print(f"\n[{timestamp}]") | |
json_string = msg["content"].decode("utf-8") | |
json_data = json.loads(json_string) | |
print(json_data["text"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment