kiwiz / gkeepapi

An unofficial client for the Google Keep API.
MIT License
1.53k stars 114 forks source link

Notes are not being archived when gnote.archived is set to True and sync() is called #160

Closed distbit0 closed 8 months ago

distbit0 commented 8 months ago

Please make sure you've done the following before submitting your issue:

I am running the following code:

import gkeepapi
import utils.general as general

def fetch_notes_text():
    keep = gkeepapi.Keep()
    keep.resume(
        <username>
        <master key>,
    )

    gnotes = keep.find(archived=False, trashed=False)

    notes_text = "\n\n" + "\n\n".join(note.text for note in gnotes if note.text)
    if notes_text.strip():
        print(notes_text)

    for gnote in gnotes:
        gnote.archived = True
        gnote._archived = True

    keep.sync()

fetch_notes_text()

Additionally, please provide the following information:

OS: Fedora 39 Python version 3.12.1 64bit

When I run this, it prints out the text of currently un-archived tasks, however does not archive them, as evidenced by the fact that it continues to print the same text every time it is run despite the fact that it requests only un-archived tasks.

How can I modify it so that it successfully archives tasks? many thx

distbit0 commented 8 months ago

Ah I figured out the issue. I thought gnotes was a list but it is a generator and hence is empty when I iterate through it a second time to archive the returned notes. the solution was to first convert it to a list.