def findNotes(self, keywords, count, createOrder=False, offset=0): """ WORK WITH NOTES """ noteFilter = NoteStore.NoteFilter(order=Types.NoteSortOrder.RELEVANCE) noteFilter.order = getattr(Types.NoteSortOrder, self.noteSortOrder) if createOrder: noteFilter.order = Types.NoteSortOrder.CREATED if keywords: noteFilter.words = keywords meta = NotesMetadataResultSpec() meta.includeTitle = True meta.includeContentLength = True meta.includeCreated = True meta.includeUpdated = True meta.includeNotebookGuid = True meta.includeAttributes = True meta.includeTagGuids = True result = self.getNoteStore().findNotesMetadata(self.authToken, noteFilter, offset, count, meta) # Reduces the count by the amount of notes already retrieved count = max(count - len(result.notes), 0) # Evernote api will only return so many notes in one go. Checks for more # notes to come whilst obeying count rules while ((result.totalNotes != len(result.notes)) and count != 0): offset = len(result.notes) result.notes += self.getNoteStore().findNotesMetadata( self.authToken, noteFilter, offset, count, meta).notes count = max(count - len(result.notes), 0) return result
def findNotes(self, keywords, count, createOrder=False, offset=0): """ WORK WITH NOTES """ noteFilter = NoteStore.NoteFilter(order=Types.NoteSortOrder.RELEVANCE) noteFilter.order = getattr(Types.NoteSortOrder, self.noteSortOrder) if createOrder: noteFilter.order = Types.NoteSortOrder.CREATED if keywords: noteFilter.words = keywords meta = NotesMetadataResultSpec() meta.includeTitle = True meta.includeContentLength = True meta.includeCreated = True meta.includeUpdated = True meta.includeNotebookGuid = True meta.includeAttributes = True meta.includeTagGuids = True result = self.getNoteStore().findNotesMetadata(self.authToken, noteFilter, offset, count, meta) # Reduces the count by the amount of notes already retrieved count = max(count - len(result.notes), 0) # Evernote api will only return so many notes in one go. Checks for more # notes to come whilst obeying count rules while ((result.totalNotes != len(result.notes)) and count != 0): offset = len(result.notes) result.notes += self.getNoteStore().findNotesMetadata(self.authToken, noteFilter, offset, count, meta).notes count = max(count - len(result.notes), 0) return result
def findNotes(self, notebookId): """Fina all notes of a notebook Args: notebookId (str): notebook id eg: '9bf6cecf-d91e-4391-a034-199c744424db' Returns: Note list Raises: """ logging.debug("notebookId=%s", notebookId) # find all notes in notebook searchOffset = 0 # searchPageSize = 1000 # searchPageSize = 5000 searchPageSize = self.searchPageSize searchFilter = NoteStore.NoteFilter() searchFilter.order = NoteSortOrder.UPDATED searchFilter.ascending = False searchFilter.notebookGuid = notebookId logging.debug("searchFilter=%s", searchFilter) resultSpec = NotesMetadataResultSpec() resultSpec.includeTitle = True resultSpec.includeContentLength = True resultSpec.includeCreated = True resultSpec.includeUpdated = True resultSpec.includeDeleted = True resultSpec.includeNotebookGuid = True resultSpec.includeTagGuids = True resultSpec.includeAttributes = True resultSpec.includeLargestResourceMime = True resultSpec.includeLargestResourceSize = True logging.debug("resultSpec=%s", resultSpec) # foundNoteResult = self.noteStore.findNotesMetadata( # authenticationToken=self.authToken, # filter=searchFilter, # offset=searchOffset, # maxNotes=pageSize, # resultSpec=resultSpec # ) foundNoteResult = self.noteStore.findNotesMetadata( self.authToken, searchFilter, searchOffset, searchPageSize, resultSpec) logging.debug("foundNoteResult=%s", foundNoteResult) totalNotes = foundNoteResult.totalNotes logging.info("Total %d notes for notebook of guid=%s", totalNotes, notebookId) foundNoteList = foundNoteResult.notes return foundNoteList
def findNotes(self, keywords, count, createOrder=False, offset=0): """ WORK WITH NOTES """ noteFilter = NoteStore.NoteFilter(order=Types.NoteSortOrder.RELEVANCE) noteFilter.order = getattr(Types.NoteSortOrder, self.noteSortOrder) if createOrder: noteFilter.order = Types.NoteSortOrder.CREATED if keywords: noteFilter.words = keywords meta = NotesMetadataResultSpec() meta.includeTitle = True meta.includeContentLength = True meta.includeCreated = True meta.includeUpdated = True meta.includeNotebookGuid = True meta.includeAttributes = True return self.getNoteStore().findNotesMetadata(self.authToken, noteFilter, offset, count, meta)
from evernote.api.client import EvernoteClient from evernote.edam.notestore.ttypes import NoteFilter, NotesMetadataResultSpec devToken = "S=s1:U=8fc8e:E=150baa2e888:C=14962f1b8a8:P=1cd:A=en-devtoken:V=2:H=00145dc7735d3b5e6f2a70b504aba079" client = EvernoteClient(token = devToken) noteStore = client.get_note_store() filter = NoteFilter() filter.ascending = False spec = NotesMetadataResultSpec() spec.includeTitle = True spec.includeCreated = True spec.includeUpdated = True spec.includeTagGuids = True spec.includeAttributes = True noteList = noteStore.findNotesMetadata(devToken, filter, 0, 100, spec) for n in noteList.notes: print(n.guid) print(n.title) print(n.tagGuids)