Skip to content

Commit 5b34237

Browse files
committed
Merge branch 'release/0.6.0' into main
2 parents 0e2a9fc + 9bdb2bf commit 5b34237

File tree

7 files changed

+104
-125
lines changed

7 files changed

+104
-125
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ settings*.cfg
22
skiptest.py
33
fuzzy.py
44
zz*.py
5+
configs.txt
56
mdfiles/
67
backup/
78
.vscode/

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
FROM ubuntu:22.04
22
RUN apt update
33
RUN apt install -y python-is-python3 python3-pip
4+
RUN apt-get install -y git
45
RUN apt-get install -y curl
56
RUN apt-get install ca-certificates
6-
RUN curl -L -o tmp/keep-it-markdown-0.5.4.tar.gz https://github.com/djsudduth/keep-it-markdown/archive/refs/tags/0.5.4.tar.gz
7-
RUN tar -zxvf tmp/keep-it-markdown-0.5.4.tar.gz
8-
RUN pip install -r keep-it-markdown-0.5.4/requirements.txt
9-
RUN pip install requests==2.23.0
10-
RUN pip install gpsoauth==1.0.2
11-
RUN pip install keyrings.alt
7+
RUN curl -L -o tmp/keep-it-markdown-0.6.0.tar.gz https://github.com/djsudduth/keep-it-markdown/archive/refs/tags/0.6.0.tar.gz
8+
RUN tar -zxvf tmp/keep-it-markdown-0.6.0.tar.gz
9+
RUN pip install keyrings.alt
10+
RUN pip install git+https://github.com/simon-weber/gpsoauth.git@8a5212481f80312e06ba6e0a29fbcfca1f210fd1

INSTALL.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Installation Steps for Advanced Users (only needs to run once)
2+
- Python 3.10+ required (or use pyenv for a specific new version)
3+
- Install git
4+
- Download latest version of `keep-it-markdown` from releases and unzip it to your working directory
5+
- Create a fresh virtual environment within the working directory
6+
- Activate the virtual environment
7+
- Install lastest `gpsoauth` package - `pip install git+https://github.com/simon-weber/gpsoauth.git@8a5212481f80312e06ba6e0a29fbcfca1f210fd1`
8+
- Follow **Second Way** instructions here to get a copy of the oauth_token cookie value - https://github.com/rukins/gpsoauth-java?tab=readme-ov-file
9+
- Run the script in the KIM directory - `python get_token.py`
10+
- Enter your Google email account name, oauth_token, and Android ID when prompted (Android ID can be anything, OAuth token expires in about 5 min)
11+
- Copy the Keep Token value output from `get_token.py` (do not execute the next step unless you have the token)
12+
- Install KIM dependencies in the venv - `pip install -r requirements.txt`
13+
- Linux users - you may need to install a Keyring - `pip install keyrings.alt`
14+
- Run KIM to save the Token in your local Keyring - `python kim.py -t <your long token value here>`
15+
16+
Congratulations! You're done! Your Token is valid for all KIM versions now (unless Google changes it). You can now run KIM locally from this point on (see `kim.py --help` for switch options)

README.md

Lines changed: 67 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,75 @@ Keep-it-markdown or KIM converts Google Keep notes to markdown using the unoffic
66
The overall goal is to utilize Google Keep as an easy way to capture raw notes on all devices or additionally using the browser plugin. Then, notes can be queried for export to markdown files directly into notetaking apps such as Obsidian, Logseq and/or Notion, or used directly with Typora.
77

88
## Installation
9-
Install assumes you have some familiarity with running scripts through a terminal or command line. KIM is a command line script that **requires Python 3.8 or greater** and utilizes the unofficial gkeepapi. (**If you have Python versions 3.10+ and have login issues you may need to review Advanced Docker Setup below**)
9+
**Advanced Users:** see the **INSTALL.md** to skip over these installation details for simple step-by-steps
10+
11+
Install assumes you have some familiarity with running scripts through a terminal or command line. KIM is a command line script that **requires Python 3.10 or greater** and utilizes the unofficial gkeepapi. (**If you have Python versions 3.10+ and have login issues you may need to review Advanced Docker Setup below**)
1012

1113
**NOTE: Be aware that 'unofficial' implies that Google could change the API at any time that might stop the script from working!**
1214

13-
You only need to run installation steps 1 through 4 one time.
15+
You only need to run installation steps 1 through 6 one time.
1416

1517
#### Step 1:
16-
Install Python (there are plenty of tutorials online for installation instructions) on you PC or Mac. Start your command prompt, shell or terminal and verify your python version by running:
18+
Install Python (there are plenty of tutorials online for installation instructions) on you PC or Mac. If you have an older version of Python (3.8 or 3.9) installed and you want to leave it, you can install pyenv to run multiple versions. Start your command prompt, shell or terminal and verify your python version by running:
1719
```bash
1820
> python --version
1921
```
20-
If you had Python 2 installed already you may need to type 'python3' instead of just 'python' for the rest of these steps to use version 3.8+.
22+
If you had Python 2 installed already you may need to type 'python3' instead of just 'python' for the rest of these steps to use version 3.10+.
2123

2224
#### Step 2:
2325
Download this project's zip file into any new directory of you choice. Select the most current release noted at the top right of this page and download 'Source code' using this link:
2426
https://github.com/djsudduth/keep-it-markdown/releases
2527

26-
Unzip the files within your chosen directory.
28+
Unzip the files within your chosen directory. **DO NOT RUN REQUIREMENTS.TXT YET!**
29+
2730

2831
#### Step 3:
29-
Start your command prompt, shell or terminal, find your download directory and run
32+
KIM requires a Google Keep authentication token in order to run. The token can only be retrieved once you have a web page OAuth cookie. To do this it is important that you have a fresh Python install or a new virtual environment (venv) setup.
33+
34+
Once you've setup a fresh environment, install the Chrome extension called 'Cookie Tab Viewer'. Change the directory to where you installed KIM. You must also install `git` on your PC. Installation is simple here -> https://git-scm.com/downloads
35+
36+
One Python module is needed to get the token. Run this command on your PC:
37+
```bash
38+
> pip install git+https://github.com/simon-weber/gpsoauth.git@8a5212481f80312e06ba6e0a29fbcfca1f210fd1
39+
```
40+
41+
#### Step 4:
42+
Here's the tricky part - you need to get your OAuth token from a Google cookie. To get the OAuth token - follow the **"Second way"** instructions here (but get the cookie value using the Chrome extension once you've pressed "I agree" on the Google page):
43+
https://github.com/rukins/gpsoauth-java?tab=readme-ov-file
44+
45+
Copy the cookie called `oauth_token` using the Chrome Cookie Tab Viewer from the cookies in your local browser. Then, run the script
46+
```bash
47+
> python get_token.py
48+
```
49+
You will be prompted for your Google email account name, OAuth token, and Android ID
50+
51+
The AndroidID can just be a random value like: `abcdef123`
52+
53+
So, when you get the prompt when running the script:
54+
**Email:** your google ID
55+
**OAuth Token:** oauth2_4/......rest of token
56+
**Android ID:** abcdef123
57+
58+
The Keep token should be displayed - it should look like:
59+
"aas_et/FKcp.............lots of characters.....................BjQ="
60+
61+
Copy that token and save it in a safe place! If it didn't work your OAuth token may have expired (takes about 5 min to expire). Run this step again until you get the token.
62+
63+
#### Step 5:
64+
Make sure you are in the KIM directory to install all needed dependencies with:
3065
```bash
3166
> pip install -r requirements.txt
3267
```
3368
(you may need to use 'pip3' instead of 'pip' if you have both python versions 2 and 3 installed) This will install the additional libraries needed to run KIM. You only need to do this once. If you have Anaconda as your Python base you may need to find tutorials on how to get pip and install dependencies. Advanced users may want to setup a virtual environment for this.
3469

35-
#### Step 4:
36-
This script was written before the official Google Keep API was available. The Google Keep API is currently only available to workspace users and not individuals. So, you must manually create an application password for authentication purposes.
37-
38-
1) Navigate to your [Google Account Page](https://myaccount.google.com)
39-
2) Click on the Security option on the left
40-
3) Under the **Signing in to Google** header select **App passwords**
41-
4) Choose **Select App** and select **Other**, the name can be anything you want but I suggest something identifiable such as "**KeepItMarkdown**"
42-
5) Click on Generate and Copy the password that's generated
43-
6) Run the following command and logon with your Google email and the newly generated application password.
70+
#### Step 6:
71+
You now need to save your Keep token within the KIM secure keyring
4472
```bash
45-
> python kim.py
73+
> python kim.py -t <your long token value here>
4674
```
47-
If you entered your Google email and application password correctly, you should see a successful login with the statement -> "You've succesfully logged into Google Keep!"
75+
If you entered your Google email and token correctly, you should see a successful login with the statement -> "You've succesfully logged into Google Keep!"
4876

