Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

to_json() on anime object error #28

Open
nickdex opened this issue Jan 21, 2018 · 5 comments
Open

to_json() on anime object error #28

nickdex opened this issue Jan 21, 2018 · 5 comments

Comments

@nickdex
Copy link

nickdex commented Jan 21, 2018

This is due to change in tag names (start and end dates) in official mal api. I'll add more details soon and also check if it affects manga object

@eshrh
Copy link
Contributor

eshrh commented Jan 21, 2018

I'm confused, what is the error? I just tested it out, Anime.to_json()seems to work fine

@nickdex
Copy link
Author

nickdex commented Jan 23, 2018

Following code is from Anime object in objects.py

@property
    def dates(self):
        if self._dates is None:
            start_val = self.raw_data.start_date
            end_val = self.raw_data.end_date
            if start_val is None:
                start_val = self.raw_data.my_start_date
                end_val = self.raw_data.my_end_date
            self._dates = (start_val.text, end_val.text)
        return self._dates

When I tried to run to_json() it gives following error

>>> anime1.to_json()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/spice_api/objects.py", line 206, in to_json
    return {field: getattr(self, field) for field in self.fields}
  File "/usr/local/lib/python3.6/site-packages/spice_api/objects.py", line 206, in <dictcomp>
    return {field: getattr(self, field) for field in self.fields}
  File "/usr/local/lib/python3.6/site-packages/spice_api/objects.py", line 166, in dates
    self._dates = (start_val.text, end_val.text)
AttributeError: 'NoneType' object has no attribute 'text

I looked up mal api, they return

<my_start_date>0000-00-00</my_start_date>
<my_finish_date>0000-00-00</my_finish_date>

I guess they changed the tag name? I wonder how your call to Anime.to_json() is working correctly

@nickdex
Copy link
Author

nickdex commented Jan 23, 2018

>>> manga1.dates()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/spice_api/objects.py", line 379, in dates
    if start_date is None:
NameError: name 'start_date' is not defined

I got this error when I called dates method on manga object.
Here are the tags name mal api is currently returning for manga

<series_start>1999-09-21</series_start>
<series_end>2014-11-10</series_end>
<my_start_date>0000-00-00</my_start_date>
<my_finish_date>2016-07-14</my_finish_date>

@eshrh
Copy link
Contributor

eshrh commented Jan 23, 2018

just so that I can test the same thing out on my computer, what anime and manga did you use? When I tested I used an anime that had already finished airing.

Edit: just tested it on another anime not yet aired, still no issue. The only other different things I can think of is that we're on different python versions? (i'm on 3.6.2)

@nickdex
Copy link
Author

nickdex commented Jan 26, 2018

I'm on 3.6.4. I too tested on finished and running anime. My guess is that this error due to difference in tag names, though I don't understand how it is working on your machine. Are you using latest version of spice?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants