예제 #1
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
예제 #2
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
예제 #3
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
        meta.includeLargestResourceMime = True
        meta.includeLargestResourceSize = 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
예제 #4
0
파일: utils.py 프로젝트: Markinhos/Drawer
 def get_metadata_notes(self, evernote_profile, project):
     filter = NoteStore.NoteFilter()
     filter.notebookGuid = self.get_notebook(evernote_profile, project).guid
     rspec = NotesMetadataResultSpec()
     rspec.includeUpdateSequenceNum = True
     new_notes = self.note_store.findNotesMetadata(self.auth_token, filter , 0, 20, rspec)
     return new_notes
예제 #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
예제 #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
예제 #7
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
예제 #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
예제 #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)
예제 #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
예제 #11
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
예제 #12
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
예제 #13
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]
예제 #14
0
def load_notes(note_store,accessToken,type,guid,display):

	# Connecting to Evernote
    notes = []
    offset = 0
    maxNotes = 100
    # Creating NoteFilter
    if (type == "search"):
    	noteFilter = NoteFilter(order=NoteSortOrder.UPDATED,words=guid)
    elif (type == "tag"):
    	noteFilter = NoteFilter(order=NoteSortOrder.UPDATED,tagGuids=[guid])
    else:
    	noteFilter = NoteFilter(order=NoteSortOrder.UPDATED,notebookGuid=guid)

        if int(display) == safeglobals.NOTES_ENCRYPTED_ONLY:
            noteFilter.words = safeglobals.ENCRYPTED_PREFIX[:-2]
        elif int(display) == safeglobals.NOTES_UNENCRYPTED_ONLY:
            noteFilter.words = "-%s" % safeglobals.ENCRYPTED_PREFIX[:-2]

    # Creating ResultSpec
    result_spec = NotesMetadataResultSpec(includeTitle=True,includeCreated=True,includeUpdated=True,includeNotebookGuid=True)
    
    # Getting the result
    response = note_store.findNotesMetadata(accessToken, noteFilter, offset, maxNotes, result_spec)

    # Parsing the list of NotesMetadata
    for metadata in response.notes:
        notes.append({"guid":metadata.guid,"updated":millisToDate(metadata.updated),"created":millisToDate(metadata.created),"title":metadata.title})

    # Caching notes
    cache_notes(notes,type,guid)
    return notes
예제 #15
0
def searchNote(client, note_store, notebooks, notebookname, notename):

    # 対象のノートブックを検索
    copied_notebook_guid = None
    for notebook in notebooks:
        if notebook.name == notebookname:
            copied_notebook_guid = notebook.guid
            break
    # 該当するノートブックが存在しない場合にはエラー
    if copied_notebook_guid == None:
        return "", ""

    # 対象のノートを検索
    offset = 0
    max_notes = 400
    filter = NoteFilter(notebookGuid=copied_notebook_guid)
    result_spec = NotesMetadataResultSpec(includeTitle=True)
    result_list = note_store.findNotesMetadata(EVERNOTE_DEV_TOKEN, filter,
                                               offset, max_notes, result_spec)
    copied_note_guid = None
    for note in result_list.notes:
        if note.title == notename:
            copied_note_guid = note.guid
            break
    # 該当するノートが存在しない場合にはエラー
    if copied_note_guid == None:
        return "", ""

    return copied_notebook_guid, copied_note_guid
예제 #16
0
def view_notebook_detail(request):
    if request.method == "POST":
        notes_values = ""
        try:
            user_obj = User.objects.get(username=request.user.get_username())
            evernote_token = user_obj.evernotecredential.evernote_token
            client = get_evernote_client(evernote_token)
            note_store = client.get_note_store()
            userStore = client.get_user_store()
            updated_filter = NoteFilter(
                notebookGuid=request.POST.get("guid_", ""))
            offset = 0
            max_notes = 10
            result_spec = NotesMetadataResultSpec(includeTitle=True)
            notes = note_store.findNotesMetadata(updated_filter, offset,
                                                 max_notes, result_spec)
            notes_values = notes.notes
        except Exception as e:
            print "{}:{}".format(e.args, e.message)
            raise

        return render(
            request, 'notes.html', {
                'notes': notes_values,
                'notebook_id': request.POST.get("guid_", ""),
                'username': request.user.get_username()
            })
예제 #17
0
 def get_page(start):
     result_spec = NotesMetadataResultSpec(includeTitle=True,
                                           includeCreated=True,
                                           includeUpdated=True,
                                           includeContentLength=True)
     return self._note_store().findNotesMetadata(
         note_filter, start, EVERNOTE_MAX_PAGE_SIZE, result_spec)
예제 #18
0
def get_notes():
    auth_token = request.args.get('auth_token')
    if not auth_token:
        return

    notebook = request.args.get('notebook')
    if not notebook:
        return

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

    offset = 0
    max_notes = 1000
    filter = NoteFilter(order=Types.NoteSortOrder.UPDATED,
                        notebookGuid=notebook)
    result_spec = NotesMetadataResultSpec(includeTitle=True)
    metadata = note_store.findNotesMetadata(auth_token, filter, offset,
                                            max_notes, result_spec)

    notes = []
    for n in metadata.notes:
        content = note_store.getNoteContent(auth_token, n.guid)
        notes.append({
            'guid': n.guid,
            'content': unicode(ENMLToHTML(content)),
            'title': n.title
        })

    return jsonify(notes=notes)
예제 #19
0
파일: main.py 프로젝트: broSysX64/bit4
def list_notes(note_store, notebook):

    filter = NoteFilter(notebookGuid=notebook.guid)
    spec = NotesMetadataResultSpec(includeTitle=True,
                                   includeContentLength=True,
                                   includeCreated=True,
                                   includeUpdated=True)

    notes = []
    offset = 0
    remain = EDAM_USER_NOTES_MAX

    while remain > 0:
        notes_list = note_store.findNotesMetadata(filter, offset, remain, spec)

        # See http://dev.evernote.com/doc/reference/NoteStore.html#Struct_NotesMetadataList
        remain = notes_list.totalNotes - (notes_list.startIndex +
                                          len(notes_list.notes))
        offset += len(notes_list.notes)

        notes.extend(notes_list.notes)

    for note in notes:
        created_time = datetime.datetime.fromtimestamp(note.created *
                                                       TIMESTAMP_RESOLUTION)
        updated_time = datetime.datetime.fromtimestamp(note.updated *
                                                       TIMESTAMP_RESOLUTION)
        title = note.title.decode('utf-8')
        print(u'  {} ({}) ctime={} mtime={}'.format(title, note.guid,
                                                    created_time,
                                                    updated_time))
예제 #20
0
파일: note.py 프로젝트: YujiShen/TimeReport
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
예제 #21
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)
 def retrieve_note_content(self):
     note_filter = NoteFilter(order=2,
                              notebookGuid=self.get_notebook_guid())
     result_spec = NotesMetadataResultSpec(includeTitle=True)
     notesMetadata = self._note_store.findNotesMetadata(
         note_filter, 0, 1, result_spec)
     if notesMetadata.notes:
         note_guid = notesMetadata.notes[0].guid
         return self._note_store.getNoteContent(note_guid)
     return 'ERROR: There are no notes in the notebook.'
예제 #23
0
파일: client.py 프로젝트: semtle/not
    def search(self, title=None, max_results=1):
        """ bumble through evernote's weird api to find a note. """
        if title:
            title = "intitle:'{title}'".format(title=title)

        notefilter = NoteFilter(order=NoteSortOrder.UPDATED, words=title)
        finder = self.store.findNotesMetadata(notefilter, 0, max_results,
                                              NotesMetadataResultSpec())
        notes = finder.notes
        if notes:
            return [note.guid for note in finder.notes]
예제 #24
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
예제 #25
0
파일: sync.py 프로젝트: gerlachry/mynote
 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))
 def retrieve_note(self):
     note_filter = NoteFilter(order=2,
                              notebookGuid=self.get_notebook_guid())
     result_spec = NotesMetadataResultSpec(includeTitle=True)
     notesMetadata = self._note_store.findNotesMetadata(
         note_filter, 0, 1, result_spec)
     if notesMetadata.notes:
         note_guid = notesMetadata.notes[0].guid
         retrieved_note = self._note_store.getNote(note_guid, False, False,
                                                   True, False)
         for resource in retrieved_note.resources:
             print resource
예제 #27
0
    def get_note_dict_in_filterlist(self, filterList):
        notebook_guids = []
        notedictlist = []
        for filter in filterList:
            notelist = self.note_store.findNotesMetadata(
                self.auth_token, filter, 0, 100,
                NotesMetadataResultSpec(includeTitle=True))
            for note in notelist.notes:
                note_content = self.note_store.getNoteContent(note.guid)
                d = {"title": note.title, "content_xml": note_content}
                notedictlist.append(d)

        return notedictlist
