Commit missing GS radio files

This commit is contained in:
Arnaud Bienner 2011-11-29 14:13:41 +01:00
parent 0aba1ce77d
commit 1c99c8cc3b
3 changed files with 101 additions and 1 deletions

View File

@ -0,0 +1,54 @@
/* This file is part of Clementine.
Copyright 2011, David Sansome <me@davidsansome.com>
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 <http://www.gnu.org/licenses/>.
*/
#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;
}

View File

@ -0,0 +1,46 @@
/* This file is part of Clementine.
Copyright 2011, David Sansome <me@davidsansome.com>
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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -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<QString, QVariant> Param;