kemayo / leech

Turn a story on certain websites into an ebook for convenient reading
MIT License
154 stars 24 forks source link

using leech with json fails to load URL #65

Closed Jason-May closed 3 years ago

Jason-May commented 3 years ago

Calling the script with arguments as follows ./leech.py worm.json I got the following traceback

./leech.py worm.json
Traceback (most recent call last):
  File "./leech.py", line 166, in <module>
    cli()
  File "/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "./leech.py", line 155, in download
    site, url = sites.get(url)
  File "/leech/sites/__init__.py", line 261, in get
    raise NotImplementedError("Could not find a handler for " + url)
NotImplementedError: Could not find a handler for worm.json

It seems like the script isn't ever reading the json file, and is instead trying to parse "worm.json" as a URL

kemayo commented 3 years ago

Does worm.json actually exist? If you're using a regular checkout and haven't touched anything, it'd be ./leech.py examples/worm.json

Jason-May commented 3 years ago

ah, that's what I was doing wrong..If you'd like, I could put together a pull request for error handling in this scenario.

I looked through the code to see where exactly the JSON files were being loaded and I couldn't quite figure it out. Is it the case that the get(url) function recognizes that it's a local file, and then constructs site_class, as an anonymous function, to pass to all the other functions within download?

Thank you.