TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicdownloadbirdskinrequest.cpp
Go to the documentation of this file.
3 
4 static constexpr const char *MAIN_URL = "Q1VDQlUvWGpxVXBjclBxZHR2MUpGaWZoeUJpUlZYRDBsYkwyV3VyRzNIY1hpWnQweTFLNWNpaCtoenp5SkR6Sg==";
5 static constexpr const char *QUERY_URL = "MlVINmI0aGlvRXpvQVcwSklUUDRyVFVFdUExT0Rib3VuZlQ5QThRWTNyQUl4RkdlYmJLTmdrb2hVN21JZ2RZRHNYV1d3b09pcWRMcmM3d09SWWdIUlVwQ2NjSHhiSVg5V2R5ZmgyaEMyMVk9";
6 
9 {
10 
11 }
12 
14 {
16  connect(d, SIGNAL(downLoadRawDataChanged(QByteArray)), SLOT(downLoadFinished(QByteArray)));
18 }
19 
21 {
23  connect(d, SIGNAL(downLoadRawDataChanged(QByteArray)), SLOT(downLoadItemsFinished(QByteArray)));
24  d->startToRequest(TTK::Algorithm::mdII(QUERY_URL, false).arg(id));
25 }
26 
28 {
29  MusicSkinRemoteGroupList groups;
30 
31  QJson::Parser json;
32  bool ok = false;
33  const QVariant &data = json.parse(bytes, &ok);
34  if(ok)
35  {
36  QVariantMap value = data.toMap();
37  if(value.contains("data"))
38  {
39  const QVariantList &datas = value["data"].toList();
40  for(const QVariant &var : qAsConst(datas))
41  {
42  if(var.isNull())
43  {
44  continue;
45  }
46 
47  value = var.toMap();
48 
50  group.m_group = QString("%1%2").arg(SKIN_BIRD_DIR, value["category"].toString());
51  group.m_id = value["old_id"].toString();
52  groups << group;
53  }
54  }
55  }
56 
57  Q_EMIT downLoadDataChanged(groups);
58 }
59 
61 {
63 
64  QJson::Parser json;
65  bool ok = false;
66  const QVariant &data = json.parse(bytes, &ok);
67  if(ok)
68  {
69  QVariantMap value = data.toMap();
70  if(value.contains("data"))
71  {
72  value = value["data"].toMap();
73 
74  const QVariantList &datas = value["list"].toList();
75  for(const QVariant &var : qAsConst(datas))
76  {
77  if(var.isNull())
78  {
79  continue;
80  }
81 
82  value = var.toMap();
83 
85  item.m_name = value["tag"].toString();
86  item.m_index = value["id"].toInt();
87  item.m_useCount = item.m_index;
88  item.m_url = value["url"].toString();
89 
90  if(group.m_id.isEmpty())
91  {
92  group.m_id = value["class_id"].toString();
93  }
94 
95  if(item.isValid())
96  {
97  group.m_items << item;
98  }
99  }
100  }
101  }
102 
103  Q_EMIT downLoadItemsChanged(group);
104 }
virtual void startToRequest() overridefinal
void downLoadItemsFinished(const QByteArray &bytes)
The class of the remote skin item.
void downLoadDataChanged(const MusicSkinRemoteGroupList &bytes)
The class of the download skin remote background.
static constexpr const char * MAIN_URL
static constexpr const char * QUERY_URL
#define qAsConst
Definition: ttkqtglobal.h:53
The class of the data source download request.
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
MusicDownloadBirdSkinRequest(QObject *parent=nullptr)
virtual void downLoadFinished(const QByteArray &bytes) overridefinal
void startToRequest(const QString &url)
The class of the remote skin item group.
TTK_MODULE_EXPORT QString toString(Record type)
void downLoadItemsChanged(const MusicSkinRemoteGroup &bytes)
Main class used to convert JSON data to QVariant objects.
Definition: parser.h:40
TTK_MODULE_EXPORT QString mdII(const QString &data, bool encode)
static constexpr const char * SKIN_BIRD_DIR