Python script to convert Google Keep notes to Obsidian markdown

Hi,

Version 0.3.1 of the Python markdown converter script to grab Google Keep notes is now ready. The major change is support for all foreign languages. The converter also supports JPEG, PNG, Drawings and Audio files attached to Keep notes. This script does not require using Google Takeout for export. I use Keep as my fast, raw input of notes captured from the Chrome plug-in and app on all devices and then use Obsidian for deep/evergreen notes. This gives you a way to have a cross-platform simple note capture for Obsidian and runs on Windows, MacOS and Linux.

Keep notes convert to markdown very well and labels will convert to tags in Obsidian. You can also use simple markdown notation in Keep and it will convert properly (including cross-linking notes, and block references). A settings file allows you to set the output path to your Vault if you want.

As always - this is an early release so be sure to test export of a small set of Keep notes first to a folder that won’t disrupt your Obsidian work. In my case I export to a side folder and copy-paste into my Vault if the conversion is valid.

You should have some familiarity with running Python scripts.

You can download the script zip file here - https://github.com/djsudduth/keep-it-markdown/archive/0.3.1.zip

Instructions on use are in the README.md file here - https://github.com/djsudduth/keep-it-markdown

Thanks!

3 Likes

Thank you - this is great if it works - ive tried 2 such scripts and crashed and burned, mainly because i kept getting errors at the very beginning related to unicode and various other things i have no familiarity with. (actually my main problem is ive never used python, and i now see why i need to learn it) .

I successfully updated pip and installed the couple dependencies that the other scripts required, just fine. But running it and successfully executing it is another story. i think the main value in the scripts for people like me is to 1st make it idiot-proof (or rather, failsafe, like the space shuttle, or anything else that must not fail), and then make it functional.

In any event, at least people like you are adding to the effectiveness of obsidian-- the “your own data, residing locally” part of it, and doing exactly that, helping people wean themselves from monopolistic or proprietary data systems, and start building safer, more portable KBs. Thanks! Will give it a go. I have >1000 keep notes, and def want to get them off goog, in an orderly manner (not destroying the minimal structure that keep already has)

Edit: i guess i gave myself a self-fulfilling profecy! here a couple screenshots. couldnt get past the test step (#4).
Details: i got some error message on 1st exe of the keep-test.py , i didnt screenshot that one. it was basicaly telling me i did have auth, which is fine. so I followed the instructions to open a browser (i had previously signed out of all but one google account) and punch in that google auth url, and then i successfully enabled access (2nd screenshot)

Then I went back and redid the python command line instruction, but the same “badauthentication” came up again. So, as always, Im stuck again… :frowning:

Yes, unfortunately Google never created an official API for Keep so the underlying library has to cheat as if it is an Android app. This ‘bad authentication’ error shows up mostly on Windows OSs due to a TLS issue. The author of the library has hopefully fixed the problem very recently. If you run - pip install gkeepapi==0.13.4 and try the test again it may work.

For reference - if you do a ‘pip list’ the key libraries should be at:
gkeepapi 0.13.4
gpsoauth 0.4.1
requests 2.23.0
urllib3 1.25.11

If you have newer versions of requests and urllib3 then that’s what is causing the ‘bad authentication’ error.

1 Like

@Barycenter, I’m telling you, I’m going to throw myself a small party if I can get this to work – my 1st python script execution - still not there yet… Attached is a screenshot of my installed libraries – it looks like Im one behind on gkeepapi, and ahead on requests and urllib3… I will update the the former and try, but regarding your last sentence-- how do i manually downgrade to the requests and urllib3 that you say would work better? (and what is it about downgrading that might eliminate my roadblock to execution?)

Woah. I really dont know how this works, but I think I did something good, just lib install-wise.

I did a pip and install gkeepapi==0.13.4. The console went wild and uninstalled the newer requests and other, and installed exactly the versions you specified - the older ones you list. I dont know how it did all that, but here’s another screenshot.

Looks like I’m good to go setup-wise, now the proof is in the pudding…

EDIT: It looks like I did it! Thank you. Now, on to actually using the script…

Edit2: I did it! I exported a small dummy google account to the subdirectory of the python script! Wow! Thanks! Very cool.

Edit3: @Barycenter, all my keep notes are archived. This is because keep is very slow with 1000 notes in the regular bullpen. So I archived them. I’m reading your GIT instructions, specifically, “You can convert to md by using a single word, a phrase or by a label. All queries to convert ignore notes in archive and trash. KIM will stay active to do more conversions until you just press --x or Ctrl-C.” Does this mean I cannot convert any of my notes since they are archived??

So glad you got it to work!!! Exporting archived notes requires using the -a option. If you type

python kim.py --help

you’ll see the list of options:

  -r                       Will reset and not use the local keep access token
                           in your system's keyring
  -o                       Overwrite any existing markdown files with the same
                           name
  -a                       Search and export only archived notes
  -p                       Preserve keep labels with spaces and special
                           characters
  -b, --search-term TEXT   Run in batch mode with a specific Keep search term
  -t, --master-token TEXT  Log in using master keep token

So in your case
python kim.py -a
will export only archive notes with a search prompt, or

python kim.py -a -o -b --all
will export all archive notes with overwriting if a duplicate in batch without prompting for search

@WahWah

Stunning, really. Thank you. Great tool. Now let’s see what happens. Local notes, here we go! @Barycenter, lovely of you to have written this.

Just as a side note @WahWah - you can use Google Keep for fast notes and add markdown within them that will convert to Obsidian. For example, to have one Keep note refer to another by title - just use the wikilink [[Other Keep Note Title]] brackets to refer between notes and Obsidian will automatically connect them on conversion. Also you can refer to section headings in Keep by using [[Other Keep Note#Other Heading]] and in the other Keep note have a section with ## Other Heading, etc. and it will automatically work in Obsidian. (Other markdown formats convert as well such as bold, italic, headings, etc).

fascinating. thank you. i just wondered, if i export my keep notes again in 6 months, is there any way the script could skip the ones i already processed or no?

also, one aspect of google keep is that if you omit a title (its own separate bar (data area) like the subject line in an email), it will take the first part of body text as its display title. a reason that someone may not use titles is that at first you may no know how to best summarize a note, so you leave the title for later-- and then keep takes the 1st part of the text when you save, and you say, “meh, that’s good enough” and leave it. Ive done that for many notes. How does that effect the advice you just appended, @Barycenter ?

Hmmmm…I didn’t think of the ignore/skip use case. However, if you use the defaults without the -o option your notes will not be overwritten - just a new filename with create date/time appended.

As for no title - just the create date/time is used as the title. I could add a feature to use the first n characters of the body text as an option.

I’ll add both to the intake list

Hi, sir
I’ve used the correct library, and I have logged in to my Google account in my internet browser,

I but I still have Error Message as below:

Login attempt failed
Technical Error Message: LoginException(‘NeedsBrowser’, ‘To access your account, you must sign in on the web. Touch Next to start browser sign-in.’)
Please start your browswer and copy-paste this URL in the address bar: https://accounts.google.com/DisplayUnlockCaptcha - then, try logging in again.

and I also follow the Error Message, open the URL and click Continue, and try logging in again and again, but nothing changed, I still get the same Error Message.

Could you give some advice,

Thank you.