Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating Evernote notes with Python

I'm trying to update a note in Evernote. I set a filter, get notes list and I can also change the note's title. But when I try to change note content, nothing happens.

from evernote.api.client import EvernoteClient
import evernote.edam.type.ttypes as Types
from evernote.edam.notestore.ttypes import NoteFilter, NotesMetadataResultSpec
client = EvernoteClient(token="xxxxx", sandbox=True)
note_store = client.get_note_store()
updated_filter = NoteFilter(words='abaco')
result_list = note_store.findNotesMetadata(updated_filter, 0, 10000, NotesMetadataResultSpec(includeTitle=True))
for note in result_list.notes:
    print "----- TITLE -----\n%s\n----- GUID -----\n%s\n----- CONTENT -----\n%s" % (note.title, note.guid, note_store.getNoteContent(note.guid))
    note.title = "pippo"
    note.guid = note.guid
    note.content = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">'
    note.content += '<en-note>Note updated</en-note>'
    note = note_store.updateNote(note)

I receive no error but the note is not updated.

I'm using Python 2.7.

Thanks in advance!

like image 708
Gianx Avatar asked Oct 20 '22 12:10

Gianx


1 Answers

The return value of NoteStore#findNotesMetadata is NotesMetadataList that contains NoteMetadata, not Note object. In order to update notes, you should call NoteStore#getNote first, update the field and call NoteStore#updateNote.

like image 170
kentaro Avatar answered Oct 23 '22 06:10

kentaro