diff --git a/myanimelist/media.py b/myanimelist/media.py index 01aa57f..9428443 100644 --- a/myanimelist/media.py +++ b/myanimelist/media.py @@ -270,8 +270,14 @@ def parse_sidebar(self, media_page): if len(rank_tag_results) == 0: raise Exception("Couldn't find rank tag.") # rank_tag is a lxml.etree._ElementUnicodeResult here: - rank_tag = rank_tag_results[0].getparent().xpath(".//text()[contains(.,'#')]")[0] - media_info['rank'] = int(rank_tag.strip()[1:].replace(',', '')) + + contains = rank_tag_results[0].getparent().xpath(".//text()[contains(.,'#')]") + if contains: + rank_tag = contains[0] + media_info['rank'] = int(rank_tag.strip()[1:].replace(',', '')) + else: + media_info['rank'] = "N/A" + except: if not self.session.suppress_parse_exceptions: raise diff --git a/myanimelist/utilities.py b/myanimelist/utilities.py index bdf6018..fbdec47 100644 --- a/myanimelist/utilities.py +++ b/myanimelist/utilities.py @@ -156,7 +156,10 @@ def parse_profile_date(text, suppress=False): try: parsed_date = datetime.datetime.strptime(text, '%b %d, %I:%M %p') except ValueError: - parsed_date = datetime.datetime.strptime(text, '%b %d, %Y %I:%M %p') + try: + parsed_date = datetime.datetime.strptime(text, '%b %d, %Y %I:%M %p') + except ValueError: # if the user don't display his birthday year, it never work. + parsed_date = None # see if it's a month/year pairing. return parsed_date if parsed_date is not None else None except: diff --git a/setup.py b/setup.py index 6b61b6d..ce08a2b 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ 'download_url': 'https://github.com/pushrbx/python3-mal/archive/master.zip', 'author_email': 'contact@pushrbx.net', 'version': '0.2.10', - 'install_requires': ['urllib3==1.21.1', 'requests', 'pytz', 'lxml', 'cssselect'], + 'install_requires': ['urllib3', 'requests', 'pytz', 'lxml', 'cssselect'], 'tests_require': ['nose'], 'packages': ['myanimelist'] }