Anpanator / jnc-downloader

A python script to automatically (pre-)order books and download them from your J-Novel.club library.
The Unlicense
8 stars 5 forks source link

AttributeError - fromisoformat #10

Closed wolfpackmars2 closed 3 years ago

wolfpackmars2 commented 3 years ago

Error: AttributeError: type object 'datetime.datetime' has no attribute 'fromisoformat'

Python 3.6.9

https://docs.python.org/3/library/datetime.html#datetime.date.fromisoformat

... which is implemented in Python 3.7, so won't work in 3.6.9.

The whole error message:

  File "./jnc.py", line 86, in <module>
    handler.load_preordered_books()
  File "/home/wolfpack/MyPrograms/j-novel.club/jnc-downloader/jnc_api_tools.py", line 257, in load_preordered_books
    book_release_datetime = datetime.fromisoformat(book_time.rstrip('Z')).replace(tzinfo=timezone.utc)
AttributeError: type object 'datetime.datetime' has no attribute 'fromisoformat'
Anpanator commented 3 years ago

Is there a particular reason you don't use a more recent python version? This script was developed with Python 3.8.

wolfpackmars2 commented 3 years ago

Because I need to update my OS :P

Not a big deal - I had hoped the fix would be fast and I would post a PR but it's more complicated. I don't think it's worth fixing this at this time. For now, I have worked around the problem by disabling the pre-order check from jnc.py as a quick patch.

Anpanator commented 3 years ago

For what it's worth: I'll keep it in mind as I'm intending to do some major rework of the script anyway. If I can think of an easy way to avoid this issue, I'll do so.

wolfpackmars2 commented 3 years ago

yeah that's why I figured it's not worth fixing. But if someone else runs into this, it's documented here. Don't spend too much time on it. Do you have any updates beyond what's posted on GitHub? I may play with the script some this weekend ... right now turkey calls!

Anpanator commented 3 years ago

I do not. My dayjob is keeping me busy and I haven't had much motivation to work on it. But it will happen eventually. At the latest when I'm picking up my books again and need new volumes ;)

wolfpackmars2 commented 3 years ago

Is the API documented anywhere or did you reverse engineer it from the web site?

Anpanator commented 3 years ago

The latter. Though I only looked at the parts I actually needed.

Keep in mind the purchase credits API has changed (see open issue). I haven't checked, but other parts may already be changed too.