Skip to content

Commit e917dd7

Browse files
committed
Merge branch 'release/0.6.1' into main
2 parents 5b34237 + 27dc1a0 commit e917dd7

File tree

4 files changed

+51
-43
lines changed

4 files changed

+51
-43
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +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
54
RUN apt-get install -y curl
65
RUN apt-get install ca-certificates
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
6+
RUN curl -L -o tmp/keep-it-markdown-0.6.1.tar.gz https://github.com/djsudduth/keep-it-markdown/archive/refs/tags/0.6.1.tar.gz
7+
RUN tar -zxvf tmp/keep-it-markdown-0.6.1.tar.gz
98
RUN pip install keyrings.alt
10-
RUN pip install git+https://github.com/simon-weber/gpsoauth.git@8a5212481f80312e06ba6e0a29fbcfca1f210fd1
9+
RUN pip install -r /keep-it-markdown-0.6.1/requirements.txt
10+

INSTALL.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
## Installation Steps for Advanced Users (only needs to run once)
22
- Python 3.10+ required (or use pyenv for a specific new version)
3-
- Install git
43
- Download latest version of `keep-it-markdown` from releases and unzip it to your working directory
54
- 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`
5+
- Activate a virtual environment
6+
- Install KIM dependencies in the venv - `pip install -r requirements.txt`
87
- 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
98
- Run the script in the KIM directory - `python get_token.py`
109
- 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`
10+
- Copy the Keep Token value output from `get_token.py`
1311
- Linux users - you may need to install a Keyring - `pip install keyrings.alt`
1412
- Run KIM to save the Token in your local Keyring - `python kim.py -t <your long token value here>`
1513

README.md

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,19 @@ If you had Python 2 installed already you may need to type 'python3' instead of
2525
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:
2626
https://github.com/djsudduth/keep-it-markdown/releases
2727

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

3130
#### Step 3:
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:
31+
Make sure you are in your KIM directory and install all needed dependencies with:
3732
```bash
38-
> pip install git+https://github.com/simon-weber/gpsoauth.git@8a5212481f80312e06ba6e0a29fbcfca1f210fd1
33+
> pip install -r requirements.txt
3934
```
35+
(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.
4036

4137
#### 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):
38+
KIM requires a Google Keep authentication token in order to run. The token can only be retrieved once you have a Google page OAuth cookie. Install the Chrome extension called 'Cookie Tab Viewer'. Change the directory to where you installed KIM.
39+
40+
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 in the Second way method):
4341
https://github.com/rukins/gpsoauth-java?tab=readme-ov-file
4442

4543
Copy the cookie called `oauth_token` using the Chrome Cookie Tab Viewer from the cookies in your local browser. Then, run the script
@@ -60,14 +58,7 @@ The Keep token should be displayed - it should look like:
6058

6159
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.
6260

