ageitgey / medium_to_ghost

Instantly move all your Medium.com content (formatted posts + images) to an open source Ghost blog!
MIT License
121 stars 13 forks source link

urllib.error.HTTPError: HTTP Error 400: Bad Request #2

Closed camilleroux closed 5 years ago

camilleroux commented 5 years ago

Hi, I've the following error when I'm using the script.

NFO:root:Parsing posts/2013-11-05_10-ways-to-fail-a-Startup-Weekend-7c8d533bfdad.html
INFO:root:Downloading https://cdn-images-1.medium.com/fit/t/NaN/NaN/1*BkLPtHoNPLVLxf1mBqXsvQ.jpeg to exported_content/downloaded_images/10-ways-to-fail-a-Startup-Weekend
Traceback (most recent call last):
  File "/usr/local/bin/medium_to_ghost", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/medium_to_ghost/medium_to_ghost.py", line 98, in main
    exported_posts = parse_posts(posts)
  File "/usr/local/lib/python3.7/site-packages/medium_to_ghost/medium_to_ghost.py", line 53, in parse_posts
    converted_post = convert_medium_post_to_ghost_json(name, content)
  File "/usr/local/lib/python3.7/site-packages/medium_to_ghost/medium_post_parser.py", line 84, in convert_medium_post_to_ghost_json
    new_image_path = download_image_with_local_cache(url, cache_folder)
  File "/usr/local/lib/python3.7/site-packages/medium_to_ghost/image_downloader.py", line 32, in download_image_with_local_cache
    local_filename, headers = urllib.request.urlretrieve(url, local_destination)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

Do you need more info?

ageitgey commented 5 years ago

Thanks for the bug report! I uploaded a new version 0.0.2. You should be able to upgrade with pip:

pip3 install -U medium_to_ghost

Try out the new version and let me know if it fixes the issue for you.