Skip to content

Instantly share code, notes, and snippets.

@spudtrooper
Last active May 26, 2021 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spudtrooper/87243baec2b1a642f850fceace730f87 to your computer and use it in GitHub Desktop.
Save spudtrooper/87243baec2b1a642f850fceace730f87 to your computer and use it in GitHub Desktop.
Produces markdown output of all Google Keep notes containing a certain phrase.
"""
Produces markdown output of all Google Keep notes containing a certain phrase.
Requirements:
pip install gkeepapi
Usage:
python keepdocs.py <gmail-username> <gmail-password> <query>
Example:
python keepdocs.py jeffpalm Jeffs-Gmail-Password pilot
"""
import gkeepapi
import sys
def main(argv):
if len(argv) < 4:
print('''
Usage: python {me} <gmail-username> <gmail-password> <query>
Example:
python {me} jeffpalm Jeffs-Gmail-Password pilot
'''.format(me=argv[0]))
return
username, password, query = argv[1], argv[2], argv[3]
keep = gkeepapi.Keep()
success = keep.login('%s@gmail.com' % username, password)
if not success:
print('could not log in')
return
notes = keep.find(query=query)
for note in notes:
print('')
title = note.title
if not title:
title = note.id
print('# %s' % title)
print(note.text)
if __name__ == '__main__':
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment