names;
-
- if (dev) {
- StationEntry entry;
-
- while (!dev->atEnd()) {
- QString line=dev->readLine().trimmed().replace("> <", "><").replace("", "").replace(" ", " ")
- .replace(" ,", ",");
- if (" | "==line) {
- entry.clear();
- } else if (line.startsWith("| ", "");
- QString extra=getString(line, "", " | ");
- if (!extra.isEmpty()) {
- entry.name+=" "+extra;
- }
- } else {
- // Station URLs...
- QString url;
- QString bitrate;
- int idx=0;
- do {
- url=getString(line, "href=\"", "\"");
- bitrate=getString(line, ">", " Kbps");
- bool sameFormatAsLast=line.startsWith(",");
- if (!url.isEmpty() && !bitrate.isEmpty() && !url.startsWith(QLatin1String("javascript")) && idx
")) {
- if (entry.location.isEmpty()) {
- entry.location=getString(line, "", " | ");
- } else {
- entry.comment=getString(line, "", " | ");
- }
- } else if ("
"==line) {
- if (entry.streams.count()) {
- qSort(entry.streams);
- QString name;
- QUrl url=entry.streams.at(0).url;
-
- if (QLatin1String("National")==entry.location || entry.name.endsWith("("+entry.location+")")) {
- name=entry.name;
- } else if (entry.name.endsWith(")")) {
- name=entry.name.left(entry.name.length()-1)+", "+entry.location+")";
- } else {
- name=entry.name+" ("+entry.location+")";
- }
-
- if (!names.contains(name) && !name.isEmpty() && url.isValid()) {
- QString genre=fixGenres(entry.comment);
- StreamsModel::StreamItem *item=new StreamsModel::StreamItem(name, genre, QString(), url);
- streams.append(item);
-// foreach (const QString &genre, item->genres) {
-// genres.insert(genre, item);
-// }
- names.insert(item->name);
- }
- }
- }
- }
- }
-
-// trimGenres(genres);
- return streams;
-}
-
-DigitallyImportedWebStream::DigitallyImportedWebStream(const QString &n, const QString &i, const QString &r, const QUrl &u)
- : WebStream(n, i, r, u)
-// , premiumStream(-1)
-{
- QStringList parts=u.host().split(".");
- if (3==parts.count()) {
- serviceName=parts.at(1);
- }
- listenHost=QLatin1String("listen.")+u.host().remove("www.");
-}
-
-QList DigitallyImportedWebStream::parse(QIODevice *dev)
-{
- QList streams;
- QJson::Parser parser;
- QVariantMap data = parser.parse(dev).toMap();
-
- if (data.contains("channel_filters")) {
- QVariantList filters = data["channel_filters"].toList();
-
- foreach (const QVariant &filter, filters) {
- // Find the filter called "All"
- QVariantMap filterMap = filter.toMap();
- if (filterMap.value("name", QString()).toString() != "All") {
- continue;
- }
-
- // Add all its stations to the result
- QVariantList channels = filterMap.value("channels", QVariantList()).toList();
- foreach (const QVariant &channel, channels) {
- QVariantMap channelMap = channel.toMap();
- QString u=constDiStdUrl.arg(listenHost).arg(channelMap.value("key").toString());
-
- StreamsModel::StreamItem *item=new StreamsModel::StreamItem(channelMap.value("name").toString(), QString(), QString(), QUrl(u));
- streams.append(item);
- }
-
- break;
- }
- }
-
- return streams;
-}
-
-QUrl DigitallyImportedWebStream::channelListUrl() const
-{
- return QUrl(constDiChannelListUrl.arg(serviceName));
-}
-
-void DigitallyImportedWebStream::addHeaders(QNetworkRequest &r)
-{
- #if QT_VERSION < 0x050000
- r.setRawHeader("Authorization", "Basic "+QString("%1:%2").arg(constDiApiUsername, constDiApiPassword).toAscii().toBase64());
- #else
- r.setRawHeader("Authorization", "Basic "+QString("%1:%2").arg(constDiApiUsername, constDiApiPassword).toLatin1().toBase64());
- #endif
-}
-
-//QUrl DigitallyImportedWebStream::modifyUrl(const QUrl &u) const
-//{
-// if (premiumHash.isEmpty()) {
-// return u;
-// }
-// QUrl modified(u);
-// #if QT_VERSION < 0x050000
-// QUrl &query=url;
-// #else
-// QUrlQuery query;
-// #endif
-// QString host=modified.host();
-// if (2==premiumStream || premiumStream<0 || premiumStream>2) {
-// host=host.replace("public3", "premium");
-// } else if (1==premiumStream) {
-// host=host.replace("public3", "premium_medium");
-// } else if (0==premiumStream) {
-// host=host.replace("public3", "premium_high");
-// }
-// modified.setHost(host);
-// query.addQueryItem("hash", premiumHash);
-// #if QT_VERSION >= 0x050000
-// modified.setQuery(query);
-// #endif
-// return modified;
-//}
diff --git a/streams/webstreams.h b/streams/webstreams.h
deleted file mode 100644
index c37e19aac..000000000
--- a/streams/webstreams.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Cantata
- *
- * Copyright (c) 2011-2013 Craig Drummond
- *
- * ----
- *
- * This program 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef WEBSTREAMS_H
-#define WEBSTREAMS_H
-
-#include "streamsmodel.h"
-#include
-#include
-
-class QNetworkReply;
-class QNetworkRequest;
-
-class WebStream : public QObject
-{
- Q_OBJECT
-public:
- static QList getAll();
- static WebStream * get(const QUrl &url);
-
- WebStream(const QString &n, const QString &i, const QString &r, const QUrl &u)
- : name(n),icon(i), region(r), url(u), job(0) { }
- virtual ~WebStream() { }
-
- virtual QList parse(QIODevice *dev)=0;
-
- const QString & getName() const { return name; }
- const QString & getIcon() const { return icon; }
- const QString & getRegion() const { return region; }
- const QUrl & getUrl() const { return url; }
- bool isDownloading() const { return 0!=job; }
- void download();
- void cancelDownload();
-// virtual QUrl modifyUrl(const QUrl &u) const { return u; }
-
-Q_SIGNALS:
- void finished();
- void error(const QString &);
-
-private Q_SLOTS:
- void downloadFinished();
-
-private:
- virtual QUrl channelListUrl() const { return url; }
- virtual void addHeaders(QNetworkRequest &) { }
-
-protected:
- QString name;
- QString icon;
- QString region;
- QUrl url;
- QNetworkReply *job;
-};
-
-class IceCastWebStream : public WebStream
-{
-public:
- IceCastWebStream(const QString &n, const QString &i, const QString &r, const QUrl &u)
- : WebStream(n, i, r, u) { }
- QList parse(QIODevice *dev);
-};
-
-class SomaFmWebStream : public WebStream
-{
-public:
- SomaFmWebStream(const QString &n, const QString &i, const QString &r, const QUrl &u)
- : WebStream(n, i, r, u) { }
- QList parse(QIODevice *dev);
-};
-
-class RadioWebStream : public WebStream
-{
-public:
- RadioWebStream(const QString &n, const QString &i, const QString &r, const QUrl &u)
- : WebStream(n, i, r, u) { }
- QList parse(QIODevice *dev);
-};
-
-class DigitallyImportedWebStream: public WebStream
-{
-public:
- DigitallyImportedWebStream(const QString &n, const QString &i, const QString &r, const QUrl &u);
- QList parse(QIODevice *dev);
-
-private:
- QUrl channelListUrl() const;
- void addHeaders(QNetworkRequest &r);
-// QUrl modifyUrl(const QUrl &u) const;
-
-private:
- QString listenHost;
- QString serviceName;
-// QString premiumHash;
-// int premiumStream;
-};
-
-#endif