shaldengeki / python-mal

Python interface to MyAnimeList
Do What The F*ck You Want To Public License
18 stars 20 forks source link

Producers out of range error. #1

Closed MartynasZilinskas closed 9 years ago

MartynasZilinskas commented 9 years ago

If there no producers in Anime. Error: producers list index is out of range. Example

import myanimelist.session
session = myanimelist.session.Session()
bebop = session.anime(2033)
print bebop.title

Log:

Traceback (most recent call last):
  File "sort.py", line 4, in <module>
    print bebop.title
  File "c:\Python27\lib\site-packages\myanimelist\base.py", line 71, in _decorat
or
    getattr(self, func_name)()
  File "c:\Python27\lib\site-packages\myanimelist\media.py", line 341, in load
    self.set(self.parse(utilities.get_clean_dom(media_page)))
  File "c:\Python27\lib\site-packages\myanimelist\media.py", line 191, in parse
    media_info = self.parse_sidebar(media_page)
  File "c:\Python27\lib\site-packages\myanimelist\anime.py", line 131, in parse_
sidebar
    anime_info[u'producers'].append(self.session.producer(int(link_parts[1])).se
t({'name': producer_link.text}))
IndexError: list index out of range
shaldengeki commented 9 years ago

Good catch! I'm house-hunting today so it'll be awhile before I can fix it myself, but if you've already got a commit fixing it, submit a PR and I'll merge it in.

MartynasZilinskas commented 9 years ago

121 line in anime.py

if len(link_parts) > 1:
    anime_info[u'producers'].append(self.session.producer(int(link_parts[1])).set({'name': producer_link.text}))

I am newbie on Python, and I fixed problem with this.

shaldengeki commented 9 years ago

Awesome, well, if you want credit for the fix, you can do the following:

  1. fork the repository by clicking the "fork" button above
  2. clone your forked repository by doing git clone https://github.com/martiogalalt/python-mal.git
  3. make the fix in anime.py
  4. do git commit -a -m "only populate producers if any exist"
  5. issue a pull request by going here, clicking "compare across forks", selecting your fork, and clicking "create pull request".

Otherwise, I can make the changes myself, but I'd like to give you formal credit for it if possible :)