-
Notifications
You must be signed in to change notification settings - Fork 52
/
qqmusic.cpp
86 lines (76 loc) · 2.56 KB
/
qqmusic.cpp
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
#include "qqmusic.h"
qqmusic::qqmusic(QObject *parent) : QObject(parent)
{
album=new qqMusicAlbum();
connect(album,SIGNAL(status(QString)),this,SIGNAL(status(QString)));
connect(album,SIGNAL(finished(int,QStringList)),this,SLOT(beginToDownload(int,QStringList)));
playlist=new qqMusicPlaylist();
connect(playlist,SIGNAL(status(QString)),this,SIGNAL(status(QString)));
connect(playlist,SIGNAL(finished(int,QStringList)),this,SLOT(beginToDownload(int,QStringList)));
song=new qqMusicSong();
connect(song,SIGNAL(status(QString)),this,SIGNAL(status(QString)));
connect(song,SIGNAL(progress(qint64,qint64)),this,SIGNAL(progress(qint64,qint64)));
connect(song,SIGNAL(finished(int)),this,SLOT(songDownloadFinished(int)));
}
void qqmusic::doJob(QString inlink)
{
songMidList.clear();
index=0;
total=0;
char tmpMid[20];
if(inlink.contains("y.qq.com/n/yqq/song"))
{
getStringBetweenAandB(inlink.toStdString().c_str(),"y.qq.com/n/yqq/song/",".html",tmpMid);
songMidList.append(QString(tmpMid));
downloadSong();
return;
}
if(inlink.contains("y.qq.com/n/yqq/album"))
{
getStringBetweenAandB(inlink.toStdString().c_str(),"y.qq.com/n/yqq/album/",".html",tmpMid);
album->doJob(QString(tmpMid));
return;
}
if(inlink.contains("y.qq.com/n/yqq/playsquare"))
{
getStringBetweenAandB(inlink.toStdString().c_str(),"y.qq.com/n/yqq/playsquare/",".html",tmpMid);
playlist->doJob(QString(tmpMid));
return;
}
if(inlink.contains("y.qq.com/n/yqq/playlist"))
{
getStringBetweenAandB(inlink.toStdString().c_str(),"y.qq.com/n/yqq/playlist/",".html",tmpMid);
playlist->doJob(QString(tmpMid));
return;
}
}
void qqmusic::beginToDownload(int inFlag, QStringList inSongMidList)
{
if(inFlag)
{
emit finished();
return;
}
else{
songMidList=inSongMidList;
downloadSong();
}
}
void qqmusic::downloadSong()
{
total=songMidList.count();
emit status(QString("下载第1/")+QString::number(total)+QString("首..."));
song->doJob(songMidList.at(0));
}
void qqmusic::songDownloadFinished(int inFlag)
{
songMidList.removeAt(0);
if(songMidList.count()>0)
{
emit status(QString("下载第")+QString::number(total-songMidList.count()+1)+QString("/")+QString::number(total)+QString("首..."));
song->doJob(songMidList.at(0));
}
else{
emit finished();
}
}