Browse Source

fixed base api

master
Robin Thoni 9 years ago
parent
commit
3d181e0e45
2 changed files with 11 additions and 4 deletions
  1. 9
    3
      nrj.cpp
  2. 2
    1
      nrj.h

+ 9
- 3
nrj.cpp View File

@@ -18,7 +18,7 @@ QList<Radio *> NRJ::getRadios()
18 18
 void NRJ::setupPlayer()
19 19
 {
20 20
     tries = 0;
21
-    QNetworkReply* reply = mgr->get(QNetworkRequest(QUrl("http://players.nrjaudio.fm/live-metadata/player/nrj/v1.0/player_setup.yml")));
21
+    QNetworkReply* reply = mgr->get(QNetworkRequest(QUrl("http://players.nrjaudio.fm/live-metadata/player/" + radio + "/v1.0/player_setup.yml")));
22 22
     connect(reply, SIGNAL(finished()), this, SLOT(onSetupFinished()));
23 23
     connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onSetupError(QNetworkReply::NetworkError)));
24 24
 }
@@ -29,7 +29,7 @@ void NRJ::getAllCur()
29 29
         return;
30 30
     tries = 0;
31 31
     QUrl url = apiBase;
32
-    QUrlQuery query;
32
+    QUrlQuery query(apiBase.query());
33 33
     query.addQueryItem("act", "get_allcur");
34 34
     url.setQuery(query);
35 35
 
@@ -38,6 +38,11 @@ void NRJ::getAllCur()
38 38
     connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onGetAllCurError(QNetworkReply::NetworkError)));
39 39
 }
40 40
 
41
+void NRJ::setRadio(QString radio)
42
+{
43
+    this->radio = radio;
44
+}
45
+
41 46
 void NRJ::onSetupFinished()
42 47
 {
43 48
     QNetworkReply* reply = (QNetworkReply*)sender();
@@ -88,7 +93,8 @@ void NRJ::onSetupError(QNetworkReply::NetworkError)
88 93
 void NRJ::onGetAllCurFinished()
89 94
 {
90 95
     QNetworkReply* reply = (QNetworkReply*)sender();
91
-    YAML::Node itms = YAML::Load(reply->readAll().constData())["itms"];
96
+    QByteArray str = reply->readAll();
97
+    YAML::Node itms = YAML::Load(str.constData())["itms"];
92 98
 
93 99
     for(unsigned i = 0;i < itms.size(); ++i)
94 100
     {

+ 2
- 1
nrj.h View File

@@ -24,6 +24,7 @@ signals:
24 24
 public slots:
25 25
     void setupPlayer();
26 26
     void getAllCur();
27
+    void setRadio(QString radio);
27 28
 
28 29
 private slots:
29 30
     void onSetupFinished();
@@ -38,7 +39,7 @@ private:
38 39
     QUrl apiBase;
39 40
     QUrl coverBase;
40 41
     int tries;
41
-    
42
+    QString radio;
42 43
 };
43 44
 
44 45
 #endif // NRJ_H

Loading…
Cancel
Save