Skip to content

Commit

Permalink
artist related endpoint added.
Browse files Browse the repository at this point in the history
  • Loading branch information
yakupadakli committed May 26, 2018
1 parent 4cda1c8 commit e65f8c7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions musixmatch/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ def artist(self):
get: Get the artist data.
related: Get related artists.
"""
return Artist(api=self)
22 changes: 22 additions & 0 deletions musixmatch/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,32 @@ def get(self, artist_id):
"""
Get the artist data.
:type artist_id: string
:param artist_id: Musixmatch artist id.
:return [Artist]: Artist Object.
"""
url = "/artist.get"
params = {"artist_id": artist_id}
result = self._get(url, params=params)
return ArtistModel._parse(result["message"]["body"]["artist"])

def related(self, artist_id, page=1, page_size=100):
"""
Get the artist data.
:type artist_id: string
:type page: double
:type page_size: double
:param artist_id: The musiXmatch artist id
:param page: Define the page number for paginated results.
:param page_size: Define the page size for paginated results. Range is 1 to 100.
:return [List]: Artist List.
"""
url = "/artist.related.get"
params = {"artist_id": artist_id, "page": page, "page_size": page_size}
result = self._get(url, params=params)
artist_list = map(lambda x: x["artist"], result["message"]["body"]["artist_list"])
return ArtistModel._parse_list(artist_list)

0 comments on commit e65f8c7

Please sign in to comment.