63-
#### Step 5:
64-
Make sure you are in the KIM directory to install all needed dependencies with:
65-
```bash
66-
> pip install -r requirements.txt
67-
```
68-
(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.
69-
70-
#### Step 6:
61+
#### Step 5:
7162
You now need to save your Keep token within the KIM secure keyring
7263
```bash
7364
> python kim.py -t <your long token value here>
@@ -212,35 +203,34 @@ If you are having difficulty logging in to Google you can use Docker with the pr
212203
1) Install Docker on any PC (find the online instructions for your particular operating system)
213204
2) Startup Docker (or it will autostart on reboot depending on how you installed it)
214205
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)
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
206+
4) Run the Docker image with ``docker run --mount type=bind,source=(your PC's KIM directory)/mdfiles,target=/keep-it-markdown-0.6.1/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)
207+
5) Change the directory to Kim ``cd keep-it-markdown-0.6.1``
208+
6) 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
209+
7) Run the script in the KIM directory - `python get_token.py`
210+
8) 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)
211+
9) Copy and save the Keep Token value output from `get_token.py` on your PC
222212
---
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``)
213+
10) For one time or sporatic use, 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``)
224214
---
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
215+
11) Alternatively, exit the Docker image with ``exit``
216+
12) Download and install KIM in your current OS
217+
13) Install KIM dependencies your PC using `pip install -r requirements.txt`
218+
14) Run KIM with the -t switch once to save the Token in your PC keystore (``python kim.py -t <long token here>``)
219+
15) 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
230220

231221
## Obsidian Use
232222
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.
233223

234224
KIM's goal is to be markdown compliant. Obsidian uses Wikilinks by default. Obsidian can use strict markdown by setting the Options / Files & Links / Use [[Wikilinks]] to off. Currently, only strict markdown is enforced in KIM conversion to be as compatible as possible.
235225

236226
## Logseq Use
237-
Notes will import into Logseq similar to the Obsidian Use description, however, you need to set your mdfiles path to the `pages` folder in Logseq. For images to render properly be sure to set your media path to `../assets`. Also, to format notes correctly, an experimental feature has been added. A new switch has been configured (-l) to add paragraph bullets within each exported note so Logseq will render them better. Deep testing was not done on this option.
227+
Notes will import into Logseq similar to the Obsidian Use description, however, you need to set your mdfiles path to the `pages` folder in Logseq. For images to render properly be sure to set your media path to `../assets`. Also, to format notes correctly, an experimental feature has been added. A new switch has been configured (-l) to add paragraph bullets within each exported note so Logseq will render them better.
238228

239229
## Notion Use
240230
KIM markdown note exports seem to import into Notion successfully. However, Notion STILL fails to import linked image attachments (which seems to be a general Notion md import problem at this time). Notion also ties underlying ids to any cross-linked notes so that there is no automated cross-linking when importing (future feature). Also, tags are not supported in Notion so Keep labels will just be text hashtags within the note which are searchable.
241231

242232
## Joplin Use
243-
KIM markdown note exports also import very well into Joplin. Using the -j flag will add Keep labels as Joplin front matter to add them as tags. Most markdown types in Keep notes should convert successfully even if Keep cannot render them. However, wikilinks are not supported in Joplin's manual markdown import and front matter tags are not supported on import.
233+
KIM markdown note exports also import very well into Joplin. Using the -j flag will add Keep labels as **Joplin front matter** to add them automatically as tags. Most markdown types in Keep notes should convert successfully even if Keep cannot render them. 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]]. Wikilinking between Keep notes will automatically convert to standard Joplin markdown note links connecting notes together.
244234

245235
## Typora Use
246236
KIM tries to adhere to strict markdown to be as compatible as possible. No issues have been discovered using Typora on KIM markdown exports.
@@ -281,4 +271,8 @@ Removed python deprecated imghdr library with pillow module
281271
Now requires Python v-3.10+ to run KIM
282272
New Docker image to get the Keep token
283273
Old keep-test.py module removed for new Google authentication (get_token.py added)
284-
New simple INSTALL.md steps
274+
New simple INSTALL.md steps
275+
276+
## 0.6.1 Recent Changes
277+
New instructions and Dockerfile for updated versions of gkeepapi and gpsoauth to get keep token
278+
Wikilinking now supported for Joplin notes

kim.py

Lines changed: 17 additions & 1 deletion
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-
KIM_VERSION = "0.6.0"
17+
KIM_VERSION = "0.6.1"
1818
KEEP_KEYRING_ID = 'google-keep-token'
1919
KEEP_NOTE_URL = "https://keep.google.com/#NOTE/"
2020
CONFIG_FILE = "settings.cfg"
@@ -412,6 +412,21 @@ def set_file_extensions(self, data_file, file_name, file_path):
412412
return (media_name)
413413

414414

415+
def replace_wikilinks(text):
416+
pattern = r"\[\[([^\]]*)\]\]"
417+
def replace(match):
418+
link_text = match.group(1)
419+
# Split the link text by pipe symbol, if present
420+
parts = link_text.split("|")
421+
print (link_text)
422+
file_link = parts[0].replace(' ', '%20')
423+
if len(parts) == 1:
424+
# No pipe symbol, use the same text for link and display text
425+
return f"[{parts[0]}]({file_link}.md)"
426+
else:
427+
return f"[{parts[1]}]({file_link}.md)"
428+
return re.sub(pattern, replace, text, count=0, flags=re.MULTILINE)
429+
415430

416431
def save_md_file(note, note_tags, note_date, overwrite, skip_existing):
417432
try:
@@ -581,6 +596,7 @@ def keep_query_convert(keep, keepquery, opts):
581596
"---\n\n")
582597
note_labels = ""
583598
note.timestamps = {}
599+
note.text = replace_wikilinks(note.text)
584600

585601

586602
if opts.archive_only:

0 commit comments

Comments
 (0)