Fix for new standard notes archives using zip files. #9

Merged
jcady merged 1 commits from upgrade-latest-sn into master 2021-05-23 17:20:18 +02:00
2 changed files with 7 additions and 8 deletions
Showing only changes of commit c2a7416652 - Show all commits
+2 -4
View File
@@ -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: ## Usage:
```bash ```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 ## Tutorial
+5 -4
View File
@@ -3,11 +3,12 @@ import html
import datetime import datetime
import re import re
from sys import argv from sys import argv
import zipfile
source = argv[1] if len(argv) > 1 else 'notes.txt' source = argv[1] if len(argv) > 1 else 'notes.zip'
data = json.load(open(source))
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): def text_from_html(title, text):
# Clear title # Clear title
@@ -65,6 +66,6 @@ final_file += '''</en-export>''' # close root tag
# Save # 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) text_file.write(final_file)