paperboi / kindle2notion

Export all clippings from your Kindle device to a database in Notion.
https://pypi.org/project/kindle2notion/
MIT License
886 stars 120 forks source link

Error if pageorloc formatting deviates from expected format #11

Closed j-chan-hkust closed 3 years ago

j-chan-hkust commented 3 years ago

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.

flintstones-fred commented 3 years ago

@j-chan-hkust After looking at your suggestion, I was able to fix part of the code. However, I still get an error while executing. Would you mind looking at the other issue I raised? Thanks!

paperboi commented 3 years ago

Hey, thanks for raising this! Sorry for the late reply! Will look into implementing a feature to take all these subtle variations in formats into account.

paperboi commented 3 years ago

@j-chan-hkust implemented your suggestions as a fix. Thanks for the help!