Skip to content
This repository was archived by the owner on May 4, 2021. It is now read-only.

Minor fix to prevent from an error in some cases#25

Merged
pushrbx merged 4 commits intopushrbx:masterfrom
Zenrac:patch-1
Dec 29, 2017
Merged

Minor fix to prevent from an error in some cases#25
pushrbx merged 4 commits intopushrbx:masterfrom
Zenrac:patch-1

Conversation

@Zenrac
Copy link
Copy Markdown

@Zenrac Zenrac commented Dec 29, 2017

Sometime, the anime don't have any rank, especially if it is an hentai. It prevent from an IndexError.
Moreover, when you try to get information about an user, it returns an error if the user don't displays his birthday year.
And I didn't find why you set the version of urllib3 so I removed it, but feel free to contradict me.

Sometime, the anime don't have any rank, especially if it is an hentai. It prevent from an IndexError.
This is a lazy fix to avoid an error when the mal user don't display his birthday year. (It should check if it can display month or day at least instead)
@pushrbx
Copy link
Copy Markdown
Owner

pushrbx commented Dec 29, 2017

And I didn't find why you set the version of urllib3 so I removed it, but feel free to contradict me.

There was an error with it, and that was the solution. It might be ok by now.

try:
rank_tag = rank_tag_results[0].getparent().xpath(".//text()[contains(.,'#')]")[0]
media_info['rank'] = int(rank_tag.strip()[1:].replace(',', ''))
except IndexError: # It may happen
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to check if the returned list contains any items instead of just catching an IndexError.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants