From c2a7416652a887dc67df0f20bd5ca6ed94e7ebd8 Mon Sep 17 00:00:00 2001 From: Jay Cady Date: Sat, 22 May 2021 17:01:05 -0700 Subject: [PATCH] Fix for new standard notes archives using zip files. --- README.md | 6 ++---- standard-notes-to-enex.py | 9 +++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1c7b3a2..af3bc34 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,9 @@ -# Attention: It has been reported that the following methodology is no longer valid as it exports Starndard Notes in a new format. A pull request is needed to fix it. - ## Usage: ```bash -python3 standard-notes-to-enex.py SN_Archive.txt +python3 standard-notes-to-enex.py SN_Archive.zip ``` -If a name like `SN_Archive.txt` is not provided, the script will assume your file is called `notes.txt`. +If a name like `SN_Archive.zip` is not provided, the script will assume your file is called `notes.zip`. ## Tutorial diff --git a/standard-notes-to-enex.py b/standard-notes-to-enex.py index 5d93af9..7cac455 100755 --- a/standard-notes-to-enex.py +++ b/standard-notes-to-enex.py @@ -3,11 +3,12 @@ import html import datetime import re from sys import argv +import zipfile -source = argv[1] if len(argv) > 1 else 'notes.txt' - -data = json.load(open(source)) +source = argv[1] if len(argv) > 1 else 'notes.zip' +with zipfile.ZipFile(source, 'r') as zip_ref: + data = json.loads(zip_ref.read('Standard Notes Backup and Import File txt.txt').decode('utf-8')) def text_from_html(title, text): # Clear title @@ -65,6 +66,6 @@ final_file += '''''' # close root tag # Save -with open("notes.enex", "w") as text_file: +with open("notes.enex", "w", encoding='utf-8') as text_file: text_file.write(final_file) -- 2.54.0