paperboi / kindle2notion Goto Github PK
View Code? Open in Web Editor NEWExport all clippings from your Kindle device to a database in Notion.
Home Page: https://pypi.org/project/kindle2notion/
License: MIT License
Export all clippings from your Kindle device to a database in Notion.
Home Page: https://pypi.org/project/kindle2notion/
License: MIT License
Hi, I don't really know where to ask but if someone know the way to export highlight with chapter name it's really helpful for later review (For now we only have location in book)
I tried running the script and i get this error.
I already tried this solution but nothing #14
(i'm very noob in programmation :))
When we go back to the book which we have already read and then make new highlights, they ##are populating at the end of the Notion pages. So it would be great, if it is possible to sort the highlight snippets using page number and location.
I am getting the following error when attempting to run kindle2notion
python package.
Executed Command: kindle2notion 86j559ih250... https://www.notion.so/h1l947gj1... '.\Desktop\My Clippings.txt'
Error recieved:
Traceback (most recent call last):
File "C:\Users\trimble\AppData\Local\Programs\Python\Python39\Scripts\kindle2notion-script.py", line 33, in <module>
sys.exit(load_entry_point('kindle2notion', 'console_scripts', 'kindle2notion')())
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1134, in __call__
return self.main(*args, **kwargs)
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1059, in main
rv = self.invoke(ctx)
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 767, in invoke
return __callback(*args, **kwargs)
File "c:\users\trimble\desktop\shortcuts\playground\fun\kindle2notion\kindle2notion\__main__.py", line 20, in main
notion_collection_view = notion_client.get_collection_view(notion_table_id)
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\notion\client.py", line 165, in get_collection_view
collection = self.get_block(
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\notion\client.py", line 118, in get_block
block = self.get_record_data("block", block_id, force_refresh=force_refresh)
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\notion\client.py", line 111, in get_record_data
return self._store.get(table, id, force_refresh=force_refresh)
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\notion\store.py", line 184, in get
self.call_load_page_chunk(id)
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\notion\store.py", line 286, in call_load_page_chunk
recordmap = self._client.post("loadPageChunk", data).json()["recordMap"]
File "c:\users\trimble\appdata\local\programs\python\python39\lib\site-packages\notion\client.py", line 209, in post
raise HTTPError(
requests.exceptions.HTTPError: Invalid input.
i keep getting this error
IsADirectoryError: [Errno 21] Is a directory: '/Volumes/Kindle/documents/My Clippings.sdr'
this happens when i tried to first run the command with the table URL, my token and the clippings path
Date extraction in line 52 assumes the formatting of the date string.
dateAdded = datetime.strptime(addedOn, ' Added on %A, %d %B %Y %X')
Thursday, 18 April 2019 21:12:17
My kindle is actually formatted as:
e.g. Thursday, April 18, 2019 9:12:17 PM
The fix is actually not that hard to implement, change line 52 to:
dateAdded = datetime.strptime(addedOn, ' Added on %A, %B %d, %Y %X %p')
However, may be worthwhile to sanity check the formatting of dates in the clipping object, or to use a more robust dateparser. After stripping out the "Added on " out of the string.
An example:
https://dateparser.readthedocs.io/en/latest/
Given a complex book title consisting of more than one word in brackets, for example:
Смерть Ивана Ильича (Russian Edition) (Толстой, Лев Николаевич)
The following exception is thrown:
Traceback (most recent call last): File "kindle2notion.py", line 242, in <module> ch = KindleClippings(CLIPPINGS_FILE) File "kindle2notion.py", line 13, in __init__ self.clippings = self._getAllClippings(clippingsFile) File "kindle2notion.py", line 18, in _getAllClippings return self._parseClippings(allClippings) File "kindle2notion.py", line 27, in _parseClippings title, author = title_author.split('|') ValueError: too many values to unpack (expected 2)
Hi.
I have experienced this issue multiple times today. When adding the latest highlights from my clippings file it somehow deleted existing clipping from "Warbreaker" Page and inserted "Oathbringer" highlights into the "Warbreaker" page.
It seems to have been solved by deleting all pages in "My Clipping" database and running the script on My Clippings file.
Do the script require "My Clippings" to not contain any existing Highlights?
Really small issue and easy to solve as it is correct right now on GitHub.
This line of code on exporting.py needs to be commented
from more_itertools import grouper # Not good
# from more_itertools import grouper #Good
Again this is fixed on the repo but not on the packages.
I found this by downloading the package from pip and kept getting this error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/bin/kindle2notion", line 33, in <module>
sys.exit(load_entry_point('kindle2notion==1.0.0', 'console_scripts', 'kindle2notion')())
File "/Library/Frameworks/Python.framework/Versions/3.10/bin/kindle2notion", line 25, in importlib_load_entry_point
return next(matches).load()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
module = import_module(match.group('module'))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kindle2notion/__main__.py", line 5, in <module>
from kindle2notion.exporting import export_to_notion
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kindle2notion/exporting.py", line 11, in <module>
from more_itertools import grouper
ModuleNotFoundError: No module named 'more_itertools'
Raising this issue in case someone else's finds it and it's wondering wtf is happening.
Hey man, love the idea, this is what I was looking for for a long time.
Encountering this issue when trying to run the module:
Traceback (most recent call last):
File "D:\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Python38\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\Python38\lib\site-packages\kindle2notion_main.py", line 31, in
main()
File "D:\Python38\lib\site-packages\click\core.py", line 1134, in call
return self.main(*args, **kwargs)
File "D:\Python38\lib\site-packages\click\core.py", line 1059, in main
rv = self.invoke(ctx)
File "D:\Python38\lib\site-packages\click\core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "D:\Python38\lib\site-packages\click\core.py", line 767, in invoke
return _callback(*args, **kwargs)
File "D:\Python38\lib\site-packages\kindle2notion_main.py", line 25, in main
books = parse_raw_clippings_text(all_clippings)
File "D:\Python38\lib\site-packages\kindle2notion\parsing.py", line 18, in parse_raw_clippings_text
author, title = _parse_author_and_title(raw_clipping_list)
File "D:\Python38\lib\site-packages\kindle2notion\parsing.py", line 35, in _parse_author_and_title
author, title = _parse_raw_author_and_title(raw_clipping_list)
File "D:\Python38\lib\site-packages\kindle2notion\parsing.py", line 69, in _parse_raw_author_and_title
author = author.removeprefix('(').removesuffix(')')
AttributeError: 'str' object has no attribute 'removeprefix'
Any help? Thanks.
I just finished the installation, when I ran the terminal I was giving an error on lines 40 and 49. I couldn't solve it.
So I installed pycharm, I'm using a Linux Mint 20.0 distribution
I would like to test the script, I am looking for a script or app that has interaction with Kindle and Notion.
Thank you.
The code works really well! Thanks for sharing it. Although there are some small bugs:
Hi! This is my first issue report, if I have missed something, just let me know.
I am on mac (m1 macbook air) and have installed the latest version of the repo and python. When I updated python with homebrew I received the following:
Warning: You are using macOS 13.
We do not provide support for this pre-release version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
pre-release version.
Warning: Ruby version 2.6.10 is unsupported on macOS 13. Homebrew
is developed and tested on Ruby 2.6.9, and may not work correctly
on other Rubies. Patches are accepted as long as they don't cause breakage
on supported Rubies.
Here is what I get when I try to sync the hightlights:
Notion page is found. Analyzing clippings file...
Found 2 notes and highlights.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/bin/kindle2notion", line 33, in <module>
sys.exit(load_entry_point('kindle2notion==1.0.1', 'console_scripts', 'kindle2notion')())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kindle2notion/__main__.py", line 41, in main
all_books = parse_raw_clippings_text(all_clippings)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kindle2notion/parsing.py", line 96, in parse_raw_clippings_text
page, location, date, isNote = _parse_page_location_date_and_note(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kindle2notion/parsing.py", line 144, in _parse_page_location_date_and_note
date = date.strftime("%A, %d %B %Y %I:%M:%S %p")
AttributeError: 'NoneType' object has no attribute 'strftime'
Hi.
I just updated kindle2notion from 0.1.2 to 0.1.7.
I took a backup of all my Clippings in Notion, deleted the original pages and transferred the content from 'My Clippings.txt' to a fresh Notion database.
Now all quotation-marks and apostrophes are missing when displayed in Notion. Now all the lines just kind of blend in with another, I am not able to separate what is thought, description or quotes.
The quotation-marks and apostrophes are still present in 'My Clippings.txt' and even in my backup Clippings Notion Database (used kindle2notion 0.1.2, so I know that this was working before).
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kindle2notion_main.py", line 49, in
main()
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1137, in call
return self.main(*args, **kwargs)
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 763, in invoke
return _callback(*args, **kwargs)
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kindle2notion_main.py", line 38, in main
export_to_notion(
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kindle2notion\exporting.py", line 35, in export_to_notion
message = _add_book_to_notion(
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kindle2notion\exporting.py", line 87, in _add_book_to_notion
notion_collection_view_rows = notion_collection_view.collection.get_rows()
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notion\collection.py", line 239, in get_rows
return self.query(**kwargs)
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notion\collection.py", line 236, in query
return CollectionQuery(self, self._get_a_collection_view(), **kwargs).execute()
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notion\collection.py", line 385, in execute
self._client.query_collection(
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notion\client.py", line 294, in query_collection
return self._store.call_query_collection(*args, **kwargs)
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notion\store.py", line 344, in call_query_collection
response = self._client.post("queryCollection", data).json()
File "C:\Users\hello\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notion\client.py", line 260, in post
raise HTTPError(
requests.exceptions.HTTPError: Invalid input.
I used this without any error but recently installed SSD in my machine with a fresh install of windows. And installed python just to use this amazing script, but getting this error. I followed the solution and changed the limit to 100, but it isn't working anymore.
I'm tryna running the script, but this error log has occurred.
python3 kindle2notion.py
Notion page is found. Analyzing clippings file...
Found 328 notes and highlights.
'str' object has no attribute 'removeprefix'
Exiting script...
sh: pause: command not found
With a Kindle in Portuguese, highlights's location and date aren't added in Notion... I think the problem is date format, that is different in portuguese.
I tested change language to English, and create a new highlight; this one was exported correct (it's the last registre in the file).
My Clippings.txt
IndexError: list index out of range
Hi, I am trying again (yesterday was working) and I face issues with the HTTP Client. I also tried logging in and out from Notion and getting a new token, but the issue is still there.
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kindle2notion\__main__.py", line 49, in <module>
main()
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kindle2notion\__main__.py", line 31, in main
notion_client = NotionClient(token_v2=notion_token)
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notion\client.py", line 95, in __init__
self._update_user_info()
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notion\client.py", line 126, in _update_user_info
records = self.post("loadUserContent", {}).json()["recordMap"]
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\notion\client.py", line 265, in post
response.raise_for_status()
File "C:\Users\pfern\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
**requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://www.notion.so/api/v3/loadUserContent**
Apparently notion-py
has some issues with big http limits.
A workaround for me (a noob on python) to make it work was:
pip show notion
on the terminal./usr/local/lib/python3.9/site-packages/notion
).store.py
line 280 to "limit": 100,
.Hi! I'm writting from Chile, the program seems awesome!
I have no skills at all in coding but I followed the steps and managed to install python, pip and kindle 2notion package. Could you please help me out? Thanx a lot!!!! I would really appreciate it!
`C:\Program Files\Python39>py -m kindle2notion
.... (i deleted the token, url and kindle path from the message i got)
Usage: python -m kindle2notion [OPTIONS] NOTION_TOKEN NOTION_TABLE_ID
CLIPPINGS_FILE_PATH
Try 'python -m kindle2notion --help' for help.
Error: Got unexpected extra argument (Clippings.txt')`
Hi, this is most probably not a bug, but and issue between chair and keyboard:)
I'm not a developer, so intalling Kindle2Notion wasn't an easy task, but I managed it. But when I tried to export the clippings from kindle to Notion by running the Kindle2Notion package, i'm getting error
notion_client.errors.APIResponseError: API token is invalid
It seems like a least expected problem, because I simply go to Notion's 'Setting & Members' > Integrations and copy Internal Integration token. Don't understand what could be an issue here. I tried to reinstall the package, but didn't help. Any advice will be highly appreciated! Thanks!
I tried running the script and i get that error
A major takeaway that came out of the Product Hunt and r/Notion launch was that many users found it tedious to go through the process of setting up a Python and pip environment on their system to the program running.
And since this is a program that in turn has a significant target audience outside of STEM, I feel it's important that we develop a distributable version of the program that is more accessible in nature.
My first pitch for this is to forward efforts into maintaining the project as a web app that can be hosted online using a framework. The base code for this web app and the package would remain the same and updates for both can be done alongside without too many complexities. I am hoping to stick to using free or open-source frameworks where ever possible- spending not much more than just the hosting fees for the domain (I think this too can be avoided if we use a platform like deta.sh or Vercel for deployment).
Alternately for offline use purposes, one can make an executable file for Windows, macOS and Linux using Python's pyinstaller package to further overcome the cognitive load to set up a Python environment for the average non-technical user.
I haven't fully looked into developing these yet as my personal schedule doesn't allow me the time to devote to this project full-time. I'm open to collaborating with any keen developers and UI designers willing to take this often and help put this together.
Feel free to comment below to take this forward.
#40
PS. as of yesterday, the repo touched over 100 commits!
The library has broken due to issues in the notion unofficial API
Refer above issue
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/main/.local/lib/python3.9/site-packages/kindle2notion/main.py", line 4, in
from kindle2notion.exporting import export_to_notion
File "/home/main/.local/lib/python3.9/site-packages/kindle2notion/exporting.py", line 4, in
from dateparser import parse
File "/home/main/.local/lib/python3.9/site-packages/dateparser/init.py", line 3, in
from .date import DateDataParser
File "/home/main/.local/lib/python3.9/site-packages/dateparser/date.py", line 6, in
import regex as re
File "/usr/lib/python3/dist-packages/regex/init.py", line 1, in
from .regex import *
File "/usr/lib/python3/dist-packages/regex/regex.py", line 402, in
import regex._regex_core as _regex_core
File "/usr/lib/python3/dist-packages/regex/_regex_core.py", line 21, in
import regex._regex as _regex
ModuleNotFoundError: No module named 'regex._regex'
Right now there is no difference between a highlight and a note. It would be nice to nicely format this in notion.
e.g.
This was the highlight in the book.
Notes: This is the note I wrote for the above highlight.
I have experienced the following error:
Traceback (most recent call last):
File "kindle2notion.py", line 200, in
ch = KindleClippings(CLIPPINGS_FILE)
File "kindle2notion.py", line 13, in init
self.clippings = self._getAllClippings(clippingsFile)
File "kindle2notion.py", line 18, in _getAllClippings
return self._parseClippings(allClippings)
File "kindle2notion.py", line 96, in _parseClippings
self.addToNotion(lastClip)
File "kindle2notion.py", line 185, in addToNotion
title = "Page: " + lastClip['Page'] + "\tDate Added: " + str(lastClip['Date Added'].strftime("%A, %d %B %Y %I:%M:%S %p"))
TypeError: must be str, not NoneType
The cause is that my Kindle is storing my strings as:
Which is a bit of a deviation from what kindle2notion expects.
I think its probably easier to make the parsing here a bit more robust, probably by doing the following:
May suggest this as a push.
Create and maintain a JSON object of books and clippings to reduce API calls and update only those clippings that are modified each time.
Motivation:
Ideal solution:
Noticed that some Kindle titles don't have Author information. I faced this issue with "The Intelligent Investor" that I bought from the Kindle Store.
While it doesn't seem possible to fetch the Author info, it can be made so the code gracefully fails and uses an empty string for Author Name. I used a fix locally to get around the issue. Will make a PR later today if this issue is accepted.
Attaching images of clippings file and error message below.
C:\Users\Nashit Ahmed Barq>python -m pip install kindle2notion
Collecting kindle2notion
Using cached kindle2notion-0.1.8.tar.gz (11 kB)
Preparing metadata (setup.py) ... done
Collecting click>=8.0.0
Using cached click-8.0.4-py3-none-any.whl (97 kB)
Collecting dateparser>=1.0.0
Using cached dateparser-1.1.0-py2.py3-none-any.whl (288 kB)
Collecting DateTime>=4.3
Using cached DateTime-4.4-py2.py3-none-any.whl (51 kB)
Collecting notion>=0.0.27
Using cached notion-0.0.28-py3-none-any.whl (43 kB)
Collecting python-decouple>=3.3
Using cached python_decouple-3.6-py3-none-any.whl (9.9 kB)
Collecting requests>=2.25.0
Using cached requests-2.27.1-py2.py3-none-any.whl (63 kB)
Collecting pathlib
Using cached pathlib-1.0.1.tar.gz (49 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
ERROR: Can not execute setup.py
since setuptools is not available in the build environment.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
I ran the script and I have the erreor : "If 'url_or_id' is an ID (not a URL), you must also pass the 'collection'"
I used the ID from my notion database for clippings (before the "?").
Do you know what's the issue ? I'm running it on windows
Thanks
I have been running with this issue after first getting following the steps shown on this pinned issue .
The database does not update on notion nor does it show if there has been any activity... any help is appreciated
Describe the bug
I'm running the script in the normal fashion: kindle2notion INTEGRATION_KEY DATABASE_ID FILE_LOC
.
To Reproduce
kindle2notion INTEGRATION_KEY DATABASE_ID FILE_LOC
.
Expected behaviour
The program uploads my clippings to Notion.
Screenshots
Initiating transfer...
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/bin/kindle2notion", line 33, in <module>
sys.exit(load_entry_point('kindle2notion==1.0.1', 'console_scripts', 'kindle2notion')())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kindle2notion/__main__.py", line 44, in main
export_to_notion(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kindle2notion/exporting.py", line 36, in export_to_notion
message = _add_book_to_notion(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kindle2notion/exporting.py", line 97, in _add_book_to_notion
notion.databases.query(notion_database_id)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/notional/session.py", line 356, in query
if issubclass(target, ConnectedPage):
TypeError: issubclass() arg 1 must be a class
Desktop (please complete the following information):
Additional context
Here's a link to my clippings.
When I try to run the script, it gives me the following error:
Traceback (most recent call last):
File "kindle2notion.py", line 9, in
from settings import CLIPPINGS_FILE, NOTION_TOKEN, NOTION_TABLE_ID, ENABLE_HIGHLIGHT_DATE
File "F:\k2n\settings.py", line 5, in
CLIPPINGS_FILE = config('CLIPPINGS_FILE')
File "C:\Users\Technolet\AppData\Local\Programs\Python\Python37\lib\site-packages\decouple.py", line 199, in call
return self.config(*args, **kwargs)
File "C:\Users\Technolet\AppData\Local\Programs\Python\Python37\lib\site-packages\decouple.py", line 83, in call
return self.get(*args, **kwargs)
File "C:\Users\Technolet\AppData\Local\Programs\Python\Python37\lib\site-packages\decouple.py", line 68, in get
raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: CLIPPINGS_FILE not found. Declare it as envvar or define a default value.
I believe it is due to something I am not doing correctly when creating the .env file. I am a beginner so I don't know what I am doing wrong.
Content of k2n.env file:
CLIPPINGS_FILE = "F:\k2n\My Clippings.txt"
NOTION_TOKEN = "7fed1060c5efc2d9a08329935c2e99c85ae834df0c86cbab1aec3aeb69c00f890e2ec4e17971c4824ddad240842151d2e753c5ca58faa68859d3776ba1d71b1e88aa9d8d702e9ff984940*******"
NOTION_TABLE_ID = "https://www.notion.so/zainkhan/1d7805cf81014931b77aa36c83cd6618?v=354a8fe2452a4b13b766a7843*******"
ENABLE_HIGHLIGHT_DATE = True
Looking forward to the help and thank you in advance.
Hey Jeffrey,
I found your script today and currently migrating all of my kindle notes to notion. Thank you so much for that code. It saves me lots of time :)
I want to get you a coffee for writing this code. Would you feel like creating a Buy me a coffee page so that others could also donate for you?
File "/Applications/kindle2notion/kindle2notion.py", line 200, in <module>
ch = KindleClippings(CLIPPINGS_FILE)
File "/Applications/kindle2notion/kindle2notion.py", line 13, in __init__
self.clippings = self._getAllClippings(clippingsFile)
File "/Applications/kindle2notion/kindle2notion.py", line 18, in _getAllClippings
return self._parseClippings(allClippings)
File "/Applications/kindle2notion/kindle2notion.py", line 96, in _parseClippings
self.addToNotion(lastClip)
File "/Applications/kindle2notion/kindle2notion.py", line 185, in addToNotion
title = "Page: " + lastClip['Page'] + "\tDate Added: " + str(lastClip['Date Added'].strftime("%A, %d %B %Y %I:%M:%S %p"))
TypeError: can only concatenate str (not "NoneType") to str
Need error handling for such errors to prevent termination of script
That could be dockerized. Docker allows to speed up development and ease deployment, especially when CI/CD is involved.
Trying to emulate the process laid down in the README.md file.
Got this error. The script successfully identified the clippings file and the notion table but not able to complete the process.
Initial output:
Notion page is found. Analyzing clippings file...
Found 105 notes and highlights.
Showing error in this line:
kindle2notion\parsing.py", line 69, in _parse_raw_author_and_title
author = author.removeprefix('(').removesuffix(')')
AttributeError: 'str' object has no attribute 'removeprefix'
One step for connecting an integration token to a Notion database has slightly changed. Refer to this Notion doc for context and update README and K2N docs accordingly.
Reference: #83
~ kindle2notion '53daebe5e31867d66528004e6f9b209f8e95889af9e39aad3ba6a774336e39edc78b39a8323c817c36f9cdaefa64085a494f0a89c2af2c26ca96ccab9e9ca301c3b11a************' 'https://www.notion.so/*******/ecd48369d2f64b53bfae2ad349afc264\?v\=a2fd7fae297f4a6999010e8d168c767c' '/Volumes/Kindle/documents/My\ Clippings.txt'
Traceback (most recent call last):
File "/usr/local/bin/kindle2notion", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1134, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1059, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 767, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/kindle2notion/main.py", line 32, in main
notion_collection_view = notion_client.get_collection_view(notion_table_id)
File "/usr/local/lib/python3.9/site-packages/notion/client.py", line 163, in get_collection_view
raise Exception("Invalid collection view URL")
Exception: Invalid collection view URL
There is nice tool which takes care of Python code format just by forcing to one specified style (PEP8): black.
Not sure what went wrong here
Code:
Traceback (most recent call last):
File "/Users/denise/Kindle2Notion/kindle2notion.py", line 151, in
cv = client.get_collection_view(NOTION_TABLE_ID)
File "/usr/local/lib/python3.9/site-packages/notion/client.py", line 165, in get_collection_view
collection = self.get_block(
File "/usr/local/lib/python3.9/site-packages/notion/client.py", line 118, in get_block
block = self.get_record_data("block", block_id, force_refresh=force_refresh)
File "/usr/local/lib/python3.9/site-packages/notion/client.py", line 111, in get_record_data
return self._store.get(table, id, force_refresh=force_refresh)
File "/usr/local/lib/python3.9/site-packages/notion/store.py", line 184, in get
self.call_load_page_chunk(id)
File "/usr/local/lib/python3.9/site-packages/notion/store.py", line 286, in call_load_page_chunk
recordmap = self._client.post("loadPageChunk", data).json()["recordMap"]
File "/usr/local/lib/python3.9/site-packages/notion/client.py", line 209, in post
raise HTTPError(
requests.exceptions.HTTPError: Invalid input.
I've tried to sync my kindle clipping recently and one of the books contains 694 highlights and failed with 413 Payload Too large error.
I am getting an error -
Traceback (most recent call last): File "/Users/Pranav/Tools/Kindle2Notion/kindle2notion.py", line 9, in <module> from settings import CLIPPINGS_FILE, NOTION_TOKEN, NOTION_TABLE_ID File "/Users/Pranav/Tools/Kindle2Notion/settings.py", line 5, in <module> CLIPPINGS_FILE = config('CLIPPINGS_FILE') File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/decouple.py", line 199, in __call__ return self.config(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/decouple.py", line 83, in __call__ return self.get(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/decouple.py", line 68, in get raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option)) decouple.UndefinedValueError: CLIPPINGS_FILE not found. Declare it as envvar or define a default value.
It seems that I am not storing the path to the clipping file correctly. But I can't tell what's going wrong -
Content of kindle2notion.env file:
CLIPPINGS_FILE = "/Users/Pranav/Tools/Kindle2Notion/MyClippings.txt" NOTION_TOKEN = "fe606a84504eeac4***" NOTION_TABLE_ID = "1fa082d598e34df***"
Hi! I am trying to use the tool for the first time, all issues which I had I was able to solve with the help of previous closed issues but..
I am running kindle2notion on mac os and now I run into an issue, which I haven't found so I opened a new one.
here is a short traceback
Notion page is found. Analyzing clippings file...
Found 652 notes and highlights.
Traceback (most recent call last):
File "/opt/anaconda3/bin/kindle2notion", line 8, in <module>
sys.exit(main())
File "/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 1134, in __call__
return self.main(*args, **kwargs)
File "/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 1059, in main
rv = self.invoke(ctx)
File "/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 767, in invoke
return __callback(*args, **kwargs)
File "/opt/anaconda3/lib/python3.8/site-packages/kindle2notion/__main__.py", line 25, in main
books = parse_raw_clippings_text(all_clippings)
File "/opt/anaconda3/lib/python3.8/site-packages/kindle2notion/parsing.py", line 18, in parse_raw_clippings_text
author, title = _parse_author_and_title(raw_clipping_list)
File "/opt/anaconda3/lib/python3.8/site-packages/kindle2notion/parsing.py", line 35, in _parse_author_and_title
author, title = _parse_raw_author_and_title(raw_clipping_list)
File "/opt/anaconda3/lib/python3.8/site-packages/kindle2notion/parsing.py", line 68, in _parse_raw_author_and_title
author = (re.findall(r'\(.*?\)', raw_clipping_list[0]))[-1]
IndexError: list index out of range
Does anybody know how to solve this issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.