Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix artist.get_bio_content() to return None if bio is empty when getElementsByTagName #368

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/pylast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,11 @@ def __hash__(self):
def _extract_cdata_from_request(self, method_name, tag_name, params):
doc = self._request(method_name, True, params)

first_child = doc.getElementsByTagName(tag_name)[0].firstChild
elements = doc.getElementsByTagName(tag_name)
if len(elements) == 0:
return None

first_child = elements[0].firstChild
if first_child is None:
return None

Expand Down
12 changes: 12 additions & 0 deletions tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,15 @@ def test_search_get_total_result_count(self):

# Assert
assert int(total) > 10000

def test_mbid_biography_issue(self):
# Arrange
mbid = "e2bef0c5-02e7-4505-b87f-90fc96bd70c3"

# Act
artist = self.network.get_artist_by_mbid(mbid)

# Assert
assert isinstance(artist, pylast.Artist)
assert artist.name == "Space 92"
assert artist.get_bio_content() is None