Created
March 10, 2021 21:47
-
-
Save graphaelli/5dc7944167c9f2c0e595b3c8daefb3ae 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
#!/usr/bin/env python | |
import hashlib | |
import binascii | |
import os | |
from evernote.api.client import EvernoteClient | |
from evernote.edam.notestore.ttypes import NoteFilter, NotesMetadataResultSpec | |
auth_token = "" | |
sandbox = False | |
china = False | |
client = EvernoteClient(token=auth_token, sandbox=sandbox,china=china) | |
note_store = client.get_note_store() | |
notebooks = note_store.listNotebooks() | |
print("Found ", len(notebooks), " notebooks:") | |
for notebook in notebooks: | |
print(notebook.name) | |
if notebook.name == "interviews": | |
continue | |
outdir = "interview" | |
elif notebook.name == "daily log": | |
outdir = "daily" | |
else: | |
continue | |
limit = 10 | |
offset = 0 | |
while True: | |
meta = note_store.findNotesMetadata( | |
NoteFilter(notebookGuid=notebook.guid), | |
offset, limit, | |
NotesMetadataResultSpec(includeTitle=True) | |
) | |
# Out[2]: NotesMetadataList(startIndex=0, totalNotes=1, notes=..., stoppedWords=None, searchedWords=None, updateCount=3) | |
# Out[3]: [NoteMetadata(guid='94d5bdd2-f402-4924-bbde-758ac5b3899e', title='Test note from EDAMTest.py', contentLength=None, created=None, updated=None, deleted=None, updateSequenceNum=None, notebookGuid=None, tagGuids=None, attributes=None, largestResourceMime=None, largestResourceSize=None)] | |
for note in meta.notes: | |
if note.deleted: | |
continue | |
if os.path.exists(os.path.join(outdir, note.title + ".html")): | |
print("already sync'd", note.title) | |
continue | |
note.title = note.title.replace("/", "-") | |
if note.title[0:4] in ("2019", "2020", "2021"): | |
continue | |
print("syncing", note.title) | |
content = note_store.getNoteContent(note.guid) | |
try: | |
with open(os.path.join(outdir, note.title + ".html"), "w") as out: | |
out.write(content) | |
except Exception as e: | |
print("FAILED", note.title, e) | |
offset += limit | |
if meta.totalNotes < offset: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment