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 getToDos(day):
    dev_token = getToken(False)
    client = EvernoteClient(token=dev_token, sandbox=False)
    notestore = client.get_note_store()
    ToDoTags = getToDoTags(dev_token, notestore)
    dayGuid = getDayTag(day, notestore)
    myfilter = NoteFilter()
    spec = NotesMetadataResultSpec()
    spec.includeTitle = True
    mylist = []
    noteguids = {}
    TODOLIST = dict()

    notebody = ""

    for tag, guid in ToDoTags.iteritems():
        mylist = []
        mylist.append(guid)
        mylist.append(dayGuid)
        myfilter.tagGuids = mylist
        notes = notestore.findNotesMetadata(dev_token, myfilter, 0, 100, spec)
        TODOLIST[tag] = []
        for note in notes.notes:
            TODOLIST[tag].append(note.title)

    return TODOLIST
Esempio n. 4
0
 def search_notes(self, words):
     filter = NoteFilter(words=words)
     spec = NotesMetadataResultSpec()
     spec.includeTitle = True
     note_list = self.note_store.findNotesMetadata(self.token, filter, 0,
                                                   100, spec)
     return note_list
Esempio n. 5
0
 def get_notes(self, *tag_names):
     """Return a list of notes matching the tag_names"""
     note_filter = NoteFilter()
     note_filter.tagGuids = [self.tags[tn].guid for tn in tag_names if tn]
     result_spec = NotesMetadataResultSpec()
     result_spec.includeTitle = True
     result_spec.includeTagGuids = True
     notes = self.note_store.findNotesMetadata(note_filter, 0, 100, result_spec)
     for note in notes.notes:
         yield note
Esempio n. 6
0
    def __get_all_notes_metadata_from_notebook(self, notebook_guid, note_store,
                                               token):
        notes_filter = NoteFilter(notebookGuid=notebook_guid)

        spec = NotesMetadataResultSpec()
        spec.includeTitle = True

        allNotesFromNotebook = note_store.findNotesMetadata(
            token, notes_filter, 0, 250, spec)
        return allNotesFromNotebook.notes
Esempio n. 7
0
 def getnotes(self,auth_token, nb_guid, fun):
     spec = NotesMetadataResultSpec()
     spec.includeTitle=True
     filter=NoteFilter()
     filter.notebookGuid=nb_guid
     note_store = self.client.get_note_store()
     notelist = []
     for i in range(0,500,250):
         notes = note_store.findNotesMetadata(auth_token, filter, i, i+250, spec)
         notelist.extend([fun(n) for n in notes.notes])
     return notelist
Esempio n. 8
0
 def find_notes_filter_by_tag_guids(self, guids_list):
     evernote_filter = NoteFilter()
     evernote_filter.ascending = False
     evernote_filter.tagGuids = guids_list
     spec = NotesMetadataResultSpec()
     spec.includeTitle = True
     note_list = self.noteStore.findNotesMetadata(self.token, evernote_filter, 0, 10000, spec)
     guids = []
     for note in note_list.notes:
         guids.append(note.guid)
     return guids
Esempio n. 9
0
 def listar_notes(self):
     note_store = self.client.get_note_store()
     filter = NoteFilter()
     filter.word = "notebook:Faculdade"
     spec = NotesMetadataResultSpec()
     spec.includeTitle = True
     all_notes = note_store.findNotesMetadata(self.dev_token, filter, 0, 10, spec)
     for note in all_notes.notes:
         print(note.title)
         conteudo = note_store.getNoteContent(note.guid)
         print(conteudo)
Esempio n. 10
0
 def getnotes(self, auth_token, nb_guid, fun):
     spec = NotesMetadataResultSpec()
     spec.includeTitle = True
     filter = NoteFilter()
     filter.notebookGuid = nb_guid
     note_store = self.client.get_note_store()
     notelist = []
     for i in range(0, 500, 250):
         notes = note_store.findNotesMetadata(auth_token, filter, i,
                                              i + 250, spec)
         notelist.extend([fun(n) for n in notes.notes])
     return notelist
Esempio n. 11
0
 def find_notes_filter_by_tag_guids(self, guids_list):
     evernote_filter = NoteFilter()
     evernote_filter.ascending = False
     evernote_filter.tagGuids = guids_list
     spec = NotesMetadataResultSpec()
     spec.includeTitle = True
     note_list = self.noteStore.findNotesMetadata(self.token,
                                                  evernote_filter, 0, 10000,
                                                  spec)
     guids = []
     for note in note_list.notes:
         guids.append(note.guid)
     return guids
Esempio n. 12
0
    def list_notes(self, notebook):
        # ノート検索条件を指定。ノートブックのIDを指定。更新日でソート
        note_filter = NoteFilter()
        note_filter.notebookGuid = notebook.guid
        note_filter.order = NoteSortOrder.UPDATED

        # ノート検索結果のフォーマットを指定。タイトルを含む
        result_format = NotesMetadataResultSpec()
        result_format.includeTitle = True

        # ノートのメタデータリストを取得
        note_meta_list = self.note_store.findNotesMetadata(note_filter, 0, 10, result_format)
        return [Note(self, note_meta) for note_meta in note_meta_list.notes]
Esempio n. 13
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. 14
0
def find_note(keywords):
    """
    Find note content by keyword.
    :param keywords: (str) keyword for search.
    :return: (str) first result content.
    """
    from evernote.edam.notestore.ttypes import NoteFilter, NotesMetadataResultSpec
    dev_token, note_store = connect_note()
    search = NoteFilter()
    search.words = keywords
    search.ascending = False

    spec = NotesMetadataResultSpec()
    spec.includeTitle = True

    our_note_list = note_store.findNotesMetadata(dev_token, search, 0, 100, spec)
    note_content = note_store.getNoteContent(dev_token, our_note_list.notes[0].guid)
    return note_content
Esempio n. 15
0
def get_ev_notes():
    dev_token = app.config['EN_DEV_TOKEN']
    notestore_url = app.config['EN_NOTESTORE_URL']
    nb_guid = app.config['EN_NB_GUID']

    client = EvernoteClient(token=dev_token)
    note_store = client.get_note_store()

    filt = NoteFilter()
    filt.notebookGuid = nb_guid

    spec = NotesMetadataResultSpec()
    spec.includeTitle = True

    notemetalist = note_store.findNotesMetadata(dev_token, filt, 0, 100, spec)
    notes = []
    for note_data in notemetalist.notes:
        note = note_store.getNote(dev_token, note_data.guid, True, True, True,
                                  True)

        title = note.title
        author = note.attributes.author
        date = note.updated
        url = note.attributes.sourceURL
        cont = note.content
        note_tags = []

        tag_guids = note.tagGuids
        if tag_guids is not None:
            for tag_guid in tag_guids:
                tag = note_store.getTag(dev_token, tag_guid)
                note_tags.append({'guid': tag_guid, 'name': tag.name})

        notes.append({
            'guid': note_data.guid,
            'title': title,
            'date_modified': date,
            'author': author,
            'content': cont,
            'tags': note_tags
        })

    #print notes
    return dumps(notes)
Esempio n. 16
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. 17
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. 18
0
def find_note(keywords):
    """
    Find note content by keyword.
    :param keywords: (str) keyword for search.
    :return: (str) first result content.
    """
    from evernote.edam.notestore.ttypes import NoteFilter, NotesMetadataResultSpec
    dev_token, note_store = connect_note()
    search = NoteFilter()
    search.words = keywords
    search.ascending = False

    spec = NotesMetadataResultSpec()
    spec.includeTitle = True

    our_note_list = note_store.findNotesMetadata(dev_token, search, 0, 100,
                                                 spec)
    note_content = note_store.getNoteContent(dev_token,
                                             our_note_list.notes[0].guid)
    return note_content
Esempio n. 19
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
Esempio n. 20
0
def get_ev_notes():
  dev_token = app.config['EN_DEV_TOKEN']
  notestore_url = app.config['EN_NOTESTORE_URL']
  nb_guid = app.config['EN_NB_GUID']
 
  client = EvernoteClient(token=dev_token)
  note_store = client.get_note_store()

  filt = NoteFilter()
  filt.notebookGuid = nb_guid

  spec = NotesMetadataResultSpec()
  spec.includeTitle = True

  notemetalist = note_store.findNotesMetadata(dev_token, filt, 0, 100, spec)
  notes = []
  for note_data in notemetalist.notes:
    note = note_store.getNote(dev_token, note_data.guid, True, True, True, True)

    title = note.title
    author = note.attributes.author
    date = note.updated
    url = note.attributes.sourceURL    
    cont = note.content
    note_tags = []

    tag_guids = note.tagGuids
    if tag_guids is not None:
      for tag_guid in tag_guids:
        tag = note_store.getTag(dev_token, tag_guid)
        note_tags.append({'guid': tag_guid, 'name': tag.name})

    notes.append({'guid': note_data.guid, 'title': title, 'date_modified': date, 'author': author, 'content': cont, 'tags': note_tags})
  
  #print notes
  return dumps(notes)
Esempio n. 21
0
def hello():
    global latestNote
    global updated
    global created

    auth_token = "S=s1:U=6eb51:E=146ce55b0ee:C=13f76a484f1:P=1cd:A=en-devtoken:V=2:H=5d05df82a62652c0ed8f2e544df37758"

    if auth_token == "":
        print "Please fill in your developer token"
        print "To get a developer token, visit " \
                "https://sandbox.evernote.com/api/DeveloperToken.action"
        exit(1)

    client = EvernoteClient(token=auth_token, sandbox=True)
    user_store = client.get_user_store()

    version_ok = user_store.checkVersion(
            "Evernote EDAMTest (Python)",
            UserStoreConstants.EDAM_VERSION_MAJOR,
            UserStoreConstants.EDAM_VERSION_MINOR
            )
    #print "Is my Evernote API version up to date? ", str(version_ok)
    #print ""
    if not version_ok:
        exit(1)

    note_store = client.get_note_store()

    # List all of the notebooks in the user's account
    notebooks = note_store.listNotebooks()
    nb = None
    #print "Found ", len(notebooks), " notebooks:"
    for notebook in notebooks:
        #print "  * ", notebook.name
        if notebook.name == "Note":
            nb = notebook;
            break

    if not nb:
        print "Note book is not found in your account"
        exit(1)

    filter = NoteFilter()
    filter.notebookGuid = nb.guid
    filter.order = Types.NoteSortOrder.UPDATED

    spec = NotesMetadataResultSpec()
    spec.includeTitle = True

    noteML = note_store.findNotesMetadata(auth_token, filter, 0, 1, spec)
    content = ""
    content_org = ""
    content_new = ""

    for note in noteML.notes:
        noteID = note.guid

        if note.created == created and note.updated == updated:
            content = latestNote
        else:
            content = note_store.getNoteContent(auth_token, noteID);
            latestNote = content
            created = note.created
            updated = note.updated

        m = re.search(r'<en-note><div>(?P<content>.+)</div></en-note>', content)
        if m:
            content_org = "%s\n" % m.group('content')
            content = re.sub('<[^>]*>', '', content_org)
            line = '''<tspan x="%d" y="%d">%s</tspan>'''

            n = 57
            m = 0
            index = n
            y_aix = 450
            length = len(content)

            while index <= length:
                while ord(content[index-1]) < 128 and content[index-1] != ' ' and index != length:
                    index = index - 1
                index = ( m+n if index == m else index)
                content_new += line%(300, y_aix, content[m:index])

                if index == length:
                    break
                y_aix = y_aix + 30
                m = index
                index = index + n
                if index > length:
                    index = length

        content_new = content_new.decode('utf-8')
        content_org = content_org.decode('utf-8')

    #output = weather.getAndDraw()
    output = getWeather.w2svg("forecast")

    #output = codecs.open('weather-script-output.svg', 'r', encoding='utf-8').read()
    output = output.replace('NOTE_TEXT', content_new)
    output = output.replace('NOTE_ORG', content_org)

    ## Write output
    #codecs.open('weather.svg', 'w', encoding='utf-8').write(output)

    return output
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)