Created
December 9, 2022 09:16
-
-
Save davidag/2b3e43946bb1f138d5e322189b6d024c to your computer and use it in GitHub Desktop.
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
import argparse | |
import json | |
# This script extracts just notes as html. No notebooks, topics or tags. | |
parser = argparse.ArgumentParser(description="Extract html notes from a notesnook backup") | |
parser.add_argument("backupfile", action="store") | |
args = parser.parse_args() | |
with open(args.backupfile, mode="rt") as f: | |
data = json.load(f)["data"] | |
for note_id in data["notes"]: | |
note = data[f"{note_id}_notes"] | |
# skip deleted notes | |
if "contentId" not in note: | |
continue | |
content_id = note["contentId"] | |
content_data = data[f"{content_id}_content"]["data"] | |
filename = "".join(x for x in note["title"] if x.isalnum()) | |
with open(filename + ".html", "wt") as f: | |
f.write(content_data) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment