From 488d2152d07ba1a7df3d2a333697dacaaf807d03 Mon Sep 17 00:00:00 2001 From: kraxarn Date: Wed, 26 Feb 2020 01:10:11 +0100 Subject: [PATCH] Add loading of related artists --- src/spotify/artist.cpp | 11 +++++++++++ src/spotify/artist.hpp | 1 + 2 files changed, 12 insertions(+) diff --git a/src/spotify/artist.cpp b/src/spotify/artist.cpp index 4c9970927..45be63b5a 100644 --- a/src/spotify/artist.cpp +++ b/src/spotify/artist.cpp @@ -34,3 +34,14 @@ QVector Artist::albums(Spotify &spotify) albums.append(Album(item.toObject())); return albums; } + +QVector Artist::relatedArtists(Spotify &spotify) +{ + auto json = spotify.get(QString("artists/%1/related-artists").arg(id)); + auto items = json["artists"].toArray(); + QVector artists; + artists.reserve(items.size()); + for (auto item : items) + artists.append(Artist(item.toObject())); + return artists; +} diff --git a/src/spotify/artist.hpp b/src/spotify/artist.hpp index 5c971e80a..9fe8c4219 100644 --- a/src/spotify/artist.hpp +++ b/src/spotify/artist.hpp @@ -23,5 +23,6 @@ namespace spt QString id, name, image; QVector topTracks(Spotify &spotify); QVector albums(Spotify &spotify); + QVector relatedArtists(Spotify &spotify); }; } \ No newline at end of file