예제 #28
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
예제 #29
0
def get_all_notes_in_notebook(notebook):
    guid = notebook.guid
    filter = NoteFilter(notebookGuid=guid)

    #def __init__(self, includeTitle=None, includeContentLength=None, includeCreated=None, includeUpdated=None, includeDeleted=None, includeUpdateSequenceNum=None, includeNotebookGuid=None, includeTagGuids=None, includeAttributes=None, includeLargestResourceMime=None, includeLargestResourceSize=None,):
    resultsSpec = NotesMetadataResultSpec(includeTitle=True)
    fetch_results = _get_note_store().findNotesMetadata(
        filter, 0, 10, resultsSpec)
    real_notes = []
    for n in fetch_results.notes:
        #note = _get_note_store().getNote(n.guid, withContent=True, withResourcesData=False, withResourcesRecognition=False, withResourcesAlternateData=False)
        note = _get_note_store().getNote(n.guid, True, False, False, False)
        real_notes.append(note)
    return real_notes
예제 #30
0
 def get_notes(self, note_count):
     note_store = self.client.get_note_store()
     noteFilter = NoteStore.NoteFilter(ascending=False,
                                       order=Types.NoteSortOrder.CREATED)
     spec = NotesMetadataResultSpec(includeTitle=True)
     try:
         notes = note_store.findNotes(noteFilter, 0, note_count)
         #notes = note_store.findNotesMetadata(note_store.token, noteFilter, 0, note_count, spec)
         if notes.totalNotes:
             print "notes tota is ", notes.totalNotes
             return notes
     except Exception, e:
         print "Can't get notes ! Exception: ", e
         return None
예제 #31
0
def et_list_notes(**kwa):
    """
    Can we get a list of notes?
    """
    if kwa['d']:
        pdb.set_trace()
    client = get_authorized_client('full')
    note_store = client.get_note_store()
    flt = NoteFilter(words="")
    spec = NotesMetadataResultSpec(includeTitle=True)
    md_list = note_store.findNotesMetadata(flt, 0, 250, spec)

    for note in md_list.notes:
        print(note.title)
        print("   {}".format(note.guid))
예제 #32
0
 def find_notes(self,
                count=1,
                keywords=None,
                notebook_guid=None,
                tag_guids=None,
                order=ttypes.NoteSortOrder.CREATED):
     spec = NotesMetadataResultSpec(includeTitle=True,
                                    includeUpdated=True,
                                    includeTagGuids=True)
     note_filter = NoteFilter(words=keywords,
                              order=order,
                              notebookGuid=notebook_guid,
                              tagGuids=tag_guids)
     return self.noteStore.findNotesMetadata(self.client.token, note_filter,
                                             0, count, spec)
예제 #33
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)
예제 #34
0
def _get_evernote_data():
    """Helper method that gets data.

    Update to give more control to which notes you get.
    """
    # Set up the NoteStore client
    client = EvernoteClient(token=DEV_TOKEN)
    note_store = client.get_note_store()

    note_filter = NoteFilter(order=NoteSortOrder.UPDATED)
    result_spec = NotesMetadataResultSpec(includeTitle=True,
                                          includeCreated=True)

    # Make API call.
    return note_store.findNotesMetadata(DEV_TOKEN, note_filter, 0, 100,
                                        result_spec)
예제 #35
0
def getEvernoteResources(config, notebook_guid):
    resources = []
    client = EvernoteClient(token=config["en_devtoken"],
                            sandbox=config["en_sandbox"] == "True")
    noteStore = client.get_note_store()
    # get notes from a specific notebook
    noteFilter = NoteFilter(notebookGuid=notebook_guid)
    result_spec = NotesMetadataResultSpec(includeTitle=True)

    filteredNotes = noteStore.findNotesMetadata(noteFilter, 0, 10, result_spec)
    notebooks = noteStore.listNotebooks()

    for n in filteredNotes.notes:
        print n.title, n.guid
        fullnote = noteStore.getNote(n.guid, True, True, False, True)
        for r in fullnote.resources:
            print r.guid
            resources += [(r.guid, r.data.body)]

    return resources
예제 #36
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)
예제 #37
0
def insert_notes(tag):
    result = []
    offset = 0  # 偏移0
    max_notes = 99999
    spec = NotesMetadataResultSpec(1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0)
    updated_filter = NoteFilter(order=NoteSortOrder.UPDATED,
                                tagGuids=[tag.guid])
    notes = note_store.findNotesMetadata(updated_filter, offset, max_notes,
                                         spec)
    if notes.notes:
        for note in notes.notes:
            node_file = {}
            node_file["data"] = {}
            node_file["data"]["text"] = note.title
            node_file["data"]["connectColor"] = "#DE4F41"
            node_file["data"]["connect-color"] = "#DE4F41"
            node_file["data"][
                "hyperlink"] = "https://app.yinxiang.com/shard/s61/nl/12899539/" + note.guid

            result.append(copy.deepcopy(node_file))
    return result
예제 #38
0
def get_recipes(tag, refresh):
    key = vmenu.app.config['CACHE_PREFIX'] + 'recipes-' + tag
    results = cache.get(key)

    if results is None or refresh:
        if refresh:
            logging.info('Explicitly refreshing %s', key)
        else:
            logging.info('Cache miss for %s', key)
        client = trace(get_client)
        notestore = trace(client.get_note_store)
        notebook = trace(get_notebook, notestore, vmenu.app.config['NOTEBOOK'])

        tag_guids = [tag]
        filter = NoteFilter(notebookGuid=notebook.guid, tagGuids=tag_guids)
        offset = 0
        max_notes = 500
        result_spec = NotesMetadataResultSpec(includeTitle=True)
        notes_result = tracen('Evernote.note_store.findNotesMetadata',
                              notestore.findNotesMetadata, filter, offset,
                              max_notes, result_spec)
        notes = sorted(notes_result.notes,
                       key=lambda NoteMetadata: NoteMetadata.title)
        results = []

        def process_notes():
            url_prefix = trace(get_url_prefix)
            for n in notes:
                result = {
                    'guid': n.guid,
                    'title': n.title,
                    'thumbnail': trace(get_thumbnail, url_prefix, n.guid)
                }
                results.append(result)

        trace(process_notes)

        cache.set(key, results, timeout=vmenu.app.config['CACHE_TIMEOUT'])

    return results
예제 #39
0
def frontendSearch(listOfStrings, userToken):

    # change auth_token to user token eventually
    auth_token = "S=s1:U=8f624:E=14fa3a78539:C=1484bf65560:P=1cd:A=en-devtoken:V=2:H=a71244ac77727e1a6a2fcb5286ab435a"
    client = EvernoteClient(token=auth_token)  # change to userToken eventually
    note_store = client.get_note_store()
    updated_filter = NoteFilter(order=NoteSortOrder.UPDATED, words="")
    offset = 0
    max_notes = 999

    result_spec = NotesMetadataResultSpec(includeTitle=True)

    for string in listOfStrings:
        updated_filter.words += string + " "

    result_list = note_store.findNotesMetadata(auth_token, updated_filter,
                                               offset, max_notes,
                                               result_spec).notes

    countDict = {}
    for note in result_list:
        countDict[note] = 1
        for string in listOfStrings:
            noteText = note_store.getNoteSearchText(auth_token, note.guid, 0,
                                                    1)
            countDict[note] *= noteText.count(string)

    result_list.sort(key=countDict.get, reverse=True)

    counter = 0
    for note in frontendSearch(["chicken"], "null"):
        print(note.title, countDict[note])
        if counter > 10:
            break
        else:
            counter += 1

    return result_list
예제 #40
0
def insert_notes(tag):
    result = []
    offset = 0  # 偏移0
    max_notes = 99999
    spec = NotesMetadataResultSpec(1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0)
    updated_filter = NoteFilter(order=NoteSortOrder.UPDATED,
                                tagGuids=[tag.guid])
    notes = note_store.findNotesMetadata(updated_filter, offset, max_notes,
                                         spec)
    if notes.notes:
        for note in notes.notes:
            node_file["id"] = gen_topic_id()
            node_file["title"] = note.title
            node_file["titleUnedited"] = True

            image_dict["src"] = "xap:resources/" + id_evernote_image
            image_dict["align"] = "left"
            node_file["image"] = copy.deepcopy(image_dict)

            node_file[
                "href"] = "https://app.yinxiang.com/shard/s61/nl/12899539/" + note.guid
            result.append(copy.deepcopy(node_file))
    return result
예제 #41
0
def download_notes(note_store, access_token, query):

    # Connecting to Evernote account (getting note store)
    note_store = get_note_store(access_token)

    # Creating ResultSpec and NoteFilter
    noteFilter = NoteFilter(order=NoteSortOrder.UPDATED,
                            notebookGuid=option.container,
                            words=query)
    result_spec = NotesMetadataResultSpec(includeTitle=True,
                                          includeCreated=True,
                                          includeUpdated=True,
                                          includeNotebookGuid=True)

    # Getting the result
    print("    " + safeglobals.MSG_DOWNLOAD_NOTES + " ......"),
    response = note_store.findNotesMetadata(access_token, noteFilter,
                                            safeglobals.evernote_offset,
                                            safeglobals.evernote_maxnotes,
                                            result_spec)
    print safeglobals.MSG_LABEL_OK

    # Sending response
    return response
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)
예제 #43
0
파일: hello.py 프로젝트: lirenlin/heroku
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