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 Dec 29, 2017
Zenrac:patch-1
Merged
Minor fix to prevent from an error in some cases#25pushrbx merged 4 commits intopushrbx:masterfrom Zenrac:patch-1
pushrbx merged 4 commits intopushrbx:masterfrom
Zenrac:patch-1
Conversation
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)
Owner
There was an error with it, and that was the solution. It might be ok by now. |
pushrbx
suggested changes
Dec 29, 2017
myanimelist/media.py
Outdated
| 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 |
Owner
There was a problem hiding this comment.
It would be better to check if the returned list contains any items instead of just catching an IndexError.
pushrbx
approved these changes
Dec 29, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.