49-
**If this step keeps failing see 'Key Callouts' #9 below, or, if you are using Python 3.10 or greater and have issues with the login - see Advanced Docker Setup below or read this note: https://github.com/djsudduth/keep-it-markdown/issues/72**
77+
**If this step keeps failing see 'Key Callouts' #9 below, and have issues with the login - see Advanced Docker Setup below or read this note: https://github.com/djsudduth/keep-it-markdown/issues/72**
5078

5179
## Usage
5280
Congrats! You can now run KIM. Simply start by running:
@@ -178,24 +206,27 @@ Note: skip -s and overwrite -o cannot be used at the same time
178206
9. There seems to be login issues due to some of the authentication and security library changes with Google and Python. Take a look at this note -> https://github.com/djsudduth/keep-it-markdown/issues/72 or use the Advanced Docker Setup in the next section
179207

180208
## Advanced Docker Setup
181-
If you are having difficulty logging in to Google you can use Docker with the preconfigured OS and Python version to access KIM and save your exported notes (see alternative step 7 if you want to save the Keep token on your PC).
209+
If you are having difficulty logging in to Google you can use Docker with the preconfigured OS and Python version to access KIM and save your exported notes (see alternative step 12 if you want to save the Keep token on your PC).
182210

183211
**Steps:**
184212
1) Install Docker on any PC (find the online instructions for your particular operating system)
185213
2) Startup Docker (or it will autostart on reboot depending on how you installed it)
186214
3) Go to the command line and run ``docker build -t kim .`` in the directory where you installed KIM (it will take about 5 min to create the image)
187-
4) Run the Docker image with ``docker run --mount type=bind,source=(your PC's KIM directory)/mdfiles,target=/keep-it-markdown-0.5.4/mdfiles -it kim`` (you will be automatically logged into the Docker image and your PC's directory will be mapped to the Docker image directory)
188-
5) Change the directory to Kim ``cd keep-it-markdown-0.5.4``
189-
6) Create a temporary app password on Google
215+
4) Run the Docker image with ``docker run --mount type=bind,source=(your PC's KIM directory)/mdfiles,target=/keep-it-markdown-0.6.0/mdfiles -it kim`` (you will be automatically logged into the Docker image and your PC's directory will be mapped to the Docker image directory)
216+
5) Change the directory to Kim ``cd keep-it-markdown-0.6.0``
217+
6) Install lastest `gpsoauth` package - `pip install git+https://github.com/simon-weber/gpsoauth.git@8a5212481f80312e06ba6e0a29fbcfca1f210fd1`
218+
7) Follow **Second Way** instructions here to get a copy of the oauth_token cookie value - https://github.com/rukins/gpsoauth-java?tab=readme-ov-file
219+
8) Run the script in the KIM directory - `python get_token.py`
220+
9) Enter your Google email account name, oauth_token, and Android ID when prompted (Android ID can be anything, OAuth token expires in about 5 min)
221+
10) Copy and save the Keep Token value output from `get_token.py` on your PC
190222
---
191-
7) For one time or sporatic use, run KIM per the instructions above (note that in Docker python3 is aliased to python) - your exported notes will be exported to your PC. NOTE, however, that running Docker this way will not save any passwords or exported notes when you exit and you may need to recreate Google app passwords each time you use KIM with Docker this way.(Exit the Docker image with ``exit``)
223+
11) For one time or sporatic use, install the KIM dependencies with `pip install -r requirements.txt` and then run KIM in Docker with ``python kim.py -t <long token here>`` using the saved Token above (note that in Docker python3 is aliased to python) - your exported notes will be exported to your PC. NOTE, however, that running Docker this way will not save any passwords or exported notes when you exit and you will need use the saved Token each time you use KIM with Docker this way.(Exit the Docker image with ``exit``)
192224
---
193-
7) Alternatively, run ``python keep-test.py -t`` in the Docker image to log in and display the Keep token (keep token will **appear be very long** - almost 2 lines)
194-
8) Copy the token by highlighting the entire string and hitting enter
195-
9) Paste and save the token somewhere safe
196-
10) Exit the Docker image with ``exit``
197-
11) Now run KIM in your current OS with the -t switch once to save it in the keystore (``python kim.py -t <long token here>`` - you may need a new Google app password to do this)
198-
12) You can now run KIM on any PC (once you save the token) with Python v-3.8 or higher
225+
12) Alternatively, exit the Docker image with ``exit``
226+
13) Download and install KIM in your current OS
227+
14) Install KIM dependencies your PC using `pip install -r requirements.txt`
228+
15) Run KIM with the -t switch once to save the Token in your PC keystore (``python kim.py -t <long token here>``)
229+
16) You can now run KIM on your PC (once you save the token) with Python v-3.10 or higher without having to run these steps again. The Token will be saved in your local PC's keystore
199230

200231
## Obsidian Use
201232
Since KIM converts Google Keep notes to markdown, you can use some of the Obsidian text markdown features in your Keep notes as you're capturing information. For example, you can begin to cross-link notes in Keep by using the Wikilink double-brackets within a note like this [[Title of another Keep note]]. Then, when you convert your notes to the Obsidian vault they will be automatically linked. This will also work for block references and other markdown notation. Most markdown types in Keep notes should convert successfully even if Keep cannot render them. **Do not try to add markdown for links/URLs in Keep**. KIM will try to map link any of Keep's URLs to markdown format for you.
@@ -232,11 +263,6 @@ Thanks for trying this markdown converter! I hope you find it useful!
232263
There's always room for improvement. Feel free to add issues to the issues list.
233264

234265

235-
## 0.5.1 Recent Changes
236-
Fixed image overwrite if note has no title or text and using -c switch
237-
Fixed error of markdown note imports if there are special characters within
238-
Added create and update dates of markdown files to imported notes
239-
240266
## 0.5.2 Recent Changes
241267
Switched audio file extensions from AAC back to M4A
242268
Added Joplin exports -j flag to use front matter header
@@ -249,4 +275,10 @@ Removed captcha note in keep-test.py
249275
## 0.5.4 Recent Changes
250276
Docker image altered to use Ubuntu:22.04 to fix Google auth issues with gkeepapi
251277
Added new flag -m to move exported images to Archive folder
252-
Removed python deprecated imghdr library with pillow module
278+
Removed python deprecated imghdr library with pillow module
279+
280+
## 0.6.0 Recent Changes
281+
Now requires Python v-3.10+ to run KIM
282+
New Docker image to get the Keep token
283+
Old keep-test.py module removed for new Google authentication (get_token.py added)
284+
New simple INSTALL.md steps

get_token.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import gpsoauth as go
2+
3+
try:
4+
print ("\nEnter your Google ID, the copied oauth_token cookie, and any value for the Android ID:\n")
5+
t = dict(go.exchange_token(input('Google ID: '), input('oauth_token Cookie: '), input('Android ID: ')))
6+
final_token = t["Token"]
7+
print ("\nCongratulations! This is your Google Keep token - you only need to extract this once. Please copy and run 'python kim.py -t <your token here>' to save the token key in your keystore. Keep-it-markdown should work on your PC from now on!\n")
8+
print (final_token)
9+
except Exception as e:
10+
print ("\nEither you entered your ID and OAuth cookie incorrectly or the OAuth cookie has expired. Try getting the OAuth cookie and run this again - the cookie expires within 5 minutes.")
11+
12+
13+

keep-test.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

kim.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from xmlrpc.client import boolean
1515
from PIL import Image
1616

17-
17+
KIM_VERSION = "0.6.0"
1818
KEEP_KEYRING_ID = 'google-keep-token'
1919
KEEP_NOTE_URL = "https://keep.google.com/#NOTE/"
2020
CONFIG_FILE = "settings.cfg"
@@ -723,7 +723,7 @@ def main(r, o, a, p, s, c, l, j, m, i, search_term, master_token):
723723

724724
#m = True
725725
opts = Options(o, a, p, s, c, l, j, m, i)
726-
click.echo("\r\nWelcome to Keep it Markdown or KIM!\r\n")
726+
click.echo("\r\nWelcome to Keep it Markdown or KIM " + KIM_VERSION + "!\r\n")
727727

728728
if i and (r or o or a or s or p or c or m):
729729
print ("Importing markdown notes with export options is not compatible -- please use -i only to import")
@@ -749,8 +749,6 @@ def main(r, o, a, p, s, c, l, j, m, i, search_term, master_token):
749749
# raise Exception("Problem with markdown file creation: " + repr(e))
750750

751751

752-
#Version 0.5.4
753-
754752
if __name__ == '__main__':
755753

756754
main() # pylint: disable=no-value-for-parameter

0 commit comments

Comments
 (0)