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

AttributeError: 'str' object has no attribute 'removeprefix' #27

Closed madzic closed 3 years ago

madzic commented 3 years ago

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.

madzic commented 3 years ago

I found your answer to other issue and upgraded Python to 3.9. Now I have the following issue: Traceback (most recent call last): File "D:\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\Python39\lib\site-packages\kindle2notion__main.py", line 31, in main() File "D:\Python39\lib\site-packages\click\core.py", line 1134, in call return self.main(*args, kwargs) File "D:\Python39\lib\site-packages\click\core.py", line 1059, in main rv = self.invoke(ctx) File "D:\Python39\lib\site-packages\click\core.py", line 1401, in invoke return ctx.invoke(self.callback, ctx.params) File "D:\Python39\lib\site-packages\click\core.py", line 767, in invoke return callback(*args, **kwargs) File "D:\Python39\lib\site-packages\kindle2notion__main__.py", line 25, in main books = parse_raw_clippings_text(all_clippings) File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 18, in parse_raw_clippings_text author, title = _parse_author_and_title(raw_clipping_list) File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 36, in _parse_author_and_title author, title = _deal_with_exceptions_in_author_name(author, title) File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 79, in _deal_with_exceptions_in_author_name last_name, first_name = author.split(', ') ValueError: too many values to unpack (expected 2)

Any help? Thanks.

paperboi commented 3 years ago

I found your answer to other issue and upgraded Python to 3.9. Now I have the following issue: Traceback (most recent call last): File "D:\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\Python39\lib\site-packages\kindle2notionmain.py", line 31, in main() File "D:\Python39\lib\site-packages\click\core.py", line 1134, in call return self.main(args, kwargs) File "D:\Python39\lib\site-packages\click\core.py", line 1059, in main rv = self.invoke(ctx) File "D:\Python39\lib\site-packages\click\core.py", line 1401, in invoke return ctx.invoke(self.callback, ctx.params) File "D:\Python39\lib\site-packages\click\core.py", line 767, in invoke return __callback(args, **kwargs) File "D:\Python39\lib\site-packages\kindle2notionmain.py", line 25, in main books = parse_raw_clippings_text(all_clippings) File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 18, in parse_raw_clippings_text author, title = _parse_author_and_title(raw_clipping_list) File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 36, in _parse_author_and_title author, title = _deal_with_exceptions_in_author_name(author, title) File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 79, in _deal_with_exceptions_in_author_name last_name, first_name = author.split(', ') ValueError: too many values to unpack (expected 2)

Any help? Thanks.

Hi, can you try posting the last book that appeared in your output before this error showed up? It may something to do with a book not having an author listed at all.

crisdias commented 3 years ago

I have the same problem and I have no books showing on my output. (is there a "verbose" option I should be using to get this info?)

Many books in my Clippings file don't follow a "Last, First" author structure. e.g.: Legion Skin Deep (Brandon Sanderson) (this is the first line of my clippings file)

Hope that helps.

yoshihiko-k commented 3 years ago

@paperboi I stumbled upon the same thing. Please update the minimum python version described in Setup.py.

setup.py

python_requires='>=3.9',
paperboi commented 3 years ago

@paperboi I stumbled upon the same thing. Please update the minimum python version described in Setup.py.

setup.py

python_requires='>=3.9',

Noted. Will address it in the next commit and release.

paperboi commented 3 years ago

I have the same problem and I have no books showing on my output. (is there a "verbose" option I should be using to get this info?)

Many books in my Clippings file don't follow a "Last, First" author structure. e.g.: Legion Skin Deep (Brandon Sanderson) (this is the first line of my clippings file)

Hope that helps.

I realized I haven't fully taken into account of the non-ASCII characters that sometimes appear when reading the clippings file in UTF-8 encoding. I assume this error came up because of it. Found a solution to this- will post a new release soon and update you here.

madzic commented 3 years ago

I found your answer to other issue and upgraded Python to 3.9. Now I have the following issue: Traceback (most recent call last): File "D:\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\Python39\lib\site-packages\kindle2notionmain.py", line 31, in main() File "D:\Python39\lib\site-packages\click\core.py", line 1134, in call return self.main(*args, kwargs) File "D:\Python39\lib\site-packages\click\core.py", line 1059, in main rv = self.invoke(ctx) File "D:\Python39\lib\site-packages\click\core.py", line 1401, in invoke return ctx.invoke(self.callback, ctx.params) File "D:\Python39\lib\site-packages\click\core.py", line 767, in invoke return *callback(args, kwargs) File "D:\Python39\lib\site-packages\kindle2notion__main.py", line 25, in main books = parse_raw_clippings_text(all_clippings) File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 18, in parse_raw_clippings_text author, title = _parse_author_and_title(raw_clipping_list) File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 36, in _parse_author_and_title author, title = _deal_with_exceptions_in_author_name(author, title) File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 79, in _deal_with_exceptions_in_author_name last_name, first_name = author.split(', ') ValueError: too many values to unpack (expected 2) Any help? Thanks.

Hi, can you try posting the last book that appeared in your output before this error showed up? It may something to do with a book not having an author listed at all.

Hi man, thanks for the reply. No books appeared in Notion and the first book has the author (Cabane, Olivia Fox). Thanks again.

paperboi commented 3 years ago

Hi, can you update to the new release and run the commands again? It should work now. pip install kindle2notion==0.1.3

madzic commented 3 years ago

Works like a charm, thank you! Will buy you a coffee for this, thanks!

paperboi commented 3 years ago

@madzic Glad to hear that! Thanks a lot!