Skip to content
This repository was archived by the owner on May 4, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions myanimelist/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion myanimelist/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
Expand Down