TTKMusicPlayer  4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicnetworkoperator.cpp
Go to the documentation of this file.
1 #include "musicnetworkoperator.h"
3 
4 static constexpr const char *IP_CHECK_URL = "ZlhkcnFzd1RabVhCZXNWM1pnbk5hT1ErL2RpMUNjK0hYQ3FXUHdCOVNGSlpDU2ZmNTZnekhHUlo3WkwrUWhtQXljNitUcjJmZ0RId004OFc5QlVibjhvRGlRSzY3QXlVbmZHNFV3bkhZdGZMU2JTZ3lJTkNhOGZJUlNhcmlBUmcvRUVrQWc9PQ==";
5 
7  : QObject(parent)
8 {
9 
10 }
11 
13 {
15  connect(d, SIGNAL(downLoadRawDataChanged(QByteArray)), SLOT(downLoadFinished(QByteArray)));
17 }
18 
19 void MusicNetworkOperator::downLoadFinished(const QByteArray &bytes)
20 {
21  QString line;
22  if(bytes.isEmpty())
23  {
24  TTK_ERROR_STREAM("Input byte data is empty");
25  }
26  else
27  {
28  QJsonParseError ok;
29  const QJsonDocument &json = QJsonDocument::fromJson(bytes, &ok);
31  {
32  QVariantMap value = json.toVariant().toMap();
33  if(value.contains("result"))
34  {
35  value = value["result"].toMap();
36  line = value["operators"].toString();
37  }
38  }
39  }
40 
41  Q_EMIT queryNetworkOperatorFinished(line);
42  deleteLater();
43 }
QVariant toVariant() const
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=0)
ParseError error
void queryNetworkOperatorFinished(const QString &name)
The class of the data source download request.
void startToRequest(const QString &url)
static constexpr const char * IP_CHECK_URL
MusicNetworkOperator(QObject *parent=nullptr)
void downLoadFinished(const QByteArray &bytes)
#define TTK_ERROR_STREAM(msg)
Definition: ttklogger.h:76
TTK_MODULE_EXPORT QString mdII(const QString &data, bool encode)