2011-11-06 00:22:25 +01:00
|
|
|
/* 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 "icecastsearchprovider.h"
|
2014-12-18 23:35:21 +01:00
|
|
|
#include "internet/icecast/icecastbackend.h"
|
2011-11-06 00:22:25 +01:00
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
IcecastSearchProvider::IcecastSearchProvider(IcecastBackend* backend,
|
|
|
|
Application* app, QObject* parent)
|
2014-02-07 16:34:20 +01:00
|
|
|
: BlockingSearchProvider(app, parent), backend_(backend) {
|
|
|
|
Init("Icecast", "icecast", QIcon(":last.fm/icon_radio.png"),
|
|
|
|
DisabledByDefault);
|
2011-11-06 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
SearchProvider::ResultList IcecastSearchProvider::Search(int id,
|
|
|
|
const QString& query) {
|
2011-11-06 00:22:25 +01:00
|
|
|
IcecastBackend::StationList stations = backend_->GetStations(query);
|
|
|
|
ResultList ret;
|
|
|
|
|
2014-02-10 14:29:07 +01:00
|
|
|
for (const IcecastBackend::Station& station : stations) {
|
2014-02-07 16:34:20 +01:00
|
|
|
if (ret.count() > 3) break;
|
2011-11-06 00:22:25 +01:00
|
|
|
|
|
|
|
Result result(this);
|
2012-06-04 19:18:37 +02:00
|
|
|
result.group_automatically_ = false;
|
2011-11-06 00:22:25 +01:00
|
|
|
result.metadata_ = station.ToSong();
|
|
|
|
ret << result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|