shaldengeki / python-mal

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

Error while fetching anime info. #3

Open nins-k opened 9 years ago

nins-k commented 9 years ago

Started getting this error while retrieving info on any anime about a week ago.

AttributeError: 'NoneType' object has no attribute 'parent' 
(file "/usr/local/lib/python2.7/dist-packages/myanimelist/media.py", line 193, in parse)

I had no idea what to do so I tried commenting out the following lines (193-195) which restored partial functionality.

synopsis_elt = media_page.find(u'h2', text=u'Synopsis').parent
utilities.extract_tags(synopsis_elt.find_all(u'h2'))
media_info[u'synopsis'] = synopsis_elt.text.strip()

This let me fetch an anime's title, rank, score, episodes but keeps returning NoneType for every call to anime.related

The complete nosetests results are in this gist.

This API is really awesome so hoping it'll be fixed. Thanks!

MartynasZilinskas commented 9 years ago

I got that error too. I will try look in that problem. EDIT: I found out, that newest HTML update caused this library to crash. I will try fix it.

nins-k commented 9 years ago

Thanks, that would be great!

MartynasZilinskas commented 9 years ago

Well I made temporary fix... because I couldn't make it find 'Synopsis' with BS4... https://github.com/martiogalalt/python-mal/commit/46dc3aa267e9dd1a28e4eb29d2b37439026f4e33

    # Lame Fix
    synopsis_elt = media_page.find_all(u'h2')

    for item in synopsis_elt:
      if 'Synopsis' in item.text:
        synopsis_elt = item.parent

    utilities.extract_tags(synopsis_elt.find_all(u'h2'))

    for item in synopsis_elt(["script", "style"]):
      item.extract()

    media_info[u'synopsis'] = synopsis_elt.text.strip()
shaldengeki commented 9 years ago

Sorry I've been unreachable; I'll take a look at this this weekend, since it looks like there's some changes that need to be made to pass all the tests.

nins-k commented 9 years ago

Oh, that's great :) In the meantime, thanks for your temporary fix @martiogalalt.

rachmadaniHaryono commented 7 years ago

if anyone want to find the repo with working fix, there are my repo and @pushrbx, which are still actively updated. If you are looking for python 3 only package (as in #10) try the fork from @pushrbx, because his fork only support that.