forked from pansinm/CleanPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
baidumusic.h
140 lines (123 loc) · 3.66 KB
/
baidumusic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef BAIDUMUSIC_H
#define BAIDUMUSIC_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkCookieJar>
#include <QNetworkReply>
#include "cookiejar.h"
class BaiduMusic : public QObject
{
Q_OBJECT
public:
explicit BaiduMusic(QObject *parent = 0);
~BaiduMusic();
/**
* @brief search 搜索歌曲
* @param keyword 关键字
* @param page 页数
*/
Q_INVOKABLE void search(const QString& keyword, int page);
/**
* @brief getSuggestion 获取搜索建议
* @param keyword 百度音乐歌曲id
*/
Q_INVOKABLE void getSuggestion(QString keyword);
/**
* @brief getSongInfo 获取歌曲信息
* @param songId
*/
Q_INVOKABLE void getSongInfo(QString songId);
/**
* @brief getSongLink 获取歌曲链接,包括下载链接和歌词连接等
* @param songId
*/
Q_INVOKABLE void getSongLink(QString songId);
private:
QNetworkAccessManager manager;
QNetworkReply* searchReply;
QNetworkReply* suggestionReply;
QNetworkReply* songInfoReply;
QNetworkReply* songLinkReply;
QString nextKeywordOfSearch;
QString nextKeywordOfSug;
QString nextSongIdOfInfo;
QString nextSongIdOfLink;
//保存所有cookie
CookieJar cookieJar;
//同一结果,如songid转换为sid,songname转换为sname
QString unifyResult(QString r);
private slots:
void searchReplyFinished();
void suggestionReplyFinished();
void songInfoReplyFinished();
void songLinkReplyFinished();
signals:
/**
* @brief searchComplete 搜索完毕
* @param currentPage 当前页
* @param pageCount 总页数
* @param keyword 关键字
* @param songList 歌曲列表,json数据
* [
* {"songItem":
* {
* "sid":877578,
* "author":"Beyond",
* "sname":"海阔天空",
* "oid":877578,
* "pay_type":"2"
* }
* },
* {"songItem":
* ...
* },
* ...
* ]
*/
void searchComplete(int currentPage,int pageCount,QString keyword, QString songList);
/**
* @brief getSuggestionComplete 获取搜索建议完毕
* @param suggestion 搜索建议json数据
* {
* "data": {
* "song": [{
* "songid": "877578",
* "songname": "\u6d77\u9614\u5929\u7a7a",
* "encrypted_songid": "",
* "has_mv": "1",
* "yyr_artist": "0",
* "artistname": "Beyond"
* },
* ...
* ],
* "artist": [{
* "artistid": "2345733",
* "artistname": "\u6d77\u9614\u5929\u7a7a",
* "artistpic": "http:\/\/a.hiphotos.baidu.com\/ting\/pic\/item\/6d81800a19d8bc3eb42695cc808ba61ea8d3458d.jpg",
* "yyr_artist": "0"
* },
* ...
* ],
* "album": [{
* "albumid": "197864",
* "albumname": "\u6d77\u9614\u5929\u7a7a",
* "artistname": "Beyond",
* "artistpic": "http:\/\/a.hiphotos.baidu.com\/ting\/pic\/item\/6c224f4a20a4462314dd8c409a22720e0cf3d7f8.jpg"
* },
* ...
* ]
* },
* "Pro": ["artist", "song", "album"]
* }
*
*/
void getSuggestionComplete(QString suggestion);
void getSongInfoComplete(QString songInfo);
/**
* @brief getSongLinkComplete 获取歌曲连接完毕
* @param songLink
*/
void getSongLinkComplete(QString songLink);
public slots:
};
#endif // BAIDUMUSIC_H