Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    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
Esempio n. 4
0
    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)
Esempio n. 5
0
 def _process_notes(self, notebook_guid):
     """process notes in given notebook checking if any need to be synced to backup location"""
     note_filter = NoteFilter()
     note_filter.notebookGuid = notebook_guid
     result_spec = NotesMetadataResultSpec()
     # evernote api will return None for almost all fields unless set them on in metadata
     result_spec.includeTitle = True
     result_spec.includeUpdated = True
     offset = 0
     notes = self.note_store.findNotesMetadata(self.token, note_filter, offset, 250, result_spec)
     while offset < notes.totalNotes:
         for en in notes.notes:
             # only fetch actual note if has been updated since last time
             if en.guid not in self.tracking or en.updated != self.tracking[en.guid]:
                 note = self._create_note(en.guid)
                 self._save(note)
         offset += 250
         notes = self.note_store.findNotesMetadata(self.token, note_filter, offset, 250, result_spec)
     print 'synced %i notes to %s' % (self.cnt, self.local_dir)
     self.logger.info('synced %i notes to %s' % (self.cnt, self.local_dir))
Esempio n. 6
0
def find_recent_notes(recent_days=1):
    logger.info("function starting - find_recent_notes: %d", recent_days)
    filter = NoteFilter()
    filter.ascending = True
    filter.order = NoteSortOrder.UPDATED
    filter.words = "updated:day-" + str(recent_days)
    spec = NotesMetadataResultSpec()
    spec.includeTitle = True
    spec.includeUpdated = True

    offset = 0
    pagesize = 50
    while True:
        logger.info("fetching, offset: %d", offset)
        result = get_store().findNotesMetadata(token, filter, offset, pagesize, spec)
        logger.info("fetched %d out of %d notes", len(result.notes), result.totalNotes)
        for metadata in result.notes:
            yield note_by_guid(metadata.guid)

        offset += pagesize

        if result.totalNotes <= offset:
            break
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)