Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'text' #18

Closed
Kin-Zhang opened this issue Jan 10, 2022 · 6 comments
Closed

KeyError: 'text' #18

Kin-Zhang opened this issue Jan 10, 2022 · 6 comments

Comments

@Kin-Zhang
Copy link

Kin-Zhang commented Jan 10, 2022

System:

  • Python 3.7
  • notion2md: 2.2.5 from pip install

Here is the error show on python, I tried a simple page it works but with other more complex page have many blocks, it seems have problems:
image
And here is the error text:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/exporter.py", line 18, in block_exporter
    output.write(blocks_convertor(blocks))
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/block.py", line 109, in blocks_convertor
    outcome_blocks = "".join([result for result in results])
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/block.py", line 109, in <listcomp>
    outcome_blocks = "".join([result for result in results])
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator
    yield fs.pop().result()
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/concurrent/futures/_base.py", line 428, in result
    return self.__get_result()
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/block.py", line 140, in block_convertor
    outcome_block = block_type_map[block_type](information_collector(block[block_type])) + "\n\n"
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/block.py", line 115, in information_collector
    information['text'] = richtext_convertor(payload['text'])
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/richtext.py", line 48, in richtext_convertor
    outcome_word = link(richtext["text"])
KeyError: 'text'
@echo724
Copy link
Owner

echo724 commented Jan 10, 2022

Oh thank you for sharing the error. Can you share the notion page url that you tested? It will be more easy to find which block occurs error.

@Kin-Zhang
Copy link
Author

Oh thank you for sharing the error. Can you share the notion page url that you tested? It will be more easy to find which block occurs error.

Thanks for your quick reply, here is the page: https://kinzhang.notion.site/Optimization-Based-Collision-Avoidance-815a2796158b41c4990fa9a04272e9a4
Just ignore the language...

@Kin-Zhang
Copy link
Author

I think the error may be it didn't support all kinds of the block that notion have... but the notion export button to markdown is fine, just sometimes the format is terrible with tab especially.

@Kin-Zhang
Copy link
Author

Kin-Zhang commented Jan 10, 2022

here is the config script:

from notion2md.exporter import block_exporter
class config:
    def __init__(self, id, path, name):
        self.target_id = id
        self.output_path = path
        self.file_name = name
my_config = config("815a2796158b41c4990fa9a04272e9a4","/home/kin/MyBlog/content/posts","test")
block_exporter(my_config)

@echo724
Copy link
Owner

echo724 commented Jan 11, 2022

Yeap. I found that I didn't add the handling case for "mention" type richtext. I add it and it will work well now. I will release new version that fixes this. Thank you
p.s. I changed the tap to \t

@echo724 echo724 closed this as completed Jan 11, 2022
@Kin-Zhang
Copy link
Author

Yeap. I found that I didn't add the handling case for "mention" type richtext. I add it and it will work well now. I will release new version that fixes this. Thank you p.s. I changed the tap to \t

 Retrieving blocks from '815a2796158b41c4990fa9a04272e9a4'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/exporter.py", line 18, in block_exporter
    output.write(blocks_convertor(blocks))
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/block.py", line 109, in blocks_convertor
    outcome_blocks = "".join([result for result in results])
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/block.py", line 109, in <listcomp>
    outcome_blocks = "".join([result for result in results])
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator
    yield fs.pop().result()
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/concurrent/futures/_base.py", line 428, in result
    return self.__get_result()
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/block.py", line 151, in block_convertor
    outcome_block += "\t"*depth + block_convertor(block,depth)
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/block.py", line 140, in block_convertor
    outcome_block = block_type_map[block_type](information_collector(block[block_type])) + "\n\n"
  File "/home/kin/anaconda3/envs/py37/lib/python3.7/site-packages/notion2md/convertor/block.py", line 67, in image
    return f"![{information['url']}]({information['url']})\n\n{information['caption']}"
KeyError: 'url'

It seems also have other... error like URL?

@echo724 echo724 reopened this Jan 16, 2022
@echo724 echo724 closed this as completed Jan 16, 2022
@mxro mxro mentioned this issue Aug 20, 2022
YouXam pushed a commit to YouXam/notion2md that referenced this issue Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants