Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
z52c authored Jul 13, 2018
1 parent 563386a commit bd5403f
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 5 deletions.
5 changes: 5 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ struct downloadQueueInfo{
#define SINGERLINKHEAD "https://y.qq.com/n/yqq/singer/"
#define SINGERLINKTAIL ".html"

#define SINGERALBUMHEAD "https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_album.fcg?g_tk=5381&jsonCallback=MusicJsonCallbacksinger_album&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq&needNewCode=0&singermid="
#define SINGERALBUMMID1 "&order=time&begin="
#define SINGERALBUMMID2 "&num="
#define SINGERALBUMTAIL "&exstatus=1"

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 拼接歌手单曲列表下载链接:HEAD+SINGERMID+MID+BEGINNUM+TAIL*
* 每页30个,下载后拼接文件,begin确定从哪一个开始 *
Expand Down
3 changes: 2 additions & 1 deletion downloadqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ void downloadQueue::oneTaskFinished()
downloading=false;
db->deleteFromDownloadQueue(queueList.at(0).url);
queueList.removeAt(0);
doJob();
emit finished(mp3Dir);
doJob();

}

void downloadQueue::insertQueue(int inFlag, int inQuality, int inNameType, QString inDir, QString inUrl)
Expand Down
7 changes: 7 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ MainWindow::MainWindow(QWidget *parent) :
h=new help();
t=new thanks();
p=new proxyForm();
_singerAllAlbum=new singerAllAlbum();
_singerAllAlbum->setDownloadQueue(dq);

_vkeyinit2=new vkeyinit2();
connect(_vkeyinit2,SIGNAL(status(QString)),this,SLOT(status(QString)));
Expand Down Expand Up @@ -171,3 +173,8 @@ void MainWindow::on_action_3_triggered()
{
p->show();
}

void MainWindow::on_action_4_triggered()
{
_singerAllAlbum->show();
}
4 changes: 4 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QDesktopServices>
#include <QFileDialog>
#include <QtDebug>
#include "singerallalbum.h"

namespace Ui {
class MainWindow;
Expand Down Expand Up @@ -56,6 +57,8 @@ private slots:

void on_action_3_triggered();

void on_action_4_triggered();

private:
Ui::MainWindow *ui;
int songNameType;
Expand All @@ -67,6 +70,7 @@ private slots:
help *h;
thanks *t;
proxyForm *p;
singerAllAlbum *_singerAllAlbum;
vkeyinit2 *_vkeyinit2;
};

Expand Down
12 changes: 12 additions & 0 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,15 @@
</property>
<addaction name="action_3"/>
</widget>
<widget class="QMenu" name="menu_3">
<property name="title">
<string>下载歌手所有专辑</string>
</property>
<addaction name="action_4"/>
</widget>
<addaction name="menu"/>
<addaction name="menu_2"/>
<addaction name="menu_3"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
Expand All @@ -276,6 +283,11 @@
<string>代理</string>
</property>
</action>
<action name="action_4">
<property name="text">
<string>下载歌手所有专辑</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
Expand Down
9 changes: 6 additions & 3 deletions musicDownloader.pro
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ SOURCES += \
qqmusicplaylist.cpp \
qqmusicsearch.cpp \
qqmusicsong.cpp \
vkeyinit2.cpp
vkeyinit2.cpp \
singerallalbum.cpp

HEADERS += \
mainwindow.h \
Expand All @@ -63,13 +64,15 @@ HEADERS += \
qqmusicplaylist.h \
qqmusicsearch.h \
qqmusicsong.h \
vkeyinit2.h
vkeyinit2.h \
singerallalbum.h

FORMS += \
mainwindow.ui \
help.ui \
proxyform.ui \
thanks.ui
thanks.ui \
singerallalbum.ui

RESOURCES += \
pic.qrc
Expand Down
2 changes: 1 addition & 1 deletion musicDownloader.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.6.1, 2018-07-12T22:11:33. -->
<!-- Written by QtCreator 4.6.1, 2018-07-12T23:57:47. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
165 changes: 165 additions & 0 deletions singerallalbum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#include "singerallalbum.h"
#include "ui_singerallalbum.h"

singerAllAlbum::singerAllAlbum(QWidget *parent) :
QWidget(parent),
ui(new Ui::singerAllAlbum)
{
songNameType=0;
songQuality=0;
ui->setupUi(this);
d=new downloader();
connect(d,SIGNAL(finished()),this,SLOT(downloadFinished()));
connect(d,SIGNAL(downloadError(QString)),this,SLOT(downloadFailed(QString)));
connect(d,SIGNAL(redirected(QString)),this,SLOT(downloadFailed(QString)));
}

singerAllAlbum::~singerAllAlbum()
{
delete ui;
}

void singerAllAlbum::on_pushButtonChosePath_clicked()
{
mp3Dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
ui->lineEditMp3Path->setText(mp3Dir);
}

void singerAllAlbum::on_radioButtonSongNameType1_clicked()
{
songNameType=1;
}

void singerAllAlbum::on_radioButtonSongNameType2_clicked()
{
songNameType=2;
}

void singerAllAlbum::on_radioButtonQuality128_clicked()
{
songQuality=1;
}

void singerAllAlbum::on_radioButtonQuality320_clicked()
{
songQuality=2;
}

void singerAllAlbum::on_radioButtonQualityflac_clicked()
{
songQuality=3;
}

void singerAllAlbum::on_radioButtonQualityape_clicked()
{
songQuality=4;
}

void singerAllAlbum::on_pushButton_clicked()
{
ui->textEdit->clear();
mp3Dir=ui->lineEditMp3Path->text();
if(!songNameType || !songQuality || ui->lineEditMp3Path->text().isEmpty() || ui->lineEditSingerUrl->text().isEmpty())
{
ui->textEdit->append("请输入合法的设置");
}
else{
if(ui->lineEditSingerUrl->text().contains("y.qq.com/n/yqq/singer"))
{
if(ui->lineEditSingerUrl->text().contains("num"))
{
ui->textEdit->append("请选择不含num的链接");
return;
}
ui->pushButton->setEnabled(false);
doJob();
}
else{
ui->textEdit->append("请填入如https://y.qq.com/n/yqq/singer/002J4UUk29y8BY.html的歌手链接");
}
}
}

void singerAllAlbum::setDownloadQueue(downloadQueue *inDQ)
{
dq=inDQ;
}

void singerAllAlbum::doJob()
{
singerName="";
albumList.clear();
albumNum=0;
nowNum=30;
char tmp[30];
getStringBetweenAandB(ui->lineEditSingerUrl->text().toStdString().c_str(),"yqq/singer/",".html",tmp);
singerMid=tmp;

QString link=QString(SINGERALBUMHEAD)+singerMid+QString(SINGERALBUMMID1)+QString("0")+QString(SINGERALBUMMID2)+QString("30")+QString(SINGERALBUMTAIL);
d->init(link,"singerAllAlbum.tmp");
d->setUserAgent(UA);
d->setReferer("https://y.qq.com");
d->doGet();
}

void singerAllAlbum::downloadFailed(QString inStr)
{
ui->textEdit->append("获取专辑信息失败,请联系作者");
ui->textEdit->append(inStr);
}

void singerAllAlbum::downloadFinished()
{
char tmp[200];
QFile file("singerAllAlbum.tmp");
if(file.open(QIODevice::ReadOnly))
{
QByteArray b=file.readAll();
QJsonParseError jsonError;
QJsonDocument doucment = QJsonDocument::fromJson(b,&jsonError);
if(jsonError.error!=QJsonParseError::NoError)
{
qDebug() << "read singerAllAlbum.tmp file failed";
qDebug()<<jsonError.error;
qDebug()<<jsonError.errorString();
ui->textEdit->append("read singerAllAlbum.tmp file failed");
file.close();
ui->pushButton->setEnabled(true);
return;
}
QJsonObject obj=doucment.object();
obj=obj["data"].toObject();
if(nowNum==30)
{
singerName=obj["singer_name"].toString();
albumNum=obj["total"].toInt();
}
QJsonArray tmpArray=obj["list"].toArray();

while(tmpArray.count()>0)
{
obj=tmpArray.first().toObject();
albumList.append(obj["albumMID"].toString());
qDebug()<<albumList.last();
tmpArray.removeFirst();
}
file.close();
}
if(nowNum<albumNum)
{
QString link=QString(SINGERALBUMHEAD)+singerMid+QString(SINGERALBUMMID1)+QString::number(nowNum)+QString(SINGERALBUMMID2)+QString::number(nowNum+30)+QString(SINGERALBUMTAIL);
nowNum+=30;
d->init(link,"singerAllAlbum.tmp");
d->doGet();
}
else
{
while(albumList.count()>0)
{
dq->insertQueue(0,songQuality,songNameType,mp3Dir+QString("/%1").arg(singerName),QString("https://y.qq.com/n/yqq/album/%1.html").arg(albumList.first()));
albumList.removeFirst();
}
ui->pushButton->setEnabled(true);
ui->textEdit->append(QString("%1张专辑已经添加到下载队列,请回到主页面查看进度,当前界面可以关闭").arg(albumNum));
}
}
64 changes: 64 additions & 0 deletions singerallalbum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef SINGERALLALBUM_H
#define SINGERALLALBUM_H

#include <QWidget>
#include "downloadqueue.h"
#include "downloader.h"
#include "config.h"
#include <QFileDialog>

namespace Ui {
class singerAllAlbum;
}

class singerAllAlbum : public QWidget
{
Q_OBJECT

public:
explicit singerAllAlbum(QWidget *parent = 0);
void setDownloadQueue(downloadQueue *inDQ);
~singerAllAlbum();

private slots:
void on_pushButtonChosePath_clicked();

void on_radioButtonSongNameType1_clicked();

void on_radioButtonSongNameType2_clicked();

void on_radioButtonQuality128_clicked();

void on_radioButtonQuality320_clicked();

void on_radioButtonQualityflac_clicked();

void on_radioButtonQualityape_clicked();

void on_pushButton_clicked();

void downloadFinished();
void downloadFailed(QString inStr);

private:
Ui::singerAllAlbum *ui;

int songNameType;
int songQuality;
QString mp3Dir;

downloadQueue *dq;
downloader *d;

int albumNum;
int nowNum;


QString singerMid;
QStringList albumList;
QString singerName;

void doJob();
};

#endif // SINGERALLALBUM_H
Loading

0 comments on commit bd5403f

Please sign in to comment.