fixed spelling mistake
This commit is contained in:
parent
7b671da37a
commit
fd6afe426d
|
@ -20,9 +20,9 @@ BitshareDownload::BitshareDownload(const QUrl &url, QObject *parent) :
|
|||
HttpDownloadWithInfoRequst(url, parent)
|
||||
{}
|
||||
|
||||
Download *BitshareDownload::infoRequestDownload(bool &sucess, QString &)
|
||||
Download *BitshareDownload::infoRequestDownload(bool &success, QString &)
|
||||
{
|
||||
sucess = true;
|
||||
success = true;
|
||||
HttpDownload *download = new HttpDownload(initialUrl());
|
||||
download->setCookieJar(usedCookieJar());
|
||||
return download;
|
||||
|
|
|
@ -12,7 +12,7 @@ class BitshareDownload : public HttpDownloadWithInfoRequst
|
|||
public:
|
||||
explicit BitshareDownload(const QUrl &url, QObject *parent = nullptr);
|
||||
|
||||
virtual Download *infoRequestDownload(bool &sucess, QString &reasonForFail);
|
||||
virtual Download *infoRequestDownload(bool &success, QString &reasonForFail);
|
||||
virtual QString typeName() const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -77,28 +77,28 @@ void FileNukeDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer
|
|||
}
|
||||
}
|
||||
|
||||
Download *FileNukeDownload::infoRequestDownload(bool &sucess, QString &reasonForFail)
|
||||
Download *FileNukeDownload::infoRequestDownload(bool &success, QString &reasonForFail)
|
||||
{
|
||||
HttpDownload *download;
|
||||
switch(m_currentStep) {
|
||||
case 0:
|
||||
download = new HttpDownload(initialUrl());
|
||||
sucess = true;
|
||||
success = true;
|
||||
return download;
|
||||
case 1:
|
||||
download = new HttpDownload(initialUrl());
|
||||
download->setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
download->setMethod(HttpDownloadMethod::Post);
|
||||
download->setPostData(m_postData);
|
||||
sucess = true;
|
||||
success = true;
|
||||
return download;
|
||||
case 2:
|
||||
download = new HttpDownload(m_playlistUrl);
|
||||
sucess = true;
|
||||
success = true;
|
||||
return download;
|
||||
default:
|
||||
reasonForFail = tr("Internal error.");
|
||||
sucess = false;
|
||||
success = false;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class FileNukeDownload : public HttpDownloadWithInfoRequst
|
|||
public:
|
||||
explicit FileNukeDownload(const QUrl &url, QObject *parent = nullptr);
|
||||
|
||||
Download *infoRequestDownload(bool &sucess, QString &reasonForFail);
|
||||
Download *infoRequestDownload(bool &success, QString &reasonForFail);
|
||||
QString typeName() const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -67,7 +67,7 @@ private slots:
|
|||
|
||||
private:
|
||||
void emitNewResultsSignal();
|
||||
void emitFinishedSignal(bool sucess, const QString &reason = QString());
|
||||
void emitFinishedSignal(bool success, const QString &reason = QString());
|
||||
|
||||
std::unique_ptr<Download> m_download;
|
||||
std::unique_ptr<QBuffer> m_buffer;
|
||||
|
@ -177,10 +177,10 @@ inline void DownloadFinder::reportCollectionTitle(const QString &title)
|
|||
/*!
|
||||
* \brief Emits the finished signal.
|
||||
*/
|
||||
inline void DownloadFinder::emitFinishedSignal(bool sucess, const QString &reason)
|
||||
inline void DownloadFinder::emitFinishedSignal(bool success, const QString &reason)
|
||||
{
|
||||
m_finished = true;
|
||||
emit finished(sucess, reason);
|
||||
emit finished(success, reason);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,14 +89,14 @@ GroovesharkDownload::GroovesharkDownload(GroovesharkRequestType requestType, con
|
|||
}
|
||||
}
|
||||
|
||||
Download *GroovesharkDownload::infoRequestDownload(bool &sucess, QString &reasonForFail)
|
||||
Download *GroovesharkDownload::infoRequestDownload(bool &success, QString &reasonForFail)
|
||||
{
|
||||
Download *download = nullptr;
|
||||
QJsonObject headerObj;
|
||||
QJsonObject paramObj;
|
||||
switch(m_currentStep) {
|
||||
case -1:
|
||||
sucess = true;
|
||||
success = true;
|
||||
break;
|
||||
case 0:
|
||||
if(m_sessionId.isNull()) {
|
||||
|
@ -108,7 +108,7 @@ Download *GroovesharkDownload::infoRequestDownload(bool &sucess, QString &reason
|
|||
headerObj.insert(QStringLiteral("country"), m_country);
|
||||
download = createJsonPostRequest(QStringLiteral("initiateSession"), headerObj, paramObj);
|
||||
}
|
||||
sucess = true;
|
||||
success = true;
|
||||
break;
|
||||
case 1:
|
||||
if(m_token.isEmpty()) {
|
||||
|
@ -122,7 +122,7 @@ Download *GroovesharkDownload::infoRequestDownload(bool &sucess, QString &reason
|
|||
paramObj.insert(QStringLiteral("secretKey"), generateSecretKey());
|
||||
download = createJsonPostRequest(QStringLiteral("getCommunicationToken"), headerObj, paramObj, true);
|
||||
}
|
||||
sucess = true;
|
||||
success = true;
|
||||
break;
|
||||
case 2:
|
||||
// getStreamKeyFromSongIDEx
|
||||
|
@ -138,11 +138,11 @@ Download *GroovesharkDownload::infoRequestDownload(bool &sucess, QString &reason
|
|||
paramObj.insert(QStringLiteral("songID"), QJsonValue(id()));
|
||||
paramObj.insert(QStringLiteral("prefetch"), QJsonValue(false));
|
||||
download = createJsonPostRequest("getStreamKeyFromSongIDEx", headerObj, paramObj);
|
||||
sucess = true;
|
||||
success = true;
|
||||
break;
|
||||
default:
|
||||
reasonForFail = QStringLiteral("Internal error.");
|
||||
sucess = false;
|
||||
success = false;
|
||||
}
|
||||
return download;
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ GroovesharkRequestType GroovesharkDownload::requestType() const
|
|||
|
||||
QString GroovesharkDownload::suitableFilename() const
|
||||
{
|
||||
QString filename = Download::suitableFilename();
|
||||
auto filename = Download::suitableFilename();
|
||||
if(!filename.endsWith(QLatin1String(".mp3"))) {
|
||||
filename.append(QStringLiteral(".mp3"));
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
explicit GroovesharkDownload(const QString &songId, QObject *parent = nullptr);
|
||||
explicit GroovesharkDownload(GroovesharkRequestType requestType, const QVariant &requestData, QObject *parent = nullptr);
|
||||
|
||||
Download *infoRequestDownload(bool &sucess, QString &reasonForFail);
|
||||
Download *infoRequestDownload(bool &success, QString &reasonForFail);
|
||||
bool isInitiatingInstantlyRecommendable() const;
|
||||
|
||||
static QJsonValue sessionId();
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
explicit HttpDownloadWithInfoRequst(const QUrl &url, QObject *parent = nullptr);
|
||||
~HttpDownloadWithInfoRequst();
|
||||
|
||||
virtual Download *infoRequestDownload(bool &sucess, QString &reasonForFail) = 0;
|
||||
virtual Download *infoRequestDownload(bool &success, QString &reasonForFail) = 0;
|
||||
void doInit();
|
||||
void abortDownload();
|
||||
|
||||
|
|
|
@ -23,29 +23,29 @@ SockshareDownload::SockshareDownload(const QUrl &url, QObject *parent) :
|
|||
m_currentStep(0)
|
||||
{}
|
||||
|
||||
Download *SockshareDownload::infoRequestDownload(bool &sucess, QString &reasonForFail)
|
||||
Download *SockshareDownload::infoRequestDownload(bool &success, QString &reasonForFail)
|
||||
{
|
||||
HttpDownload *download;
|
||||
switch(m_currentStep)
|
||||
{
|
||||
case 0:
|
||||
download = new HttpDownload(initialUrl());
|
||||
sucess = true;
|
||||
success = true;
|
||||
return download;
|
||||
case 1:
|
||||
download = new HttpDownload(initialUrl());
|
||||
download->setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
download->setMethod(HttpDownloadMethod::Post);
|
||||
download->setPostData(m_postData);
|
||||
sucess = true;
|
||||
success = true;
|
||||
return download;
|
||||
case 2:
|
||||
download = new HttpDownload(m_playlistUrl);
|
||||
sucess = true;
|
||||
success = true;
|
||||
return download;
|
||||
default:
|
||||
reasonForFail = tr("Internal error.");
|
||||
sucess = false;
|
||||
success = false;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class SockshareDownload : public HttpDownloadWithInfoRequst
|
|||
public:
|
||||
explicit SockshareDownload(const QUrl &url, QObject *parent = nullptr);
|
||||
|
||||
Download *infoRequestDownload(bool &sucess, QString &reasonForFail);
|
||||
Download *infoRequestDownload(bool &success, QString &reasonForFail);
|
||||
QString typeName() const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -54,26 +54,26 @@ void SpotifyDownload::resetSession()
|
|||
m_creationFlow.clear();
|
||||
}
|
||||
|
||||
Download *SpotifyDownload::infoRequestDownload(bool &sucess, QString &reasonForFail)
|
||||
Download *SpotifyDownload::infoRequestDownload(bool &success, QString &reasonForFail)
|
||||
{
|
||||
HttpDownload *download = nullptr;
|
||||
if(m_csrftoken.isEmpty() || m_trackingId.isEmpty()/* || creationFlow.isEmpty()*/) {
|
||||
if(m_triesToGetAuthenticationData < 2) {
|
||||
download = new HttpDownload(m_spotifyUrl);
|
||||
download->setCustomUserAgent(m_supportedUseragents.at(0));
|
||||
sucess = true;
|
||||
success = true;
|
||||
++m_triesToGetAuthenticationData;
|
||||
m_currentRequest = SpotifyRequestType::GetAuthenticationData;
|
||||
} else {
|
||||
reasonForFail = tr("Unable to find data required for autentication.");
|
||||
sucess = false;
|
||||
success = false;
|
||||
}
|
||||
} else if(!m_authenticationCredentialsValidated) {
|
||||
if(initialAuthenticationCredentials().isIncomplete()) {
|
||||
reportAuthenticationRequired(-1, tr("To download songs from Spotify authentication is required so you have to enter the credentials of your Spotify account."));
|
||||
reasonForFail = tr("Authentication credentials not given.");
|
||||
//networkError = QNetworkReply::AuthenticationRequiredError;
|
||||
sucess = false;
|
||||
success = false;
|
||||
} else {
|
||||
QUrl url(m_spotifyUrl);
|
||||
url.setPath(QStringLiteral("/xhr/json/auth.php"));
|
||||
|
@ -92,7 +92,7 @@ Download *SpotifyDownload::infoRequestDownload(bool &sucess, QString &reasonForF
|
|||
download->setPostData(postData);
|
||||
download->setCustomUserAgent(m_supportedUseragents.at(0));
|
||||
|
||||
sucess = true;
|
||||
success = true;
|
||||
m_currentRequest = SpotifyRequestType::Authenticate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class SpotifyDownload : public HttpDownloadWithInfoRequst
|
|||
public:
|
||||
explicit SpotifyDownload(const QString &songid, QObject *parent = nullptr);
|
||||
|
||||
Download *infoRequestDownload(bool &sucess, QString &reasonForFail);
|
||||
Download *infoRequestDownload(bool &success, QString &reasonForFail);
|
||||
QString typeName() const;
|
||||
|
||||
static void resetSession();
|
||||
|
|
|
@ -1,10 +1,104 @@
|
|||
#include "vimeodownload.h"
|
||||
#include "./vimeodownload.h"
|
||||
|
||||
#include <c++utilities/chrono/timespan.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
using namespace ChronoUtilities;
|
||||
|
||||
namespace Network {
|
||||
|
||||
VimeoDownload::VimeoDownload()
|
||||
{
|
||||
/*!
|
||||
* \class VimeoDownload
|
||||
* \brief Download implementation for Vimeo videos.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new VimeoDownload for the specified \a url.
|
||||
*/
|
||||
VimeoDownload::VimeoDownload(const QUrl &url, QObject *parent) :
|
||||
HttpDownloadWithInfoRequst(url, parent)
|
||||
{}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new VimeoDownload for the specified video \a id.
|
||||
*/
|
||||
VimeoDownload::VimeoDownload(const QString &id, QObject *parent) :
|
||||
HttpDownloadWithInfoRequst(QUrl(QStringLiteral("https://vimeo.com/%1").arg(id)), parent)
|
||||
{}
|
||||
|
||||
Download *VimeoDownload::infoRequestDownload(bool &success, QString &reasonForFail)
|
||||
{
|
||||
const auto pathParts = initialUrl().path(QUrl::FullyDecoded).splitRef(QChar('/'), QString::SkipEmptyParts);
|
||||
if(pathParts.size() < 2) {
|
||||
const auto &id = pathParts.back();
|
||||
bool isInt;
|
||||
id.toULongLong(&isInt);
|
||||
if(isInt) {
|
||||
setId(id.toString());
|
||||
success = true;
|
||||
return new HttpDownload(QUrl(QStringLiteral("https://player.vimeo.com/video/%1/config").arg(id.toString())));
|
||||
}
|
||||
}
|
||||
success = false;
|
||||
reasonForFail = tr("The video ID couldn't be identified.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QString VimeoDownload::suitableFilename() const
|
||||
{
|
||||
auto filename = Download::suitableFilename();
|
||||
if(!filename.endsWith(QLatin1String(".mp4"))) {
|
||||
filename.append(QStringLiteral(".mp4"));
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
QString VimeoDownload::typeName() const
|
||||
{
|
||||
return tr("Vimeo");
|
||||
}
|
||||
|
||||
void VimeoDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer)
|
||||
{
|
||||
QJsonParseError error;
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(videoInfoBuffer->readAll(), &error);
|
||||
if(error.error == QJsonParseError::NoError) {
|
||||
const auto h264Object = doc.object().value(QStringLiteral("request"))
|
||||
.toObject().value(QStringLiteral("files"))
|
||||
.toObject().value(QStringLiteral("h264")).toObject();
|
||||
const auto videoObject = doc.object().value(QStringLiteral("video")).toObject();
|
||||
const auto title = videoObject.value(QStringLiteral("title")).toString();
|
||||
if(!title.isEmpty()) {
|
||||
setTitle(title);
|
||||
}
|
||||
const auto uploader = videoObject.value(QStringLiteral("owner")).toObject().value(QStringLiteral("name")).toString();
|
||||
if(!uploader.isEmpty()) {
|
||||
setUploader(uploader);
|
||||
}
|
||||
if(const auto duration = videoObject.value(QStringLiteral("duration")).toInt()) {
|
||||
setDuration(TimeSpan::fromSeconds(duration));
|
||||
}
|
||||
for(const auto &value : h264Object) {
|
||||
const auto optionObject = value.toObject();
|
||||
const auto url = optionObject.value(QStringLiteral("url")).toString();
|
||||
if(!url.isEmpty()) {
|
||||
const auto width = optionObject.value(QStringLiteral("width")).toInt();
|
||||
const auto height = optionObject.value(QStringLiteral("height")).toInt();
|
||||
const auto bitrate = optionObject.value(QStringLiteral("bitrate")).toInt();
|
||||
addDownloadUrl(QStringLiteral("%1 x %2, %3 kbit/s").arg(width).arg(height).arg(bitrate), url);
|
||||
}
|
||||
}
|
||||
if(availableOptionCount() > 0) {
|
||||
reportInitiated(true);
|
||||
} else {
|
||||
reportInitiated(false, tr("No video URLs found. The video config could be parsed, but it seems like Vimeo changed something in their API."));
|
||||
}
|
||||
} else {
|
||||
reportInitiated(false, tr("Couldn't parse video configuration (invalid JSON)."));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Network
|
||||
|
|
|
@ -1,17 +1,25 @@
|
|||
#ifndef NETWORK_VIMEODOWNLOAD_H
|
||||
#define NETWORK_VIMEODOWNLOAD_H
|
||||
|
||||
#include "./httpdownloadwithinforequst.h"
|
||||
|
||||
namespace Network {
|
||||
|
||||
class VimeoDownload
|
||||
class VimeoDownload : public HttpDownloadWithInfoRequst
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VimeoDownload();
|
||||
explicit VimeoDownload(const QUrl &url, QObject *parent = nullptr);
|
||||
explicit VimeoDownload(const QString &id, QObject *parent = nullptr);
|
||||
|
||||
signals:
|
||||
Download *infoRequestDownload(bool &success, QString &reasonForFail);
|
||||
QString suitableFilename() const;
|
||||
QString typeName() const;
|
||||
|
||||
protected:
|
||||
void evalVideoInformation(Download *, QBuffer *videoInfoBuffer);
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
} // namespace Network
|
||||
|
|
|
@ -33,7 +33,7 @@ YoutubeDownload::YoutubeDownload(const QString &id, QObject *parent) :
|
|||
HttpDownloadWithInfoRequst(QUrl(QStringLiteral("http://www.youtube.com/watch?v=%1").arg(id)), parent)
|
||||
{}
|
||||
|
||||
Download *YoutubeDownload::infoRequestDownload(bool &sucess, QString &reasonForFail)
|
||||
Download *YoutubeDownload::infoRequestDownload(bool &success, QString &reasonForFail)
|
||||
{
|
||||
const QUrl &url = initialUrl();
|
||||
QString videoId;
|
||||
|
@ -44,12 +44,12 @@ Download *YoutubeDownload::infoRequestDownload(bool &sucess, QString &reasonForF
|
|||
videoId.remove(0, 1);
|
||||
}
|
||||
if(videoId.isEmpty()) {
|
||||
sucess = false;
|
||||
success = false;
|
||||
reasonForFail = tr("The video ID couldn't be identified.");
|
||||
return nullptr;
|
||||
} else {
|
||||
setId(videoId);
|
||||
sucess = true;
|
||||
success = true;
|
||||
return new HttpDownload(QUrl(QStringLiteral("http://www.youtube.com/get_video_info?video_id=%1&asv=3&el=detailpage&hl=en_US").arg(videoId)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
explicit YoutubeDownload(const QUrl &url, QObject *parent = nullptr);
|
||||
explicit YoutubeDownload(const QString &id, QObject *parent = nullptr);
|
||||
|
||||
Download *infoRequestDownload(bool &sucess, QString &reasonForFail);
|
||||
Download *infoRequestDownload(bool &success, QString &reasonForFail);
|
||||
QString videoInfo(QString field, const QString &defaultValue);
|
||||
QString suitableFilename() const;
|
||||
QString typeName() const;
|
||||
|
|
Loading…
Reference in New Issue