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

IndexError: list index out of range #54

Closed dawidwelna closed 2 years ago

dawidwelna commented 3 years ago

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?

paperboi commented 3 years ago

Hi, chances are you have a book that has no author listed in it's metadata. Will write a fix for this and include it in the next release.

dawidwelna commented 3 years ago

yes I have a few books that have no author. I have many articles etc.. But I managed to solve it by setting up the repo myself and installing the dependencies with conda and then installing the package inside my conda environment

python setup.py install

I'm also planning now to try to make this package to work with my language polish etc. Because during copying the characters like "ę", "ą", "ł" are lost maybe you already know how to solve it?

paperboi commented 3 years ago

yes I have a few books that have no author. I have many articles etc.. But I managed to solve it by setting up the repo myself and installing the dependencies with conda and then installing the package inside my conda environment

python setup.py install

I'm also planning now to try to make this package to work with my language polish etc. Because during copying the characters like "ę", "ą", "ł" are lost maybe you already know how to solve it?

I know it's an issue with the way the file is read in kindle2notion/reading.py but haven't been successful so far in getting it right. Please do look into it if you can and update here what you find. Thanks for taking the initiative!

paperboi commented 3 years ago

yes I have a few books that have no author. I have many articles etc.. But I managed to solve it by setting up the repo myself and installing the dependencies with conda and then installing the package inside my conda environment

python setup.py install

I'm also planning now to try to make this package to work with my language polish etc. Because during copying the characters like "ę", "ą", "ł" are lost maybe you already know how to solve it?

Hi @dawidwelna, if it's okay, can you please forward me a clipping of one such article which has no author listed from your My Clippings file? I had written a function to account for this case earlier and wanted to know how this would have gone past that.

dawidwelna commented 3 years ago

@paperboi here is a draft PR https://github.com/paperboi/kindle2notion/pull/55 I fixed the issue with missing polish characters. I still need to add unit tests, so please wait for it. I've been busy recently. Also there is an example file you asked which you may use. I am not sure if this is a correct excerpt that generated an error, but definitely there is a book without an author inside.

paperboi commented 2 years ago

@dawidwelna, just got the fix for this up- please update to the latest version (1.0.0) and try again. The setup is a little different too so please go through the README file and docs.