Skip to content

Commit

Permalink
Add loading of related artists
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed Feb 26, 2020
1 parent dd4b15b commit 488d215
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/spotify/artist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@ QVector<Album> Artist::albums(Spotify &spotify)
albums.append(Album(item.toObject()));
return albums;
}

QVector<Artist> Artist::relatedArtists(Spotify &spotify)
{
auto json = spotify.get(QString("artists/%1/related-artists").arg(id));
auto items = json["artists"].toArray();
QVector<Artist> artists;
artists.reserve(items.size());
for (auto item : items)
artists.append(Artist(item.toObject()));
return artists;
}
1 change: 1 addition & 0 deletions src/spotify/artist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ namespace spt
QString id, name, image;
QVector<Track> topTracks(Spotify &spotify);
QVector<Album> albums(Spotify &spotify);
QVector<Artist> relatedArtists(Spotify &spotify);
};
}

0 comments on commit 488d215

Please sign in to comment.