Refactor Tidal, Spotify, Qobuz, Subsonic and cover providers
Use common HTTP, Json and OAuthenticator class
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QPair>
|
||||
#include <QList>
|
||||
@@ -46,16 +45,44 @@
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
QobuzBaseRequest::QobuzBaseRequest(QobuzService *service, const SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent),
|
||||
: JsonBaseRequest(network, parent),
|
||||
service_(service),
|
||||
network_(network) {}
|
||||
|
||||
QobuzBaseRequest::~QobuzBaseRequest() = default;
|
||||
QString QobuzBaseRequest::service_name() const {
|
||||
|
||||
return service_->name();
|
||||
|
||||
}
|
||||
|
||||
bool QobuzBaseRequest::authentication_required() const {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool QobuzBaseRequest::authenticated() const {
|
||||
|
||||
return service_->authenticated();
|
||||
|
||||
}
|
||||
|
||||
bool QobuzBaseRequest::use_authorization_header() const {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
QByteArray QobuzBaseRequest::authorization_header() const {
|
||||
|
||||
return QByteArray();
|
||||
|
||||
}
|
||||
|
||||
QNetworkReply *QobuzBaseRequest::CreateRequest(const QString &ressource_name, const ParamList ¶ms_provided) {
|
||||
|
||||
ParamList params = ParamList() << params_provided
|
||||
<< Param(u"app_id"_s, app_id());
|
||||
<< Param(u"app_id"_s, service_->app_id());
|
||||
|
||||
std::sort(params.begin(), params.end());
|
||||
|
||||
@@ -64,15 +91,18 @@ QNetworkReply *QobuzBaseRequest::CreateRequest(const QString &ressource_name, co
|
||||
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
|
||||
}
|
||||
|
||||
QUrl url(QString::fromLatin1(QobuzService::kApiUrl) + QLatin1Char('/') + ressource_name);
|
||||
QUrl url(QString::fromLatin1(QobuzService::kApiUrl) + u'/' + ressource_name);
|
||||
url.setQuery(url_query);
|
||||
QNetworkRequest req(url);
|
||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
req.setHeader(QNetworkRequest::ContentTypeHeader, u"application/x-www-form-urlencoded"_s);
|
||||
req.setRawHeader("X-App-Id", app_id().toUtf8());
|
||||
if (authenticated()) req.setRawHeader("X-User-Auth-Token", user_auth_token().toUtf8());
|
||||
QNetworkRequest network_request(url);
|
||||
network_request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
network_request.setHeader(QNetworkRequest::ContentTypeHeader, u"application/x-www-form-urlencoded"_s);
|
||||
network_request.setRawHeader("X-App-Id", service_->app_id().toUtf8());
|
||||
if (authenticated()) {
|
||||
network_request.setRawHeader("X-User-Auth-Token", service_->user_auth_token().toUtf8());
|
||||
}
|
||||
|
||||
QNetworkReply *reply = network_->get(req);
|
||||
QNetworkReply *reply = network_->get(network_request);
|
||||
replies_ << reply;
|
||||
QObject::connect(reply, &QNetworkReply::sslErrors, this, &QobuzBaseRequest::HandleSSLErrors);
|
||||
|
||||
qLog(Debug) << "Qobuz: Sending request" << url;
|
||||
@@ -81,112 +111,56 @@ QNetworkReply *QobuzBaseRequest::CreateRequest(const QString &ressource_name, co
|
||||
|
||||
}
|
||||
|
||||
void QobuzBaseRequest::HandleSSLErrors(const QList<QSslError> &ssl_errors) {
|
||||
JsonBaseRequest::JsonObjectResult QobuzBaseRequest::ParseJsonObject(QNetworkReply *reply) {
|
||||
|
||||
for (const QSslError &ssl_error : ssl_errors) {
|
||||
Error(ssl_error.errorString());
|
||||
if (reply->error() != QNetworkReply::NoError && reply->error() < 200) {
|
||||
return ReplyDataResult(ErrorCode::NetworkError, QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QByteArray QobuzBaseRequest::GetReplyData(QNetworkReply *reply) {
|
||||
|
||||
QByteArray data;
|
||||
|
||||
if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200) {
|
||||
data = reply->readAll();
|
||||
JsonObjectResult result(ErrorCode::Success);
|
||||
result.network_error = reply->error();
|
||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).isValid()) {
|
||||
result.http_status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
}
|
||||
else {
|
||||
if (reply->error() != QNetworkReply::NoError && reply->error() < 200) {
|
||||
// This is a network error, there is nothing more to do.
|
||||
Error(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||
|
||||
const QByteArray data = reply->readAll();
|
||||
if (!data.isEmpty()) {
|
||||
QJsonParseError json_parse_error;
|
||||
const QJsonDocument json_document = QJsonDocument::fromJson(data, &json_parse_error);
|
||||
if (json_parse_error.error == QJsonParseError::NoError) {
|
||||
const QJsonObject json_object = json_document.object();
|
||||
if (json_object.contains("code"_L1) && json_object.contains("status"_L1) && json_object.contains("message"_L1)) {
|
||||
const int code = json_object["code"_L1].toInt();
|
||||
const QString message = json_object["message"_L1].toString();
|
||||
result.error_code = ErrorCode::APIError;
|
||||
result.error_message = QStringLiteral("%1 (%2)").arg(message).arg(code);
|
||||
}
|
||||
else {
|
||||
result.json_object = json_document.object();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// See if there is Json data containing "status", "code" and "message" - then use that instead.
|
||||
data = reply->readAll();
|
||||
QString error;
|
||||
QJsonParseError parse_error;
|
||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &parse_error);
|
||||
if (parse_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (!json_obj.isEmpty() && json_obj.contains("status"_L1) && json_obj.contains("code"_L1) && json_obj.contains("message"_L1)) {
|
||||
int code = json_obj["code"_L1].toInt();
|
||||
QString message = json_obj["message"_L1].toString();
|
||||
error = QStringLiteral("%1 (%2)").arg(message).arg(code);
|
||||
}
|
||||
}
|
||||
if (error.isEmpty()) {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
error = QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||
}
|
||||
else {
|
||||
error = QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
|
||||
}
|
||||
}
|
||||
Error(error);
|
||||
result.error_code = ErrorCode::ParseError;
|
||||
result.error_message = json_parse_error.errorString();
|
||||
}
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
QJsonObject QobuzBaseRequest::ExtractJsonObj(QByteArray &data) {
|
||||
|
||||
QJsonParseError json_error;
|
||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||
|
||||
if (json_error.error != QJsonParseError::NoError) {
|
||||
Error(u"Reply from server missing Json data."_s, data);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
if (json_doc.isEmpty()) {
|
||||
Error(u"Received empty Json document."_s, data);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
if (!json_doc.isObject()) {
|
||||
Error(u"Json document is not an object."_s, json_doc);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (json_obj.isEmpty()) {
|
||||
Error(u"Received empty Json object."_s, json_doc);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
return json_obj;
|
||||
|
||||
}
|
||||
|
||||
QJsonValue QobuzBaseRequest::ExtractItems(QByteArray &data) {
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) return QJsonValue();
|
||||
return ExtractItems(json_obj);
|
||||
|
||||
}
|
||||
|
||||
QJsonValue QobuzBaseRequest::ExtractItems(QJsonObject &json_obj) {
|
||||
|
||||
if (!json_obj.contains("items"_L1)) {
|
||||
Error(u"Json reply is missing items."_s, json_obj);
|
||||
return QJsonArray();
|
||||
}
|
||||
QJsonValue json_items = json_obj["items"_L1];
|
||||
return json_items;
|
||||
|
||||
}
|
||||
|
||||
QString QobuzBaseRequest::ErrorsToHTML(const QStringList &errors) {
|
||||
|
||||
QString error_html;
|
||||
for (const QString &error : errors) {
|
||||
error_html += error + u"<br />"_s;
|
||||
}
|
||||
return error_html;
|
||||
if (result.error_code != ErrorCode::APIError) {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
result.error_code = ErrorCode::NetworkError;
|
||||
result.error_message = QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||
}
|
||||
else if (result.http_status_code != 200) {
|
||||
result.error_code = ErrorCode::HttpError;
|
||||
result.error_message = QStringLiteral("Received HTTP code %1").arg(result.http_status_code);
|
||||
}
|
||||
}
|
||||
|
||||
if (reply->error() == QNetworkReply::AuthenticationRequiredError) {
|
||||
service_->ClearSession();
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,31 +22,21 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "qobuzservice.h"
|
||||
#include "core/jsonbaserequest.h"
|
||||
|
||||
class QNetworkReply;
|
||||
class NetworkAccessManager;
|
||||
class QobuzService;
|
||||
|
||||
class QobuzBaseRequest : public QObject {
|
||||
class QobuzBaseRequest : public JsonBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QobuzBaseRequest(QobuzService *service, const SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~QobuzBaseRequest();
|
||||
|
||||
enum class Type {
|
||||
None,
|
||||
@@ -60,41 +50,16 @@ class QobuzBaseRequest : public QObject {
|
||||
};
|
||||
|
||||
protected:
|
||||
using Param = QPair<QString, QString>;
|
||||
using ParamList = QList<Param>;
|
||||
QString service_name() const override;
|
||||
bool authentication_required() const override;
|
||||
bool authenticated() const override;
|
||||
bool use_authorization_header() const override;
|
||||
QByteArray authorization_header() const override;
|
||||
|
||||
QNetworkReply *CreateRequest(const QString &ressource_name, const ParamList ¶ms_provided);
|
||||
QByteArray GetReplyData(QNetworkReply *reply);
|
||||
QJsonObject ExtractJsonObj(QByteArray &data);
|
||||
QJsonValue ExtractItems(QByteArray &data);
|
||||
QJsonValue ExtractItems(QJsonObject &json_obj);
|
||||
JsonObjectResult ParseJsonObject(QNetworkReply *reply);
|
||||
|
||||
virtual void Error(const QString &error, const QVariant &debug = QVariant()) = 0;
|
||||
static QString ErrorsToHTML(const QStringList &errors);
|
||||
|
||||
QString app_id() const { return service_->app_id(); }
|
||||
QString app_secret() const { return service_->app_secret(); }
|
||||
QString username() const { return service_->username(); }
|
||||
QString password() const { return service_->password(); }
|
||||
int format() const { return service_->format(); }
|
||||
int artistssearchlimit() const { return service_->artistssearchlimit(); }
|
||||
int albumssearchlimit() const { return service_->albumssearchlimit(); }
|
||||
int songssearchlimit() const { return service_->songssearchlimit(); }
|
||||
|
||||
qint64 user_id() const { return service_->user_id(); }
|
||||
QString user_auth_token() const { return service_->user_auth_token(); }
|
||||
QString device_id() const { return service_->device_id(); }
|
||||
qint64 credential_id() const { return service_->credential_id(); }
|
||||
|
||||
bool authenticated() const { return service_->authenticated(); }
|
||||
bool login_sent() const { return service_->login_sent(); }
|
||||
int max_login_attempts() const { return service_->max_login_attempts(); }
|
||||
int login_attempts() const { return service_->login_attempts(); }
|
||||
|
||||
private Q_SLOTS:
|
||||
void HandleSSLErrors(const QList<QSslError> &ssl_errors);
|
||||
|
||||
private:
|
||||
protected:
|
||||
QobuzService *service_;
|
||||
const SharedPtr<NetworkAccessManager> network_;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
@@ -39,20 +37,7 @@
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
QobuzFavoriteRequest::QobuzFavoriteRequest(QobuzService *service, const SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QobuzBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
network_(network) {}
|
||||
|
||||
QobuzFavoriteRequest::~QobuzFavoriteRequest() {
|
||||
|
||||
while (!replies_.isEmpty()) {
|
||||
QNetworkReply *reply = replies_.takeFirst();
|
||||
QObject::disconnect(reply, nullptr, this, nullptr);
|
||||
reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
}
|
||||
: QobuzBaseRequest(service, network, parent) {}
|
||||
|
||||
QString QobuzFavoriteRequest::FavoriteText(const FavoriteType type) {
|
||||
|
||||
@@ -134,8 +119,8 @@ void QobuzFavoriteRequest::AddFavorites(const FavoriteType type, const SongList
|
||||
|
||||
void QobuzFavoriteRequest::AddFavoritesRequest(const FavoriteType type, const QStringList &ids_list, const SongList &songs) {
|
||||
|
||||
const ParamList params = ParamList() << Param(u"app_id"_s, app_id())
|
||||
<< Param(u"user_auth_token"_s, user_auth_token())
|
||||
const ParamList params = ParamList() << Param(u"app_id"_s, service_->app_id())
|
||||
<< Param(u"user_auth_token"_s, service_->user_auth_token())
|
||||
<< Param(FavoriteMethod(type), ids_list.join(u','));
|
||||
|
||||
QUrlQuery url_query;
|
||||
@@ -159,9 +144,9 @@ void QobuzFavoriteRequest::AddFavoritesReply(QNetworkReply *reply, const Favorit
|
||||
return;
|
||||
}
|
||||
|
||||
GetReplyData(reply);
|
||||
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
const JsonObjectResult json_object_result = ParseJsonObject(reply);
|
||||
if (!json_object_result.success()) {
|
||||
Error(json_object_result.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -229,8 +214,8 @@ void QobuzFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
|
||||
|
||||
void QobuzFavoriteRequest::RemoveFavoritesRequest(const FavoriteType type, const QStringList &ids_list, const SongList &songs) {
|
||||
|
||||
const ParamList params = ParamList() << Param(u"app_id"_s, app_id())
|
||||
<< Param(u"user_auth_token"_s, user_auth_token())
|
||||
const ParamList params = ParamList() << Param(u"app_id"_s, service_->app_id())
|
||||
<< Param(u"user_auth_token"_s, service_->user_auth_token())
|
||||
<< Param(FavoriteMethod(type), ids_list.join(u','));
|
||||
|
||||
QUrlQuery url_query;
|
||||
@@ -254,8 +239,9 @@ void QobuzFavoriteRequest::RemoveFavoritesReply(QNetworkReply *reply, const Favo
|
||||
return;
|
||||
}
|
||||
|
||||
GetReplyData(reply);
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
const JsonObjectResult json_object_result = ParseJsonObject(reply);
|
||||
if (!json_object_result.success()) {
|
||||
Error(json_object_result.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
@@ -34,13 +32,13 @@
|
||||
class QNetworkReply;
|
||||
class QobuzService;
|
||||
class NetworkAccessManager;
|
||||
class QobuzService;
|
||||
|
||||
class QobuzFavoriteRequest : public QobuzBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QobuzFavoriteRequest(QobuzService *service, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~QobuzFavoriteRequest();
|
||||
|
||||
private:
|
||||
enum class FavoriteType {
|
||||
@@ -79,10 +77,6 @@ class QobuzFavoriteRequest : public QobuzBaseRequest {
|
||||
void AddFavoritesRequest(const FavoriteType type, const QStringList &ids_list, const SongList &songs);
|
||||
void RemoveFavorites(const FavoriteType type, const SongList &songs);
|
||||
void RemoveFavoritesRequest(const FavoriteType type, const QStringList &ids_list, const SongList &songs);
|
||||
|
||||
QobuzService *service_;
|
||||
const SharedPtr<NetworkAccessManager> network_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
};
|
||||
|
||||
#endif // QOBUZFAVORITEREQUEST_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QByteArray>
|
||||
#include <QByteArrayList>
|
||||
@@ -35,6 +34,7 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
#include <QTimer>
|
||||
#include <QScopeGuard>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
@@ -62,9 +62,7 @@ constexpr int kFlushRequestsDelay = 200;
|
||||
|
||||
QobuzRequest::QobuzRequest(QobuzService *service, QobuzUrlHandler *url_handler, const SharedPtr<NetworkAccessManager> network, const Type query_type, QObject *parent)
|
||||
: QobuzBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
url_handler_(url_handler),
|
||||
network_(network),
|
||||
timer_flush_requests_(new QTimer(this)),
|
||||
query_type_(query_type),
|
||||
query_id_(-1),
|
||||
@@ -105,24 +103,6 @@ QobuzRequest::QobuzRequest(QobuzService *service, QobuzUrlHandler *url_handler,
|
||||
|
||||
}
|
||||
|
||||
QobuzRequest::~QobuzRequest() {
|
||||
|
||||
while (!replies_.isEmpty()) {
|
||||
QNetworkReply *reply = replies_.takeFirst();
|
||||
QObject::disconnect(reply, nullptr, this, nullptr);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
while (!album_cover_replies_.isEmpty()) {
|
||||
QNetworkReply *reply = album_cover_replies_.takeFirst();
|
||||
QObject::disconnect(reply, nullptr, this, nullptr);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QobuzRequest::Process() {
|
||||
|
||||
switch (query_type_) {
|
||||
@@ -225,12 +205,12 @@ void QobuzRequest::FlushArtistsRequests() {
|
||||
|
||||
while (!artists_requests_queue_.isEmpty() && artists_requests_active_ < kMaxConcurrentArtistsRequests) {
|
||||
|
||||
Request request = artists_requests_queue_.dequeue();
|
||||
const Request request = artists_requests_queue_.dequeue();
|
||||
|
||||
ParamList params;
|
||||
if (query_type_ == Type::FavouriteArtists) {
|
||||
params << Param(u"type"_s, u"artists"_s);
|
||||
params << Param(u"user_auth_token"_s, user_auth_token());
|
||||
params << Param(u"user_auth_token"_s, service_->user_auth_token());
|
||||
}
|
||||
else if (query_type_ == Type::SearchArtists) params << Param(u"query"_s, search_text_);
|
||||
if (request.limit > 0) params << Param(u"limit"_s, QString::number(request.limit));
|
||||
@@ -277,12 +257,12 @@ void QobuzRequest::FlushAlbumsRequests() {
|
||||
|
||||
while (!albums_requests_queue_.isEmpty() && albums_requests_active_ < kMaxConcurrentAlbumsRequests) {
|
||||
|
||||
Request request = albums_requests_queue_.dequeue();
|
||||
const Request request = albums_requests_queue_.dequeue();
|
||||
|
||||
ParamList params;
|
||||
if (query_type_ == Type::FavouriteAlbums) {
|
||||
params << Param(u"type"_s, u"albums"_s);
|
||||
params << Param(u"user_auth_token"_s, user_auth_token());
|
||||
params << Param(u"user_auth_token"_s, service_->user_auth_token());
|
||||
}
|
||||
else if (query_type_ == Type::SearchAlbums) params << Param(u"query"_s, search_text_);
|
||||
if (request.limit > 0) params << Param(u"limit"_s, QString::number(request.limit));
|
||||
@@ -329,12 +309,12 @@ void QobuzRequest::FlushSongsRequests() {
|
||||
|
||||
while (!songs_requests_queue_.isEmpty() && songs_requests_active_ < kMaxConcurrentSongsRequests) {
|
||||
|
||||
Request request = songs_requests_queue_.dequeue();
|
||||
const Request request = songs_requests_queue_.dequeue();
|
||||
|
||||
ParamList params;
|
||||
if (query_type_ == Type::FavouriteSongs) {
|
||||
params << Param(u"type"_s, u"tracks"_s);
|
||||
params << Param(u"user_auth_token"_s, user_auth_token());
|
||||
params << Param(u"user_auth_token"_s, service_->user_auth_token());
|
||||
}
|
||||
else if (query_type_ == Type::SearchSongs) params << Param(u"query"_s, search_text_);
|
||||
if (request.limit > 0) params << Param(u"limit"_s, QString::number(request.limit));
|
||||
@@ -405,61 +385,59 @@ void QobuzRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
|
||||
QObject::disconnect(reply, nullptr, this, nullptr);
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = GetReplyData(reply);
|
||||
const JsonObjectResult json_object_result = ParseJsonObject(reply);
|
||||
|
||||
--artists_requests_active_;
|
||||
++artists_requests_received_;
|
||||
|
||||
if (finished_) return;
|
||||
|
||||
if (data.isEmpty()) {
|
||||
ArtistsFinishCheck();
|
||||
int offset = 0;
|
||||
int artists_received = 0;
|
||||
const QScopeGuard finish_check = qScopeGuard([this, limit_requested, &offset, &artists_received]() { ArtistsFinishCheck(limit_requested, offset, artists_received); });
|
||||
|
||||
if (!json_object_result.success()) {
|
||||
Error(json_object_result.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) {
|
||||
ArtistsFinishCheck();
|
||||
const QJsonObject &json_object = json_object_result.json_object;
|
||||
if (json_object.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("artists"_L1)) {
|
||||
ArtistsFinishCheck();
|
||||
Error(u"Json object is missing artists."_s, json_obj);
|
||||
if (!json_object.contains("artists"_L1)) {
|
||||
Error(u"Json object is missing artists."_s, json_object);
|
||||
return;
|
||||
}
|
||||
QJsonValue value_artists = json_obj["artists"_L1];
|
||||
const QJsonValue value_artists = json_object["artists"_L1];
|
||||
if (!value_artists.isObject()) {
|
||||
Error(u"Json artists is not an object."_s, json_obj);
|
||||
ArtistsFinishCheck();
|
||||
Error(u"Json artists is not an object."_s, json_object);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_artists = value_artists.toObject();
|
||||
const QJsonObject object_artists = value_artists.toObject();
|
||||
|
||||
if (!obj_artists.contains("limit"_L1) ||
|
||||
!obj_artists.contains("offset"_L1) ||
|
||||
!obj_artists.contains("total"_L1) ||
|
||||
!obj_artists.contains("items"_L1)) {
|
||||
ArtistsFinishCheck();
|
||||
Error(u"Json artists object is missing values."_s, json_obj);
|
||||
if (!object_artists.contains("limit"_L1) ||
|
||||
!object_artists.contains("offset"_L1) ||
|
||||
!object_artists.contains("total"_L1) ||
|
||||
!object_artists.contains("items"_L1)) {
|
||||
Error(u"Json artists object is missing values."_s, json_object);
|
||||
return;
|
||||
}
|
||||
//int limit = obj_artists["limit"].toInt();
|
||||
int offset = obj_artists["offset"_L1].toInt();
|
||||
int artists_total = obj_artists["total"_L1].toInt();
|
||||
offset = object_artists["offset"_L1].toInt();
|
||||
int artists_total = object_artists["total"_L1].toInt();
|
||||
|
||||
if (offset_requested == 0) {
|
||||
artists_total_ = artists_total;
|
||||
}
|
||||
else if (artists_total != artists_total_) {
|
||||
Error(QStringLiteral("total returned does not match previous total! %1 != %2").arg(artists_total).arg(artists_total_));
|
||||
ArtistsFinishCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset != offset_requested) {
|
||||
Error(QStringLiteral("Offset returned does not match offset requested! %1 != %2").arg(offset).arg(offset_requested));
|
||||
ArtistsFinishCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -467,20 +445,18 @@ void QobuzRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
|
||||
Q_EMIT UpdateProgress(query_id_, GetProgress(artists_received_, artists_total_));
|
||||
}
|
||||
|
||||
QJsonValue value_items = ExtractItems(obj_artists);
|
||||
if (!value_items.isArray()) {
|
||||
ArtistsFinishCheck();
|
||||
const JsonArrayResult json_array_result = GetJsonArray(object_artists, u"items"_s);
|
||||
if (!json_array_result.success()) {
|
||||
Error(json_array_result.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
const QJsonArray array_items = value_items.toArray();
|
||||
const QJsonArray &array_items = json_array_result.json_array;
|
||||
if (array_items.isEmpty()) { // Empty array means no results
|
||||
if (offset_requested == 0) no_results_ = true;
|
||||
ArtistsFinishCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
int artists_received = 0;
|
||||
for (const QJsonValue &value_item : array_items) {
|
||||
|
||||
++artists_received;
|
||||
@@ -525,8 +501,6 @@ void QobuzRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
|
||||
|
||||
if (offset_requested != 0) Q_EMIT UpdateProgress(query_id_, GetProgress(artists_received_, artists_total_));
|
||||
|
||||
ArtistsFinishCheck(limit_requested, offset, artists_received);
|
||||
|
||||
}
|
||||
|
||||
void QobuzRequest::ArtistsFinishCheck(const int limit, const int offset, const int artists_received) {
|
||||
@@ -619,86 +593,84 @@ void QobuzRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
|
||||
QObject::disconnect(reply, nullptr, this, nullptr);
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = GetReplyData(reply);
|
||||
const JsonObjectResult json_object_result = ParseJsonObject(reply);
|
||||
|
||||
if (finished_) return;
|
||||
|
||||
if (data.isEmpty()) {
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
int offset = 0;
|
||||
int albums_total = 0;
|
||||
int albums_received = 0;
|
||||
const QScopeGuard finish_check = qScopeGuard([this, artist_requested, limit_requested, &offset, &albums_total, &albums_received]() { AlbumsFinishCheck(artist_requested, limit_requested, offset, albums_total, albums_received); });
|
||||
|
||||
if (!json_object_result.success()) {
|
||||
Error(json_object_result.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) {
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
const QJsonObject &json_object = json_object_result.json_object;
|
||||
if (json_object.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Artist artist = artist_requested;
|
||||
|
||||
if (json_obj.contains("id"_L1) && json_obj.contains("name"_L1)) {
|
||||
if (json_obj["id"_L1].isString()) {
|
||||
artist.artist_id = json_obj["id"_L1].toString();
|
||||
if (json_object.contains("id"_L1) && json_object.contains("name"_L1)) {
|
||||
if (json_object["id"_L1].isString()) {
|
||||
artist.artist_id = json_object["id"_L1].toString();
|
||||
}
|
||||
else {
|
||||
artist.artist_id = QString::number(json_obj["id"_L1].toInt());
|
||||
artist.artist_id = QString::number(json_object["id"_L1].toInt());
|
||||
}
|
||||
artist.artist = json_obj["name"_L1].toString();
|
||||
artist.artist = json_object["name"_L1].toString();
|
||||
}
|
||||
|
||||
if (artist.artist_id != artist_requested.artist_id) {
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
Error(u"Artist ID returned does not match artist ID requested."_s, json_obj);
|
||||
Error(u"Artist ID returned does not match artist ID requested."_s, json_object);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("albums"_L1)) {
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
Error(u"Json object is missing albums."_s, json_obj);
|
||||
if (!json_object.contains("albums"_L1)) {
|
||||
Error(u"Json object is missing albums."_s, json_object);
|
||||
return;
|
||||
}
|
||||
QJsonValue value_albums = json_obj["albums"_L1];
|
||||
const QJsonValue value_albums = json_object["albums"_L1];
|
||||
if (!value_albums.isObject()) {
|
||||
Error(u"Json albums is not an object."_s, json_obj);
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
Error(u"Json albums is not an object."_s, json_object);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_albums = value_albums.toObject();
|
||||
const QJsonObject object_albums = value_albums.toObject();
|
||||
|
||||
if (!obj_albums.contains("limit"_L1) ||
|
||||
!obj_albums.contains("offset"_L1) ||
|
||||
!obj_albums.contains("total"_L1) ||
|
||||
!obj_albums.contains("items"_L1)) {
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
Error(u"Json albums object is missing values."_s, json_obj);
|
||||
if (!object_albums.contains("limit"_L1) ||
|
||||
!object_albums.contains("offset"_L1) ||
|
||||
!object_albums.contains("total"_L1) ||
|
||||
!object_albums.contains("items"_L1)) {
|
||||
Error(u"Json albums object is missing values."_s, json_object);
|
||||
return;
|
||||
}
|
||||
|
||||
//int limit = obj_albums["limit"].toInt();
|
||||
int offset = obj_albums["offset"_L1].toInt();
|
||||
int albums_total = obj_albums["total"_L1].toInt();
|
||||
offset = object_albums["offset"_L1].toInt();
|
||||
albums_total = object_albums["total"_L1].toInt();
|
||||
|
||||
if (offset != offset_requested) {
|
||||
Error(QStringLiteral("Offset returned does not match offset requested! %1 != %2").arg(offset).arg(offset_requested));
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonValue value_items = ExtractItems(obj_albums);
|
||||
if (!value_items.isArray()) {
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
const JsonArrayResult json_array_result = GetJsonArray(object_albums, u"items"_s);
|
||||
if (!json_array_result.success()) {
|
||||
Error(json_array_result.error_message);
|
||||
return;
|
||||
}
|
||||
const QJsonArray array_items = value_items.toArray();
|
||||
|
||||
const QJsonArray &array_items = json_array_result.json_array;
|
||||
if (array_items.isEmpty()) {
|
||||
if ((query_type_ == Type::FavouriteAlbums || query_type_ == Type::SearchAlbums) && offset_requested == 0) {
|
||||
no_results_ = true;
|
||||
}
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
return;
|
||||
}
|
||||
|
||||
int albums_received = 0;
|
||||
for (const QJsonValue &value_item : array_items) {
|
||||
|
||||
++albums_received;
|
||||
@@ -762,8 +734,6 @@ void QobuzRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
|
||||
Q_EMIT UpdateProgress(query_id_, GetProgress(albums_received_, albums_total_));
|
||||
}
|
||||
|
||||
AlbumsFinishCheck(artist_requested, limit_requested, offset, albums_total, albums_received);
|
||||
|
||||
}
|
||||
|
||||
void QobuzRequest::AlbumsFinishCheck(const Artist &artist, const int limit, const int offset, const int albums_total, const int albums_received) {
|
||||
@@ -845,7 +815,7 @@ void QobuzRequest::FlushAlbumSongsRequests() {
|
||||
|
||||
while (!album_songs_requests_queue_.isEmpty() && album_songs_requests_active_ < kMaxConcurrentAlbumSongsRequests) {
|
||||
|
||||
AlbumSongsRequest request = album_songs_requests_queue_.dequeue();
|
||||
const AlbumSongsRequest request = album_songs_requests_queue_.dequeue();
|
||||
ParamList params = ParamList() << Param(u"album_id"_s, request.album.album_id);
|
||||
if (request.offset > 0) params << Param(u"offset"_s, QString::number(request.offset));
|
||||
QNetworkReply *reply = CreateRequest(u"album/get"_s, params);
|
||||
@@ -876,51 +846,53 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
|
||||
QObject::disconnect(reply, nullptr, this, nullptr);
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = GetReplyData(reply);
|
||||
const JsonObjectResult json_object_result = ParseJsonObject(reply);
|
||||
|
||||
if (finished_) return;
|
||||
|
||||
if (data.isEmpty()) {
|
||||
SongsFinishCheck(artist_requested, album_requested, limit_requested, offset_requested);
|
||||
Artist album_artist;
|
||||
Album album;
|
||||
int songs_total = 0;
|
||||
int songs_received = 0;
|
||||
const QScopeGuard finish_check = qScopeGuard([this, &album_artist, &album, limit_requested, offset_requested, &songs_total, &songs_received]() { SongsFinishCheck(album_artist, album, limit_requested, offset_requested, songs_total, songs_received); });
|
||||
|
||||
if (!json_object_result.success()) {
|
||||
Error(json_object_result.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) {
|
||||
SongsFinishCheck(artist_requested, album_requested, limit_requested, offset_requested);
|
||||
const QJsonObject &json_object = json_object_result.json_object;
|
||||
if (json_object.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("tracks"_L1)) {
|
||||
Error(u"Json object is missing tracks."_s, json_obj);
|
||||
SongsFinishCheck(artist_requested, album_requested, limit_requested, offset_requested);
|
||||
if (!json_object.contains("tracks"_L1)) {
|
||||
Error(u"Json object is missing tracks."_s, json_object);
|
||||
return;
|
||||
}
|
||||
|
||||
Artist album_artist = artist_requested;
|
||||
Album album = album_requested;
|
||||
album_artist = artist_requested;
|
||||
album = album_requested;
|
||||
|
||||
if (json_obj.contains("id"_L1) && json_obj.contains("title"_L1)) {
|
||||
if (json_obj["id"_L1].isString()) {
|
||||
album.album_id = json_obj["id"_L1].toString();
|
||||
if (json_object.contains("id"_L1) && json_object.contains("title"_L1)) {
|
||||
if (json_object["id"_L1].isString()) {
|
||||
album.album_id = json_object["id"_L1].toString();
|
||||
}
|
||||
else {
|
||||
album.album_id = QString::number(json_obj["id"_L1].toInt());
|
||||
album.album_id = QString::number(json_object["id"_L1].toInt());
|
||||
}
|
||||
album.album = json_obj["title"_L1].toString();
|
||||
album.album = json_object["title"_L1].toString();
|
||||
}
|
||||
|
||||
if (json_obj.contains("artist"_L1)) {
|
||||
QJsonValue value_artist = json_obj["artist"_L1];
|
||||
if (json_object.contains("artist"_L1)) {
|
||||
QJsonValue value_artist = json_object["artist"_L1];
|
||||
if (!value_artist.isObject()) {
|
||||
Error(u"Invalid Json reply, album artist is not a object."_s, value_artist);
|
||||
SongsFinishCheck(artist_requested, album_requested, limit_requested, offset_requested);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_artist = value_artist.toObject();
|
||||
if (!obj_artist.contains("id"_L1) || !obj_artist.contains("name"_L1)) {
|
||||
Error(u"Invalid Json reply, album artist is missing id or name."_s, obj_artist);
|
||||
SongsFinishCheck(artist_requested, album_requested, limit_requested, offset_requested);
|
||||
return;
|
||||
}
|
||||
if (obj_artist["id"_L1].isString()) {
|
||||
@@ -932,17 +904,15 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
|
||||
album_artist.artist = obj_artist["name"_L1].toString();
|
||||
}
|
||||
|
||||
if (json_obj.contains("image"_L1)) {
|
||||
QJsonValue value_image = json_obj["image"_L1];
|
||||
if (json_object.contains("image"_L1)) {
|
||||
QJsonValue value_image = json_object["image"_L1];
|
||||
if (!value_image.isObject()) {
|
||||
Error(u"Invalid Json reply, album image is not a object."_s, value_image);
|
||||
SongsFinishCheck(artist_requested, album_requested, limit_requested, offset_requested);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_image = value_image.toObject();
|
||||
if (!obj_image.contains("large"_L1)) {
|
||||
Error(u"Invalid Json reply, album image is missing large."_s, obj_image);
|
||||
SongsFinishCheck(artist_requested, album_requested, limit_requested, offset_requested);
|
||||
return;
|
||||
}
|
||||
QString album_image = obj_image["large"_L1].toString();
|
||||
@@ -951,10 +921,9 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
|
||||
}
|
||||
}
|
||||
|
||||
QJsonValue value_tracks = json_obj["tracks"_L1];
|
||||
QJsonValue value_tracks = json_object["tracks"_L1];
|
||||
if (!value_tracks.isObject()) {
|
||||
Error(u"Json tracks is not an object."_s, json_obj);
|
||||
SongsFinishCheck(artist_requested, album_requested, limit_requested, offset_requested);
|
||||
Error(u"Json tracks is not an object."_s, json_object);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_tracks = value_tracks.toObject();
|
||||
@@ -963,51 +932,47 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
|
||||
!obj_tracks.contains("offset"_L1) ||
|
||||
!obj_tracks.contains("total"_L1) ||
|
||||
!obj_tracks.contains("items"_L1)) {
|
||||
SongsFinishCheck(artist_requested, album_requested, limit_requested, offset_requested);
|
||||
Error(u"Json songs object is missing values."_s, json_obj);
|
||||
Error(u"Json songs object is missing values."_s, json_object);
|
||||
return;
|
||||
}
|
||||
|
||||
//int limit = obj_tracks["limit"].toInt();
|
||||
int offset = obj_tracks["offset"_L1].toInt();
|
||||
int songs_total = obj_tracks["total"_L1].toInt();
|
||||
const int offset = obj_tracks["offset"_L1].toInt();
|
||||
songs_total = obj_tracks["total"_L1].toInt();
|
||||
|
||||
if (offset != offset_requested) {
|
||||
Error(QStringLiteral("Offset returned does not match offset requested! %1 != %2").arg(offset).arg(offset_requested));
|
||||
SongsFinishCheck(album_artist, album, limit_requested, offset_requested, songs_total);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonValue value_items = ExtractItems(obj_tracks);
|
||||
if (!value_items.isArray()) {
|
||||
SongsFinishCheck(album_artist, album, limit_requested, offset_requested, songs_total);
|
||||
const JsonArrayResult json_array_result = GetJsonArray(obj_tracks, u"items"_s);
|
||||
if (!json_array_result.success()) {
|
||||
Error(json_array_result.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
const QJsonArray array_items = value_items.toArray();
|
||||
const QJsonArray &array_items = json_array_result.json_array;
|
||||
if (array_items.isEmpty()) {
|
||||
if ((query_type_ == Type::FavouriteSongs || query_type_ == Type::SearchSongs) && offset_requested == 0) {
|
||||
no_results_ = true;
|
||||
}
|
||||
SongsFinishCheck(album_artist, album, limit_requested, offset_requested, songs_total);
|
||||
return;
|
||||
}
|
||||
|
||||
bool compilation = false;
|
||||
bool multidisc = false;
|
||||
SongList songs;
|
||||
int songs_received = 0;
|
||||
for (const QJsonValue &value_item : array_items) {
|
||||
|
||||
if (!value_item.isObject()) {
|
||||
Error(u"Invalid Json reply, track is not a object."_s);
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_item = value_item.toObject();
|
||||
const QJsonObject object_item = value_item.toObject();
|
||||
|
||||
++songs_received;
|
||||
Song song(Song::Source::Qobuz);
|
||||
ParseSong(song, obj_item, album_artist, album);
|
||||
ParseSong(song, object_item, album_artist, album);
|
||||
if (!song.is_valid()) continue;
|
||||
if (song.disc() >= 2) multidisc = true;
|
||||
if (song.is_compilation()) compilation = true;
|
||||
@@ -1025,8 +990,6 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
|
||||
Q_EMIT UpdateProgress(query_id_, GetProgress(songs_received_, songs_total_));
|
||||
}
|
||||
|
||||
SongsFinishCheck(album_artist, album, limit_requested, offset_requested, songs_total, songs_received);
|
||||
|
||||
}
|
||||
|
||||
void QobuzRequest::SongsFinishCheck(const Artist &artist, const Album &album, const int limit, const int offset, const int songs_total, const int songs_received) {
|
||||
@@ -1291,25 +1254,18 @@ void QobuzRequest::AddAlbumCoverRequest(const Song &song) {
|
||||
void QobuzRequest::FlushAlbumCoverRequests() {
|
||||
|
||||
while (!album_cover_requests_queue_.isEmpty() && album_covers_requests_active_ < kMaxConcurrentAlbumCoverRequests) {
|
||||
|
||||
AlbumCoverRequest request = album_cover_requests_queue_.dequeue();
|
||||
|
||||
QNetworkRequest req(request.url);
|
||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
QNetworkReply *reply = network_->get(req);
|
||||
album_cover_replies_ << reply;
|
||||
const AlbumCoverRequest request = album_cover_requests_queue_.dequeue();
|
||||
QNetworkReply *reply = CreateGetRequest(request.url);
|
||||
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, request]() { AlbumCoverReceived(reply, request.url, request.filename); });
|
||||
|
||||
++album_covers_requests_active_;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_url, const QString &filename) {
|
||||
|
||||
if (album_cover_replies_.contains(reply)) {
|
||||
album_cover_replies_.removeAll(reply);
|
||||
if (replies_.contains(reply)) {
|
||||
replies_.removeAll(reply);
|
||||
QObject::disconnect(reply, nullptr, this, nullptr);
|
||||
reply->deleteLater();
|
||||
}
|
||||
@@ -1323,24 +1279,23 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur
|
||||
|
||||
if (finished_) return;
|
||||
|
||||
const QScopeGuard finish_check = qScopeGuard([this]() { AlbumCoverFinishCheck(); });
|
||||
|
||||
Q_EMIT UpdateProgress(query_id_, GetProgress(album_covers_requests_received_, album_covers_requests_total_));
|
||||
|
||||
if (!album_covers_requests_sent_.contains(cover_url)) {
|
||||
AlbumCoverFinishCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
Error(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||
if (album_covers_requests_sent_.contains(cover_url)) album_covers_requests_sent_.remove(cover_url);
|
||||
AlbumCoverFinishCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
|
||||
Error(QStringLiteral("Received HTTP code %1 for %2.").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()).arg(cover_url.toString()));
|
||||
if (album_covers_requests_sent_.contains(cover_url)) album_covers_requests_sent_.remove(cover_url);
|
||||
AlbumCoverFinishCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1351,7 +1306,6 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur
|
||||
if (!ImageUtils::SupportedImageMimeTypes().contains(mimetype, Qt::CaseInsensitive) && !ImageUtils::SupportedImageFormats().contains(mimetype, Qt::CaseInsensitive)) {
|
||||
Error(QStringLiteral("Unsupported mimetype for image reader %1 for %2").arg(mimetype, cover_url.toString()));
|
||||
if (album_covers_requests_sent_.contains(cover_url)) album_covers_requests_sent_.remove(cover_url);
|
||||
AlbumCoverFinishCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1359,7 +1313,6 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur
|
||||
if (data.isEmpty()) {
|
||||
Error(QStringLiteral("Received empty image data for %1").arg(cover_url.toString()));
|
||||
if (album_covers_requests_sent_.contains(cover_url)) album_covers_requests_sent_.remove(cover_url);
|
||||
AlbumCoverFinishCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1389,8 +1342,6 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur
|
||||
Error(QStringLiteral("Error decoding image data from %1").arg(cover_url.toString()));
|
||||
}
|
||||
|
||||
AlbumCoverFinishCheck();
|
||||
|
||||
}
|
||||
|
||||
void QobuzRequest::AlbumCoverFinishCheck() {
|
||||
@@ -1424,16 +1375,20 @@ void QobuzRequest::FinishCheck() {
|
||||
}
|
||||
finished_ = true;
|
||||
if (no_results_ && songs_.isEmpty()) {
|
||||
if (IsSearch())
|
||||
if (IsSearch()) {
|
||||
Q_EMIT Results(query_id_, SongMap(), tr("No match."));
|
||||
else
|
||||
}
|
||||
else {
|
||||
Q_EMIT Results(query_id_, SongMap(), QString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (songs_.isEmpty() && errors_.isEmpty())
|
||||
if (songs_.isEmpty() && error_.isEmpty()) {
|
||||
Q_EMIT Results(query_id_, songs_, tr("Unknown error"));
|
||||
else
|
||||
Q_EMIT Results(query_id_, songs_, ErrorsToHTML(errors_));
|
||||
}
|
||||
else {
|
||||
Q_EMIT Results(query_id_, songs_, error_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1445,20 +1400,22 @@ int QobuzRequest::GetProgress(const int count, const int total) {
|
||||
|
||||
}
|
||||
|
||||
void QobuzRequest::Error(const QString &error, const QVariant &debug) {
|
||||
void QobuzRequest::Error(const QString &error_message, const QVariant &debug_output) {
|
||||
|
||||
if (!error.isEmpty()) {
|
||||
errors_ << error;
|
||||
qLog(Error) << "Qobuz:" << error;
|
||||
qLog(Error) << "Qobuz:" << error_message;
|
||||
if (debug_output.isValid()) {
|
||||
qLog(Debug) << debug_output;
|
||||
}
|
||||
if (debug.isValid()) qLog(Debug) << debug;
|
||||
FinishCheck();
|
||||
|
||||
error_ = QStringLiteral("Qobuz: %1").arg(error_message);
|
||||
|
||||
}
|
||||
|
||||
void QobuzRequest::Warn(const QString &error, const QVariant &debug) {
|
||||
void QobuzRequest::Warn(const QString &error_message, const QVariant &debug_output) {
|
||||
|
||||
qLog(Error) << "Qobuz:" << error;
|
||||
if (debug.isValid()) qLog(Debug) << debug;
|
||||
qLog(Error) << "Qobuz:" << error_message;
|
||||
if (debug_output.isValid()) {
|
||||
qLog(Debug) << debug_output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,11 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QMultiMap>
|
||||
@@ -36,6 +31,7 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
#include <QJsonObject>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
@@ -51,9 +47,7 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit QobuzRequest(QobuzService *service, QobuzUrlHandler *url_handler, const SharedPtr<NetworkAccessManager> network, const Type query_type, QObject *parent = nullptr);
|
||||
~QobuzRequest() override;
|
||||
|
||||
void ReloadSettings();
|
||||
|
||||
@@ -98,8 +92,6 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
};
|
||||
|
||||
Q_SIGNALS:
|
||||
void LoginSuccess();
|
||||
void LoginFailure(const QString &failure_reason);
|
||||
void Results(const int id, const SongMap &songs, const QString &error);
|
||||
void UpdateStatus(const int id, const QString &text);
|
||||
void UpdateProgress(const int id, const int max);
|
||||
@@ -119,7 +111,6 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
void AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_url, const QString &filename);
|
||||
|
||||
private:
|
||||
|
||||
bool IsQuery() const { return (query_type_ == Type::FavouriteArtists || query_type_ == Type::FavouriteAlbums || query_type_ == Type::FavouriteSongs); }
|
||||
bool IsSearch() const { return (query_type_ == Type::SearchArtists || query_type_ == Type::SearchAlbums || query_type_ == Type::SearchSongs); }
|
||||
|
||||
@@ -144,9 +135,9 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
void AddSongsSearchRequest(const int offset = 0);
|
||||
void FlushSongsRequests();
|
||||
|
||||
void ArtistsFinishCheck(const int limit = 0, const int offset = 0, const int artists_received = 0);
|
||||
void AlbumsFinishCheck(const Artist &artist, const int limit = 0, const int offset = 0, const int albums_total = 0, const int albums_received = 0);
|
||||
void SongsFinishCheck(const Artist &artist, const Album &album, const int limit = 0, const int offset = 0, const int songs_total = 0, const int songs_received = 0);
|
||||
void ArtistsFinishCheck(const int limit, const int offset, const int artists_received);
|
||||
void AlbumsFinishCheck(const Artist &artist, const int limit, const int offset, const int albums_total, const int albums_received);
|
||||
void SongsFinishCheck(const Artist &artist, const Album &album, const int limit, const int offset, const int songs_total, const int songs_received);
|
||||
|
||||
void AddArtistAlbumsRequest(const Artist &artist, const int offset = 0);
|
||||
void FlushArtistAlbumsRequests();
|
||||
@@ -167,12 +158,10 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
int GetProgress(const int count, const int total);
|
||||
|
||||
void FinishCheck();
|
||||
static void Warn(const QString &error, const QVariant &debug = QVariant());
|
||||
void Error(const QString &error, const QVariant &debug = QVariant()) override;
|
||||
static void Warn(const QString &error_message, const QVariant &debug_output = QVariant());
|
||||
void Error(const QString &error_message, const QVariant &debug_output = QVariant());
|
||||
|
||||
QobuzService *service_;
|
||||
QobuzUrlHandler *url_handler_;
|
||||
const SharedPtr<NetworkAccessManager> network_;
|
||||
QTimer *timer_flush_requests_;
|
||||
|
||||
const Type query_type_;
|
||||
@@ -228,10 +217,10 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
int album_covers_requests_received_;
|
||||
|
||||
SongMap songs_;
|
||||
QStringList errors_;
|
||||
bool no_results_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
QList<QNetworkReply*> album_cover_replies_;
|
||||
QString error_;
|
||||
};
|
||||
|
||||
using QobuzRequestPtr = QScopedPointer<QobuzRequest, QScopedPointerDeleteLater>;
|
||||
|
||||
#endif // QOBUZREQUEST_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,10 +19,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QPair>
|
||||
#include <QList>
|
||||
@@ -37,6 +35,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QSettings>
|
||||
#include <QSslError>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
@@ -173,7 +172,7 @@ QobuzService::~QobuzService() {
|
||||
}
|
||||
|
||||
while (!stream_url_requests_.isEmpty()) {
|
||||
SharedPtr<QobuzStreamURLRequest> stream_url_req = stream_url_requests_.take(stream_url_requests_.firstKey());
|
||||
QSharedPointer<QobuzStreamURLRequest> stream_url_req = stream_url_requests_.take(stream_url_requests_.firstKey());
|
||||
QObject::disconnect(&*stream_url_req, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
@@ -218,7 +217,7 @@ void QobuzService::ReloadSettings() {
|
||||
const bool base64_secret = s.value(QobuzSettings::kBase64Secret, false).toBool();;
|
||||
|
||||
username_ = s.value(QobuzSettings::kUsername).toString();
|
||||
QByteArray password = s.value(QobuzSettings::kPassword).toByteArray();
|
||||
const QByteArray password = s.value(QobuzSettings::kPassword).toByteArray();
|
||||
if (password.isEmpty()) password_.clear();
|
||||
else password_ = QString::fromUtf8(QByteArray::fromBase64(password));
|
||||
|
||||
@@ -267,7 +266,6 @@ void QobuzService::SendLogin() {
|
||||
void QobuzService::SendLoginWithCredentials(const QString &app_id, const QString &username, const QString &password) {
|
||||
|
||||
Q_EMIT UpdateStatus(tr("Authenticating..."));
|
||||
login_errors_.clear();
|
||||
|
||||
login_sent_ = true;
|
||||
++login_attempts_;
|
||||
@@ -285,14 +283,13 @@ void QobuzService::SendLoginWithCredentials(const QString &app_id, const QString
|
||||
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
|
||||
}
|
||||
|
||||
QUrl url(QString::fromLatin1(kAuthUrl));
|
||||
QNetworkRequest req(url);
|
||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
const QUrl url(QString::fromLatin1(kAuthUrl));
|
||||
QNetworkRequest network_request(url);
|
||||
network_request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
network_request.setHeader(QNetworkRequest::ContentTypeHeader, u"application/x-www-form-urlencoded"_s);
|
||||
|
||||
req.setHeader(QNetworkRequest::ContentTypeHeader, u"application/x-www-form-urlencoded"_s);
|
||||
|
||||
QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
|
||||
QNetworkReply *reply = network_->post(req, query);
|
||||
const QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
|
||||
QNetworkReply *reply = network_->post(network_request, query);
|
||||
replies_ << reply;
|
||||
QObject::connect(reply, &QNetworkReply::sslErrors, this, &QobuzService::HandleLoginSSLErrors);
|
||||
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply]() { HandleAuthReply(reply); });
|
||||
@@ -304,7 +301,7 @@ void QobuzService::SendLoginWithCredentials(const QString &app_id, const QString
|
||||
void QobuzService::HandleLoginSSLErrors(const QList<QSslError> &ssl_errors) {
|
||||
|
||||
for (const QSslError &ssl_error : ssl_errors) {
|
||||
login_errors_ += ssl_error.errorString();
|
||||
qLog(Debug) << "Qobuz" << ssl_error.errorString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -321,115 +318,111 @@ void QobuzService::HandleAuthReply(QNetworkReply *reply) {
|
||||
LoginError(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// See if there is Json data containing "status", "code" and "message" - then use that instead.
|
||||
QByteArray data(reply->readAll());
|
||||
QJsonParseError json_error;
|
||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||
if (json_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (!json_obj.isEmpty() && json_obj.contains("status"_L1) && json_obj.contains("code"_L1) && json_obj.contains("message"_L1)) {
|
||||
int code = json_obj["code"_L1].toInt();
|
||||
QString message = json_obj["message"_L1].toString();
|
||||
login_errors_ << QStringLiteral("%1 (%2)").arg(message).arg(code);
|
||||
}
|
||||
// See if there is Json data containing "status", "code" and "message" - then use that instead.
|
||||
const QByteArray data = reply->readAll();
|
||||
QString error_message;
|
||||
QJsonParseError json_error;
|
||||
const QJsonDocument json_document = QJsonDocument::fromJson(data, &json_error);
|
||||
if (json_error.error == QJsonParseError::NoError && !json_document.isEmpty() && json_document.isObject()) {
|
||||
const QJsonObject json_object = json_document.object();
|
||||
if (!json_object.isEmpty() && json_object.contains("status"_L1) && json_object.contains("code"_L1) && json_object.contains("message"_L1)) {
|
||||
const int code = json_object["code"_L1].toInt();
|
||||
const QString message = json_object["message"_L1].toString();
|
||||
error_message = QStringLiteral("%1 (%2)").arg(message).arg(code);
|
||||
}
|
||||
if (login_errors_.isEmpty()) {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
login_errors_ << QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||
}
|
||||
else {
|
||||
login_errors_ << QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
|
||||
}
|
||||
}
|
||||
LoginError();
|
||||
return;
|
||||
}
|
||||
if (error_message.isEmpty()) {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
error_message = QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||
}
|
||||
else {
|
||||
error_message = QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
|
||||
}
|
||||
}
|
||||
LoginError(error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
login_errors_.clear();
|
||||
|
||||
const QByteArray data = reply->readAll();
|
||||
QJsonParseError json_error;
|
||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||
|
||||
const QJsonDocument json_document = QJsonDocument::fromJson(data, &json_error);
|
||||
if (json_error.error != QJsonParseError::NoError) {
|
||||
LoginError(u"Authentication reply from server missing Json data."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
if (json_doc.isEmpty()) {
|
||||
if (json_document.isEmpty()) {
|
||||
LoginError(u"Authentication reply from server has empty Json document."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_doc.isObject()) {
|
||||
LoginError(u"Authentication reply from server has Json document that is not an object."_s, json_doc);
|
||||
if (!json_document.isObject()) {
|
||||
LoginError(u"Authentication reply from server has Json document that is not an object."_s, json_document);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (json_obj.isEmpty()) {
|
||||
LoginError(u"Authentication reply from server has empty Json object."_s, json_doc);
|
||||
const QJsonObject json_object = json_document.object();
|
||||
if (json_object.isEmpty()) {
|
||||
LoginError(u"Authentication reply from server has empty Json object."_s, json_document);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("user_auth_token"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user_auth_token"_s, json_obj);
|
||||
if (!json_object.contains("user_auth_token"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user_auth_token"_s, json_object);
|
||||
return;
|
||||
}
|
||||
user_auth_token_ = json_obj["user_auth_token"_L1].toString();
|
||||
user_auth_token_ = json_object["user_auth_token"_L1].toString();
|
||||
|
||||
if (!json_obj.contains("user"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user"_s, json_obj);
|
||||
if (!json_object.contains("user"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user"_s, json_object);
|
||||
return;
|
||||
}
|
||||
QJsonValue value_user = json_obj["user"_L1];
|
||||
const QJsonValue value_user = json_object["user"_L1];
|
||||
if (!value_user.isObject()) {
|
||||
LoginError(u"Authentication reply user is not a object"_s, json_obj);
|
||||
LoginError(u"Authentication reply user is not a object"_s, json_object);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_user = value_user.toObject();
|
||||
const QJsonObject object_user = value_user.toObject();
|
||||
|
||||
if (!obj_user.contains("id"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user id"_s, obj_user);
|
||||
if (!object_user.contains("id"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user id"_s, object_user);
|
||||
return;
|
||||
}
|
||||
user_id_ = obj_user["id"_L1].toInt();
|
||||
user_id_ = object_user["id"_L1].toInt();
|
||||
|
||||
if (!obj_user.contains("device"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user device"_s, obj_user);
|
||||
if (!object_user.contains("device"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user device"_s, object_user);
|
||||
return;
|
||||
}
|
||||
QJsonValue value_device = obj_user["device"_L1];
|
||||
const QJsonValue value_device = object_user["device"_L1];
|
||||
if (!value_device.isObject()) {
|
||||
LoginError(u"Authentication reply from server user device is not a object"_s, value_device);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_device = value_device.toObject();
|
||||
const QJsonObject object_device = value_device.toObject();
|
||||
|
||||
if (!obj_device.contains("device_manufacturer_id"_L1)) {
|
||||
LoginError(u"Authentication reply from server device is missing device_manufacturer_id"_s, obj_device);
|
||||
if (!object_device.contains("device_manufacturer_id"_L1)) {
|
||||
LoginError(u"Authentication reply from server device is missing device_manufacturer_id"_s, object_device);
|
||||
return;
|
||||
}
|
||||
device_id_ = obj_device["device_manufacturer_id"_L1].toString();
|
||||
device_id_ = object_device["device_manufacturer_id"_L1].toString();
|
||||
|
||||
if (!obj_user.contains("credential"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user credential"_s, obj_user);
|
||||
if (!object_user.contains("credential"_L1)) {
|
||||
LoginError(u"Authentication reply from server is missing user credential"_s, object_user);
|
||||
return;
|
||||
}
|
||||
QJsonValue value_credential = obj_user["credential"_L1];
|
||||
const QJsonValue value_credential = object_user["credential"_L1];
|
||||
if (!value_credential.isObject()) {
|
||||
LoginError(u"Authentication reply from serve userr credential is not a object"_s, value_device);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_credential = value_credential.toObject();
|
||||
const QJsonObject object_credential = value_credential.toObject();
|
||||
|
||||
if (!obj_credential.contains("id"_L1)) {
|
||||
LoginError(u"Authentication reply user credential from server is missing user credential id"_s, obj_credential);
|
||||
if (!object_credential.contains("id"_L1)) {
|
||||
LoginError(u"Authentication reply user credential from server is missing user credential id"_s, object_credential);
|
||||
return;
|
||||
}
|
||||
credential_id_ = obj_credential["id"_L1].toInt();
|
||||
credential_id_ = object_credential["id"_L1].toInt();
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(QobuzSettings::kSettingsGroup);
|
||||
@@ -444,12 +437,12 @@ void QobuzService::HandleAuthReply(QNetworkReply *reply) {
|
||||
login_attempts_ = 0;
|
||||
if (timer_login_attempt_->isActive()) timer_login_attempt_->stop();
|
||||
|
||||
Q_EMIT LoginComplete(true);
|
||||
Q_EMIT LoginFinished(true);
|
||||
Q_EMIT LoginSuccess();
|
||||
|
||||
}
|
||||
|
||||
void QobuzService::Logout() {
|
||||
void QobuzService::ClearSession() {
|
||||
|
||||
user_auth_token_.clear();
|
||||
device_id_.clear();
|
||||
@@ -475,19 +468,19 @@ void QobuzService::TryLogin() {
|
||||
if (authenticated() || login_sent_) return;
|
||||
|
||||
if (login_attempts_ >= kLoginAttempts) {
|
||||
Q_EMIT LoginComplete(false, tr("Maximum number of login attempts reached."));
|
||||
Q_EMIT LoginFinished(false, tr("Maximum number of login attempts reached."));
|
||||
return;
|
||||
}
|
||||
if (app_id_.isEmpty()) {
|
||||
Q_EMIT LoginComplete(false, tr("Missing Qobuz app ID."));
|
||||
Q_EMIT LoginFinished(false, tr("Missing Qobuz app ID."));
|
||||
return;
|
||||
}
|
||||
if (username_.isEmpty()) {
|
||||
Q_EMIT LoginComplete(false, tr("Missing Qobuz username."));
|
||||
Q_EMIT LoginFinished(false, tr("Missing Qobuz username."));
|
||||
return;
|
||||
}
|
||||
if (password_.isEmpty()) {
|
||||
Q_EMIT LoginComplete(false, tr("Missing Qobuz password."));
|
||||
Q_EMIT LoginFinished(false, tr("Missing Qobuz password."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -517,8 +510,7 @@ void QobuzService::GetArtists() {
|
||||
return;
|
||||
}
|
||||
|
||||
ResetArtistsRequest();
|
||||
artists_request_.reset(new QobuzRequest(this, url_handler_, network_, QobuzBaseRequest::Type::FavouriteArtists), [](QobuzRequest *request) { request->deleteLater(); });
|
||||
artists_request_.reset(new QobuzRequest(this, url_handler_, network_, QobuzBaseRequest::Type::FavouriteArtists));
|
||||
QObject::connect(&*artists_request_, &QobuzRequest::Results, this, &QobuzService::ArtistsResultsReceived);
|
||||
QObject::connect(&*artists_request_, &QobuzRequest::UpdateStatus, this, &QobuzService::ArtistsUpdateStatusReceived);
|
||||
QObject::connect(&*artists_request_, &QobuzRequest::UpdateProgress, this, &QobuzService::ArtistsUpdateProgressReceived);
|
||||
@@ -567,8 +559,7 @@ void QobuzService::GetAlbums() {
|
||||
return;
|
||||
}
|
||||
|
||||
ResetAlbumsRequest();
|
||||
albums_request_.reset(new QobuzRequest(this, url_handler_, network_, QobuzBaseRequest::Type::FavouriteAlbums), [](QobuzRequest *request) { request->deleteLater(); });
|
||||
albums_request_.reset(new QobuzRequest(this, url_handler_, network_, QobuzBaseRequest::Type::FavouriteAlbums));
|
||||
QObject::connect(&*albums_request_, &QobuzRequest::Results, this, &QobuzService::AlbumsResultsReceived);
|
||||
QObject::connect(&*albums_request_, &QobuzRequest::UpdateStatus, this, &QobuzService::AlbumsUpdateStatusReceived);
|
||||
QObject::connect(&*albums_request_, &QobuzRequest::UpdateProgress, this, &QobuzService::AlbumsUpdateProgressReceived);
|
||||
@@ -617,8 +608,7 @@ void QobuzService::GetSongs() {
|
||||
return;
|
||||
}
|
||||
|
||||
ResetSongsRequest();
|
||||
songs_request_.reset(new QobuzRequest(this, url_handler_, network_, QobuzBaseRequest::Type::FavouriteSongs), [](QobuzRequest *request) { request->deleteLater(); });
|
||||
songs_request_.reset(new QobuzRequest(this, url_handler_, network_, QobuzBaseRequest::Type::FavouriteSongs));
|
||||
QObject::connect(&*songs_request_, &QobuzRequest::Results, this, &QobuzService::SongsResultsReceived);
|
||||
QObject::connect(&*songs_request_, &QobuzRequest::UpdateStatus, this, &QobuzService::SongsUpdateStatusReceived);
|
||||
QObject::connect(&*songs_request_, &QobuzRequest::UpdateProgress, this, &QobuzService::SongsUpdateProgressReceived);
|
||||
@@ -678,8 +668,7 @@ void QobuzService::StartSearch() {
|
||||
|
||||
}
|
||||
|
||||
void QobuzService::CancelSearch() {
|
||||
}
|
||||
void QobuzService::CancelSearch() {}
|
||||
|
||||
void QobuzService::SendSearch() {
|
||||
|
||||
@@ -697,12 +686,10 @@ void QobuzService::SendSearch() {
|
||||
break;
|
||||
}
|
||||
|
||||
search_request_.reset(new QobuzRequest(this, url_handler_, network_, query_type), [](QobuzRequest *request) { request->deleteLater(); } );
|
||||
|
||||
search_request_.reset(new QobuzRequest(this, url_handler_, network_, query_type));
|
||||
QObject::connect(&*search_request_, &QobuzRequest::Results, this, &QobuzService::SearchResultsReceived);
|
||||
QObject::connect(&*search_request_, &QobuzRequest::UpdateStatus, this, &QobuzService::SearchUpdateStatus);
|
||||
QObject::connect(&*search_request_, &QobuzRequest::UpdateProgress, this, &QobuzService::SearchUpdateProgress);
|
||||
|
||||
search_request_->Search(search_id_, search_text_);
|
||||
search_request_->Process();
|
||||
|
||||
@@ -724,16 +711,15 @@ uint QobuzService::GetStreamURL(const QUrl &url, QString &error) {
|
||||
|
||||
uint id = 0;
|
||||
while (id == 0) id = ++next_stream_url_request_id_;
|
||||
SharedPtr<QobuzStreamURLRequest> stream_url_req;
|
||||
stream_url_req.reset(new QobuzStreamURLRequest(this, network_, url, id), [](QobuzStreamURLRequest *request) { request->deleteLater(); });
|
||||
stream_url_requests_.insert(id, stream_url_req);
|
||||
QobuzStreamURLRequestPtr stream_url_request = QobuzStreamURLRequestPtr(new QobuzStreamURLRequest(this, network_, url, id), &QObject::deleteLater);
|
||||
stream_url_requests_.insert(id, stream_url_request);
|
||||
|
||||
QObject::connect(&*stream_url_req, &QobuzStreamURLRequest::TryLogin, this, &QobuzService::TryLogin);
|
||||
QObject::connect(&*stream_url_req, &QobuzStreamURLRequest::StreamURLFailure, this, &QobuzService::HandleStreamURLFailure);
|
||||
QObject::connect(&*stream_url_req, &QobuzStreamURLRequest::StreamURLSuccess, this, &QobuzService::HandleStreamURLSuccess);
|
||||
QObject::connect(this, &QobuzService::LoginComplete, &*stream_url_req, &QobuzStreamURLRequest::LoginComplete);
|
||||
QObject::connect(&*stream_url_request, &QobuzStreamURLRequest::TryLogin, this, &QobuzService::TryLogin);
|
||||
QObject::connect(&*stream_url_request, &QobuzStreamURLRequest::StreamURLFailure, this, &QobuzService::HandleStreamURLFailure);
|
||||
QObject::connect(&*stream_url_request, &QobuzStreamURLRequest::StreamURLSuccess, this, &QobuzService::HandleStreamURLSuccess);
|
||||
QObject::connect(this, &QobuzService::LoginFinished, &*stream_url_request, &QobuzStreamURLRequest::LoginComplete);
|
||||
|
||||
stream_url_req->Process();
|
||||
stream_url_request->Process();
|
||||
|
||||
return id;
|
||||
|
||||
@@ -759,18 +745,10 @@ void QobuzService::HandleStreamURLSuccess(const uint id, const QUrl &media_url,
|
||||
|
||||
void QobuzService::LoginError(const QString &error, const QVariant &debug) {
|
||||
|
||||
if (!error.isEmpty()) login_errors_ << error;
|
||||
|
||||
QString error_html;
|
||||
for (const QString &e : std::as_const(login_errors_)) {
|
||||
qLog(Error) << "Qobuz:" << e;
|
||||
error_html += e + u"<br />"_s;
|
||||
}
|
||||
qLog(Error) << "Qobuz:" << error;
|
||||
if (debug.isValid()) qLog(Debug) << debug;
|
||||
|
||||
Q_EMIT LoginFailure(error_html);
|
||||
Q_EMIT LoginComplete(false, error_html);
|
||||
|
||||
login_errors_.clear();
|
||||
Q_EMIT LoginFailure(error);
|
||||
Q_EMIT LoginFinished(false, error);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
@@ -36,6 +34,8 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
#include <QSslError>
|
||||
#include <QScopedPointer>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
@@ -57,6 +57,8 @@ class CollectionBackend;
|
||||
class CollectionModel;
|
||||
class CollectionFilter;
|
||||
|
||||
using QobuzRequestPtr = QScopedPointer<QobuzRequest, QScopedPointerDeleteLater>;
|
||||
|
||||
class QobuzService : public StreamingService {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -77,7 +79,7 @@ class QobuzService : public StreamingService {
|
||||
void Exit() override;
|
||||
void ReloadSettings() override;
|
||||
|
||||
void Logout();
|
||||
void ClearSession();
|
||||
int Search(const QString &text, const SearchType type) override;
|
||||
void CancelSearch() override;
|
||||
|
||||
@@ -169,10 +171,10 @@ class QobuzService : public StreamingService {
|
||||
QTimer *timer_search_delay_;
|
||||
QTimer *timer_login_attempt_;
|
||||
|
||||
SharedPtr<QobuzRequest> artists_request_;
|
||||
SharedPtr<QobuzRequest> albums_request_;
|
||||
SharedPtr<QobuzRequest> songs_request_;
|
||||
SharedPtr<QobuzRequest> search_request_;
|
||||
QobuzRequestPtr artists_request_;
|
||||
QobuzRequestPtr albums_request_;
|
||||
QobuzRequestPtr songs_request_;
|
||||
QobuzRequestPtr search_request_;
|
||||
QobuzFavoriteRequest *favorite_request_;
|
||||
|
||||
QString app_id_;
|
||||
@@ -202,9 +204,7 @@ class QobuzService : public StreamingService {
|
||||
int login_attempts_;
|
||||
|
||||
uint next_stream_url_request_id_;
|
||||
QMap<uint, SharedPtr<QobuzStreamURLRequest>> stream_url_requests_;
|
||||
|
||||
QStringList login_errors_;
|
||||
QMap<uint, QSharedPointer<QobuzStreamURLRequest>> stream_url_requests_;
|
||||
|
||||
QList<QObject*> wait_for_exit_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,14 +22,11 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMimeDatabase>
|
||||
#include <QPair>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QChar>
|
||||
#include <QUrl>
|
||||
#include <QDateTime>
|
||||
#include <QMimeDatabase>
|
||||
#include <QNetworkReply>
|
||||
#include <QCryptographicHash>
|
||||
#include <QJsonObject>
|
||||
@@ -47,7 +44,6 @@ using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
QobuzStreamURLRequest::QobuzStreamURLRequest(QobuzService *service, const SharedPtr<NetworkAccessManager> network, const QUrl &media_url, const uint id, QObject *parent)
|
||||
: QobuzBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
reply_(nullptr),
|
||||
media_url_(media_url),
|
||||
id_(id),
|
||||
@@ -81,7 +77,7 @@ void QobuzStreamURLRequest::LoginComplete(const bool success, const QString &err
|
||||
|
||||
void QobuzStreamURLRequest::Process() {
|
||||
|
||||
if (app_id().isEmpty() || app_secret().isEmpty()) {
|
||||
if (service_->app_id().isEmpty() || service_->app_secret().isEmpty()) {
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, tr("Missing Qobuz app ID or secret."));
|
||||
return;
|
||||
}
|
||||
@@ -116,9 +112,9 @@ void QobuzStreamURLRequest::GetStreamURL() {
|
||||
reply_->deleteLater();
|
||||
}
|
||||
|
||||
quint64 timestamp = QDateTime::currentSecsSinceEpoch();
|
||||
const quint64 timestamp = QDateTime::currentSecsSinceEpoch();
|
||||
|
||||
ParamList params_to_sign = ParamList() << Param(u"format_id"_s, QString::number(format()))
|
||||
ParamList params_to_sign = ParamList() << Param(u"format_id"_s, QString::number(service_->format()))
|
||||
<< Param(u"track_id"_s, QString::number(song_id_));
|
||||
|
||||
std::sort(params_to_sign.begin(), params_to_sign.end());
|
||||
@@ -129,7 +125,7 @@ void QobuzStreamURLRequest::GetStreamURL() {
|
||||
data_to_sign += param.first + param.second;
|
||||
}
|
||||
data_to_sign += QString::number(timestamp);
|
||||
data_to_sign += app_secret();
|
||||
data_to_sign += service_->app_secret();
|
||||
|
||||
QByteArray const digest = QCryptographicHash::hash(data_to_sign.toUtf8(), QCryptographicHash::Md5);
|
||||
const QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, u'0').toLower();
|
||||
@@ -137,7 +133,7 @@ void QobuzStreamURLRequest::GetStreamURL() {
|
||||
ParamList params = params_to_sign;
|
||||
params << Param(u"request_ts"_s, QString::number(timestamp));
|
||||
params << Param(u"request_sig"_s, signature);
|
||||
params << Param(u"user_auth_token"_s, user_auth_token());
|
||||
params << Param(u"user_auth_token"_s, service_->user_auth_token());
|
||||
|
||||
std::sort(params.begin(), params.end());
|
||||
|
||||
@@ -150,48 +146,49 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
||||
|
||||
if (!reply_) return;
|
||||
|
||||
QByteArray data = GetReplyData(reply_);
|
||||
Q_ASSERT(replies_.contains(reply_));
|
||||
replies_.removeAll(reply_);
|
||||
|
||||
const JsonObjectResult json_object_result = ParseJsonObject(reply_);
|
||||
|
||||
QObject::disconnect(reply_, nullptr, this, nullptr);
|
||||
reply_->deleteLater();
|
||||
reply_ = nullptr;
|
||||
|
||||
if (data.isEmpty()) {
|
||||
if (!authenticated() && login_sent() && tries_ <= 1) {
|
||||
if (!json_object_result.success()) {
|
||||
if (!authenticated() && service_->login_sent() && tries_ <= 1) {
|
||||
need_login_ = true;
|
||||
return;
|
||||
}
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, json_object_result.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) {
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
const QJsonObject &json_object = json_object_result.json_object;
|
||||
|
||||
if (json_object.isEmpty()) {
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, u"Empty json object."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("track_id"_L1)) {
|
||||
Error(u"Invalid Json reply, stream url is missing track_id."_s, json_obj);
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
if (!json_object.contains("track_id"_L1)) {
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, u"Invalid Json reply, stream url is missing track_id."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
int track_id = json_obj["track_id"_L1].toInt();
|
||||
const int track_id = json_object["track_id"_L1].toInt();
|
||||
if (track_id != song_id_) {
|
||||
Error(u"Incorrect track ID returned."_s, json_obj);
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, u"Incorrect track ID returned."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("mime_type"_L1) || !json_obj.contains("url"_L1)) {
|
||||
Error(u"Invalid Json reply, stream url is missing url or mime_type."_s, json_obj);
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
if (!json_object.contains("mime_type"_L1) || !json_object.contains("url"_L1)) {
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, u"Invalid Json reply, stream url is missing url or mime_type."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
QUrl url(json_obj["url"_L1].toString());
|
||||
QString mimetype = json_obj["mime_type"_L1].toString();
|
||||
const QUrl url(json_object["url"_L1].toString());
|
||||
const QString mimetype = json_object["mime_type"_L1].toString();
|
||||
|
||||
Song::FileType filetype(Song::FileType::Unknown);
|
||||
QMimeDatabase mimedb;
|
||||
@@ -206,34 +203,23 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
||||
}
|
||||
|
||||
if (!url.isValid()) {
|
||||
Error(u"Returned stream url is invalid."_s, json_obj);
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
Q_EMIT StreamURLFailure(id_, media_url_, u"Returned stream url is invalid."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
qint64 duration = -1;
|
||||
if (json_obj.contains("duration"_L1)) {
|
||||
duration = json_obj["duration"_L1].toInt() * kNsecPerSec;
|
||||
if (json_object.contains("duration"_L1)) {
|
||||
duration = json_object["duration"_L1].toInt() * kNsecPerSec;
|
||||
}
|
||||
int samplerate = -1;
|
||||
if (json_obj.contains("sampling_rate"_L1)) {
|
||||
samplerate = static_cast<int>(json_obj["sampling_rate"_L1].toDouble()) * 1000;
|
||||
if (json_object.contains("sampling_rate"_L1)) {
|
||||
samplerate = static_cast<int>(json_object["sampling_rate"_L1].toDouble()) * 1000;
|
||||
}
|
||||
int bit_depth = -1;
|
||||
if (json_obj.contains("bit_depth"_L1)) {
|
||||
bit_depth = static_cast<int>(json_obj["bit_depth"_L1].toDouble());
|
||||
if (json_object.contains("bit_depth"_L1)) {
|
||||
bit_depth = static_cast<int>(json_object["bit_depth"_L1].toDouble());
|
||||
}
|
||||
|
||||
Q_EMIT StreamURLSuccess(id_, media_url_, url, filetype, samplerate, bit_depth, duration);
|
||||
|
||||
}
|
||||
|
||||
void QobuzStreamURLRequest::Error(const QString &error, const QVariant &debug) {
|
||||
|
||||
if (!error.isEmpty()) {
|
||||
qLog(Error) << "Qobuz:" << error;
|
||||
errors_ << error;
|
||||
}
|
||||
if (debug.isValid()) qLog(Debug) << debug;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,12 +22,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
@@ -65,16 +63,14 @@ class QobuzStreamURLRequest : public QobuzBaseRequest {
|
||||
void LoginComplete(const bool success, const QString &error = QString());
|
||||
|
||||
private:
|
||||
void Error(const QString &error, const QVariant &debug = QVariant());
|
||||
|
||||
QobuzService *service_;
|
||||
QNetworkReply *reply_;
|
||||
QUrl media_url_;
|
||||
uint id_;
|
||||
int song_id_;
|
||||
int tries_;
|
||||
bool need_login_;
|
||||
QStringList errors_;
|
||||
};
|
||||
|
||||
using QobuzStreamURLRequestPtr = QSharedPointer<QobuzStreamURLRequest>;
|
||||
|
||||
#endif // QOBUZSTREAMURLREQUEST_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2018-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2018-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,8 +20,6 @@
|
||||
#ifndef QOBUZURLHANDLER_H
|
||||
#define QOBUZURLHANDLER_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
Reference in New Issue
Block a user