dexplo / jupyter_to_medium

Python package for publishing Jupyter Notebooks as Medium blogposts
https://dexplo.org/jupyter_to_medium
MIT License
144 stars 13 forks source link

Fixed PNG syntax error. Fixed issue with .jpg filenames #79

Open FoamoftheSea opened 1 year ago

FoamoftheSea commented 1 year ago

Fixes Issue #63

Also fixes this issue with medium not understanding file names with .jpg extension:

  File "C:\Users\indez\.venvs\jtm_dev\lib\site-packages\jupyter_to_medium\_publish_to_medium.py", line 249, in load_images_to_medium
    new_url = req_json["data"]["url"]
KeyError: 'data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\indez\jupyter_to_medium\publish.py", line 3, in <module>
    jtm.publish(
  File "C:\Users\indez\.venvs\jtm_dev\lib\site-packages\jupyter_to_medium\_publish_to_medium.py", line 465, in publish
    p.main()
  File "C:\Users\indez\.venvs\jtm_dev\lib\site-packages\jupyter_to_medium\_publish_to_medium.py", line 338, in main
    self.load_images_to_medium()
  File "C:\Users\indez\.venvs\jtm_dev\lib\site-packages\jupyter_to_medium\_publish_to_medium.py", line 251, in load_images_to_medium
    raise ValueError("Problem loading image {name}.{extension} to Medium: " + r.text)
ValueError: Problem loading image {name}.{extension} to Medium: {"errors":[{"message":"The media is not in a format we understand.","code":-1}]}

The easiest fix for the above would be in the nbconvert package where these file names are generated, but to keep the solution in this repo the markdown and filenames must be corrected after they are generated.