1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-17 12:02:48 +01:00

Add user's Grooveshark favorites songs

This commit is contained in:
Arnaud Bienner 2011-10-29 20:42:25 +02:00
parent d3aa4f3a56
commit c8a4852843
2 changed files with 36 additions and 0 deletions

View File

@ -431,6 +431,7 @@ void GroovesharkService::EnsureItemsCreated() {
search_->setData(InternetModel::PlayBehaviour_DoubleClickAction,
InternetModel::Role_PlayBehaviour);
root_->appendRow(search_);
RetrieveUserFavorites();
RetrieveUserPlaylists();
}
}
@ -506,6 +507,39 @@ void GroovesharkService::PlaylistSongsRetrieved() {
root_->appendRow(item);
}
void GroovesharkService::RetrieveUserFavorites() {
QNetworkReply* reply = CreateRequest("getUserFavoriteSongs", QList<Param>(), true);
connect(reply, SIGNAL(finished()), SLOT(UserFavoritesRetrieved()));
}
void GroovesharkService::UserFavoritesRetrieved() {
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
if (!reply)
return;
reply->deleteLater();
// Create item
QStandardItem* item = new QStandardItem(QIcon(":/star-on.png"), tr("Favorites"));
item->setData(InternetModel::Type_UserPlaylist, InternetModel::Role_Type);
item->setData(true, InternetModel::Role_CanLazyLoad);
item->setData(InternetModel::PlayBehaviour_SingleItem, InternetModel::Role_PlayBehaviour);
QVariantMap result = ExtractResult(reply);
SongList songs = ExtractSongs(result);
foreach (const Song& song, songs) {
QStandardItem* child = new QStandardItem(song.PrettyTitleWithArtist());
child->setData(Type_Track, InternetModel::Role_Type);
child->setData(QVariant::fromValue(song), InternetModel::Role_SongMetadata);
child->setData(InternetModel::PlayBehaviour_SingleItem, InternetModel::Role_PlayBehaviour);
child->setData(song.url(), InternetModel::Role_Url);
item->appendRow(child);
}
root_->appendRow(item);
}
void GroovesharkService::MarkStreamKeyOver30Secs(const QString& stream_key,
const QString& server_id) {
QList<Param> parameters;

View File

@ -63,6 +63,7 @@ class GroovesharkService : public InternetService {
void Logout();
bool IsLoggedIn() const { return !session_id_.isEmpty(); }
void RetrieveUserPlaylists();
void RetrieveUserFavorites();
void MarkStreamKeyOver30Secs(const QString& stream_key, const QString& server_id);
void MarkSongComplete(const QString& song_id, const QString& stream_key, const QString& server_id);
@ -119,6 +120,7 @@ class GroovesharkService : public InternetService {
void GetAlbumSongsFinished(QNetworkReply* reply, int id);
void Authenticated();
void UserPlaylistsRetrieved();
void UserFavoritesRetrieved();
void PlaylistSongsRetrieved();
void StreamMarked();
void SongMarkedAsComplete();