This repository was archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlist_notes.py
More file actions
executable file
·53 lines (46 loc) · 1.3 KB
/
list_notes.py
File metadata and controls
executable file
·53 lines (46 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
import getpass
import json
import os
import sys
from uuid import getnode
import gkeepapi
import gpsoauth
import keyring
keep = gkeepapi.Keep()
cache_home = os.environ.get(
"XDG_CACHE_HOME", os.path.join(os.environ["HOME"], ".cache")
)
nvim_cache = os.path.join(cache_home, "nvim")
os.makedirs(nvim_cache, exist_ok=True)
config_file = os.path.join(nvim_cache, "gkeep.json")
email = None
data = {}
if os.path.exists(config_file):
with open(config_file, "r") as ifile:
data = json.load(ifile)
email = data.get("email")
if email is None:
email = input("Email:")
data["email"] = email
with open(config_file, "w") as ofile:
json.dump(data, ofile)
token = keyring.get_password("google-keep-token", email)
if token is None:
password = getpass.getpass("Password:")
res = gpsoauth.perform_master_login(email, password, str(getnode()))
token = res.get('Token')
if token is None:
url = res.get("Url")
if url:
print(url)
print("Complete login flow in browser")
sys.exit(0)
else:
print("Unknown error logging in", res)
sys.exit(1)
keyring.set_password("google-keep-token", email, token)
keep.resume(email, token)
keep.sync()
for note in keep.all():
print(note.title)