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
 void NRJ::setupPlayer()
18
 void NRJ::setupPlayer()
19
 {
19
 {
20
     tries = 0;
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
     connect(reply, SIGNAL(finished()), this, SLOT(onSetupFinished()));
22
     connect(reply, SIGNAL(finished()), this, SLOT(onSetupFinished()));
23
     connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onSetupError(QNetworkReply::NetworkError)));
23
     connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onSetupError(QNetworkReply::NetworkError)));
24
 }
24
 }
29
         return;
29
         return;
30
     tries = 0;
30
     tries = 0;
31
     QUrl url = apiBase;
31
     QUrl url = apiBase;
32
-    QUrlQuery query;
32
+    QUrlQuery query(apiBase.query());
33
     query.addQueryItem("act", "get_allcur");
33
     query.addQueryItem("act", "get_allcur");
34
     url.setQuery(query);
34
     url.setQuery(query);
35
 
35
 
38
     connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onGetAllCurError(QNetworkReply::NetworkError)));
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
 void NRJ::onSetupFinished()
46
 void NRJ::onSetupFinished()
42
 {
47
 {
43
     QNetworkReply* reply = (QNetworkReply*)sender();
48
     QNetworkReply* reply = (QNetworkReply*)sender();
88
 void NRJ::onGetAllCurFinished()
93
 void NRJ::onGetAllCurFinished()
89
 {
94
 {
90
     QNetworkReply* reply = (QNetworkReply*)sender();
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
     for(unsigned i = 0;i < itms.size(); ++i)
99
     for(unsigned i = 0;i < itms.size(); ++i)
94
     {
100
     {

+ 2
- 1
nrj.h View File

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

Loading…
Cancel
Save