Skip to content

Commit

Permalink
the Spotify API sometimes returns artist names with leading or traili…
Browse files Browse the repository at this point in the history
…ng spaces that should be stripped
  • Loading branch information
Péter Volf committed Nov 14, 2017
1 parent 22904b4 commit 5fbac45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/graphscraper/spotifyartist.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ def search_artists_by_name(self, artist_name: str, limit: int = 5) -> List[NameE
result: List[NameExternalIDPair] = []
data: List[Dict] = response.json()["artists"]["items"]
for artist in data:
artist = NameExternalIDPair(artist["name"], artist["id"])
if artist.name is None or artist.external_id is None:
artist = NameExternalIDPair(artist["name"].strip(), artist["id"].strip())
if not artist.name or not artist.external_id:
raise SpotifyClientError("Name or ID is missing")
result.append(artist)

Expand Down

0 comments on commit 5fbac45

Please sign in to comment.