diff --git a/src/internet/groovesharkradio.cpp b/src/internet/groovesharkradio.cpp new file mode 100644 index 000000000..70de79e04 --- /dev/null +++ b/src/internet/groovesharkradio.cpp @@ -0,0 +1,54 @@ +/* This file is part of Clementine. + Copyright 2011, David Sansome + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#include "groovesharkradio.h" + +#include "groovesharkservice.h" +#include "core/logging.h" +#include "internet/internetplaylistitem.h" + +GroovesharkRadio::GroovesharkRadio() + : tag_id_(0), + first_time_(true) { +} + +GroovesharkRadio::GroovesharkRadio(GroovesharkService* service, int tag_id) + : service_(service), + tag_id_(tag_id), + first_time_(true) { +} + +void GroovesharkRadio::Load(const QByteArray& data) { +} + +QByteArray GroovesharkRadio::Save() const { + return QByteArray(); +} + +PlaylistItemList GroovesharkRadio::Generate() { + PlaylistItemList items; + if (first_time_) { + Song song = service_->StartAutoplayTag(tag_id_, autoplay_state_); + PlaylistItemPtr playlist_item = PlaylistItemPtr(new InternetPlaylistItem(service_, song)); + items << playlist_item; + first_time_ = false; + } + Song song = service_->GetAutoplaySong(autoplay_state_); + PlaylistItemPtr playlist_item = PlaylistItemPtr(new InternetPlaylistItem(service_, song)); + items << playlist_item; + return items; +} diff --git a/src/internet/groovesharkradio.h b/src/internet/groovesharkradio.h new file mode 100644 index 000000000..5bd1298cc --- /dev/null +++ b/src/internet/groovesharkradio.h @@ -0,0 +1,46 @@ +/* This file is part of Clementine. + Copyright 2011, David Sansome + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef GROOVESHARKDYNAMICPLAYLIST_H +#define GROOVESHARKDYNAMICPLAYLIST_H + +#include "smartplaylists/generator.h" + +class GroovesharkService; + +class GroovesharkRadio : public smart_playlists::Generator { + +public: + //GroovesharkRadio(); + GroovesharkRadio(GroovesharkService* service, int tag_id); + + QString type() const { return "Grooveshark"; } + void Load(const QByteArray& data); + QByteArray Save() const; + PlaylistItemList Generate(); + PlaylistItemList GenerateMore(int count) { return Generate(); } + bool is_dynamic() const { return true; } + +private: + GroovesharkService* service_; + int tag_id_; + // For Generate: indicates if it's the first time we generate songs + bool first_time_; + QVariantMap autoplay_state_; +}; + +#endif // GROOVESHARKDYNAMICPLAYLIST_H diff --git a/src/internet/groovesharkservice.cpp b/src/internet/groovesharkservice.cpp index c4866705a..cae2d8991 100644 --- a/src/internet/groovesharkservice.cpp +++ b/src/internet/groovesharkservice.cpp @@ -74,7 +74,7 @@ const char* GroovesharkService::kUrlCover = "http://beta.grooveshark.com/static/ const char* GroovesharkService::kHomepage = "http://grooveshark.com/"; const int GroovesharkService::kSearchDelayMsec = 400; -const int GroovesharkService::kSongSearchLimit = 50; +const int GroovesharkService::kSongSearchLimit = 100; const int GroovesharkService::kSongSimpleSearchLimit = 10; typedef QPair Param;