TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicmvradiocategoryrequest.cpp
Go to the documentation of this file.
2 
5 {
6 
7 }
8 
10 {
12  if(m_reply && m_reply->error() == QNetworkReply::NoError)
13  {
14  QByteArray bytes = m_reply->readAll();
15  bytes = QString(bytes).split("var mvfmdata = ").back().split("$img = ").front().toUtf8();
16  bytes.chop(3);
17 
18  QJson::Parser json;
19  bool ok = false;
20  const QVariant &data = json.parse(bytes, &ok);
21  if(ok)
22  {
23  const QVariantList &datas = data.toList();
24  for(const QVariant &var : qAsConst(datas))
25  {
26  if(var.isNull())
27  {
28  continue;
29  }
30 
31  QVariantMap value = var.toMap();
33 
34  if(value["classId"].toString() == m_queryValue)
35  {
36  const QVariantList &fms = value["fm_list"].toList();
37  for(const QVariant &var : qAsConst(fms))
38  {
39  if(var.isNull())
40  {
41  continue;
42  }
43 
44  value = var.toMap();
46 
48  item.m_name = value["fmName"].toString();
49  item.m_id = value["fmId"].toString();
50  item.m_coverUrl = value["imgUrlMv"].toString();
51  Q_EMIT createMVRadioItem(item);
52  }
53  }
54  }
55  }
56  }
57 
58  Q_EMIT downLoadDataChanged({});
59  deleteAll();
60 }
#define TTK_NETWORK_QUERY_CHECK(VALUE)
MusicMVRadioCategoryRequest(QObject *parent=nullptr)
The class of the search result data item.
virtual void deleteAll()
void downLoadDataChanged(const QString &bytes)
QNetworkReply * m_reply
The class of the music mv radio request abstract.
#define qAsConst
Definition: ttkqtglobal.h:53
QVariant parse(QIODevice *io, bool *ok=0)
Read JSON string from the I/O Device and converts it to a QVariant object.
Definition: parser.cpp:69
virtual void downLoadFinished() override
void createMVRadioItem(const MusicResultDataItem &item)
TTK_MODULE_EXPORT QString toString(Record type)
virtual void downLoadFinished() overridefinal
Main class used to convert JSON data to QVariant objects.
Definition: parser.h:40