Fix submit and error handling
This commit is contained in:
@@ -150,11 +150,7 @@ void AudioScrobbler::Love(const Song &song) {
|
|||||||
void AudioScrobbler::Submit() {
|
void AudioScrobbler::Submit() {
|
||||||
for (ScrobblerService *service : scrobbler_services_->List()) {
|
for (ScrobblerService *service : scrobbler_services_->List()) {
|
||||||
if (!service->IsEnabled() || !service->IsAuthenticated() || service->IsSubmitted()) continue;
|
if (!service->IsEnabled() || !service->IsAuthenticated() || service->IsSubmitted()) continue;
|
||||||
int msec = 300;
|
service->DoSubmit();
|
||||||
if (submit_delay_ != 0) msec = (submit_delay_ * kMsecPerSec);
|
|
||||||
DoAfter(this, SLOT(Submit()), msec);
|
|
||||||
service->Submitted();
|
|
||||||
DoInAMinuteOrSo(service, SLOT(Submit()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -407,13 +407,24 @@ void ListenBrainzScrobbler::Scrobble(const Song &song) {
|
|||||||
Submit();
|
Submit();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int msec = (app_->scrobbler()->SubmitDelay() * kMsecPerSec);
|
qint64 msec = (app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec);
|
||||||
DoAfter(this, SLOT(Submit()), msec);
|
DoAfter(this, SLOT(Submit()), msec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListenBrainzScrobbler::DoSubmit() {
|
||||||
|
|
||||||
|
if (!submitted_ && cache_->Count() > 0) {
|
||||||
|
submitted_ = true;
|
||||||
|
qint64 msec = 30000ll;
|
||||||
|
if (app_->scrobbler()->SubmitDelay() != 0) msec = (app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec);
|
||||||
|
DoAfter(this, SLOT(Submit()), msec);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void ListenBrainzScrobbler::Submit() {
|
void ListenBrainzScrobbler::Submit() {
|
||||||
|
|
||||||
qLog(Debug) << __PRETTY_FUNCTION__;
|
qLog(Debug) << __PRETTY_FUNCTION__;
|
||||||
@@ -461,12 +472,14 @@ void ListenBrainzScrobbler::ScrobbleRequestFinished(QNetworkReply *reply, QList<
|
|||||||
QByteArray data = GetReplyData(reply);
|
QByteArray data = GetReplyData(reply);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
cache_->ClearSent(list);
|
cache_->ClearSent(list);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject json_obj = ExtractJsonObj(data);
|
QJsonObject json_obj = ExtractJsonObj(data);
|
||||||
if (json_obj.isEmpty()) {
|
if (json_obj.isEmpty()) {
|
||||||
cache_->ClearSent(list);
|
cache_->ClearSent(list);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,6 +488,7 @@ void ListenBrainzScrobbler::ScrobbleRequestFinished(QNetworkReply *reply, QList<
|
|||||||
QString error_desc = json_obj["error_description"].toString();
|
QString error_desc = json_obj["error_description"].toString();
|
||||||
Error(error_desc);
|
Error(error_desc);
|
||||||
cache_->ClearSent(list);
|
cache_->ClearSent(list);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,6 +498,7 @@ void ListenBrainzScrobbler::ScrobbleRequestFinished(QNetworkReply *reply, QList<
|
|||||||
}
|
}
|
||||||
|
|
||||||
cache_->Flush(list);
|
cache_->Flush(list);
|
||||||
|
DoSubmit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class ListenBrainzScrobbler : public ScrobblerService {
|
|||||||
void RequestSession(QUrl url, QString token);
|
void RequestSession(QUrl url, QString token);
|
||||||
void AuthError(QString error);
|
void AuthError(QString error);
|
||||||
void Error(QString error, QVariant debug = QVariant());
|
void Error(QString error, QVariant debug = QVariant());
|
||||||
|
void DoSubmit();
|
||||||
|
|
||||||
static const char *kAuthUrl;
|
static const char *kAuthUrl;
|
||||||
static const char *kAuthTokenUrl;
|
static const char *kAuthTokenUrl;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class ScrobblerCache : public QObject {
|
|||||||
ScrobblerCacheItem *Get(const quint64 hash);
|
ScrobblerCacheItem *Get(const quint64 hash);
|
||||||
void Remove(const quint64 hash);
|
void Remove(const quint64 hash);
|
||||||
void Remove(ScrobblerCacheItem &item);
|
void Remove(ScrobblerCacheItem &item);
|
||||||
|
int Count() const { return scrobbler_cache_.size(); };
|
||||||
QList<ScrobblerCacheItem*> List() const { return scrobbler_cache_.values(); }
|
QList<ScrobblerCacheItem*> List() const { return scrobbler_cache_.values(); }
|
||||||
void ClearSent(const QList<quint64> list);
|
void ClearSent(const QList<quint64> list);
|
||||||
void Flush(const QList<quint64> list);
|
void Flush(const QList<quint64> list);
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class ScrobblerService : public QObject {
|
|||||||
virtual void Love(const Song &song) = 0;
|
virtual void Love(const Song &song) = 0;
|
||||||
virtual void Error(QString error, QVariant debug = QVariant()) = 0;
|
virtual void Error(QString error, QVariant debug = QVariant()) = 0;
|
||||||
|
|
||||||
|
virtual void DoSubmit() = 0;
|
||||||
virtual void Submitted() = 0;
|
virtual void Submitted() = 0;
|
||||||
virtual bool IsSubmitted() const { return false; }
|
virtual bool IsSubmitted() const { return false; }
|
||||||
|
|
||||||
|
|||||||
@@ -340,8 +340,8 @@ QByteArray ScrobblingAPI20::GetReplyData(QNetworkReply *reply) {
|
|||||||
QJsonObject json_obj = json_doc.object();
|
QJsonObject json_obj = json_doc.object();
|
||||||
if (json_obj.contains("error") && json_obj.contains("message")) {
|
if (json_obj.contains("error") && json_obj.contains("message")) {
|
||||||
error_code = json_obj["error"].toInt();
|
error_code = json_obj["error"].toInt();
|
||||||
QString message = json_obj["message"].toString();
|
QString error_message = json_obj["message"].toString();
|
||||||
error_reason = QString("%1 (%2)").arg(message).arg(error_code);
|
error_reason = QString("%1 (%2)").arg(error_message).arg(error_code);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
error_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||||
@@ -424,13 +424,24 @@ void ScrobblingAPI20::Scrobble(const Song &song) {
|
|||||||
Submit();
|
Submit();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int msec = (app_->scrobbler()->SubmitDelay() * kMsecPerSec);
|
qint64 msec = (app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec);
|
||||||
DoAfter(this, SLOT(Submit()), msec);
|
DoAfter(this, SLOT(Submit()), msec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScrobblingAPI20::DoSubmit() {
|
||||||
|
|
||||||
|
if (!submitted_ && cache()->Count() > 0) {
|
||||||
|
submitted_ = true;
|
||||||
|
qint64 msec = 30000ll;
|
||||||
|
if (app_->scrobbler()->SubmitDelay() != 0) msec = (app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec);
|
||||||
|
DoAfter(this, SLOT(Submit()), msec);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void ScrobblingAPI20::Submit() {
|
void ScrobblingAPI20::Submit() {
|
||||||
|
|
||||||
qLog(Debug) << __PRETTY_FUNCTION__ << name_;
|
qLog(Debug) << __PRETTY_FUNCTION__ << name_;
|
||||||
@@ -474,22 +485,31 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QList<quint6
|
|||||||
QByteArray data = GetReplyData(reply);
|
QByteArray data = GetReplyData(reply);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
cache()->ClearSent(list);
|
cache()->ClearSent(list);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject json_obj = ExtractJsonObj(data);
|
QJsonObject json_obj = ExtractJsonObj(data);
|
||||||
if (json_obj.isEmpty()) {
|
if (json_obj.isEmpty()) {
|
||||||
cache()->ClearSent(list);
|
cache()->ClearSent(list);
|
||||||
|
DoSubmit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json_obj.contains("error") && json_obj.contains("message")) {
|
||||||
|
int error_code = json_obj["error"].toInt();
|
||||||
|
QString error_message = json_obj["message"].toString();
|
||||||
|
QString error_reason = QString("%1 (%2)").arg(error_message).arg(error_code);
|
||||||
|
Error(error_reason);
|
||||||
|
cache()->ClearSent(list);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!json_obj.contains("scrobbles")) {
|
if (!json_obj.contains("scrobbles")) {
|
||||||
if (json_obj.contains("error")) {
|
Error("Json reply from server is missing scrobbles.", json_obj);
|
||||||
int error = json_obj["error"].toInt();
|
|
||||||
Error(QString("Error: %1: %2").arg(QString::number(error)).arg(error));
|
|
||||||
}
|
|
||||||
Error("Json reply from server is missing scrobbles.");
|
|
||||||
cache()->ClearSent(list);
|
cache()->ClearSent(list);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,30 +518,36 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QList<quint6
|
|||||||
QJsonValue json_scrobbles = json_obj["scrobbles"];
|
QJsonValue json_scrobbles = json_obj["scrobbles"];
|
||||||
if (!json_scrobbles.isObject()) {
|
if (!json_scrobbles.isObject()) {
|
||||||
Error("Json scrobbles is not an object.", json_obj);
|
Error("Json scrobbles is not an object.", json_obj);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
json_obj = json_scrobbles.toObject();
|
json_obj = json_scrobbles.toObject();
|
||||||
if (json_obj.isEmpty()) {
|
if (json_obj.isEmpty()) {
|
||||||
Error("Json scrobbles object is empty.", json_scrobbles);
|
Error("Json scrobbles object is empty.", json_scrobbles);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!json_obj.contains("@attr") || !json_obj.contains("scrobble")) {
|
if (!json_obj.contains("@attr") || !json_obj.contains("scrobble")) {
|
||||||
Error("Json scrobbles object is missing values.", json_obj);
|
Error("Json scrobbles object is missing values.", json_obj);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonValue json_attr = json_obj["@attr"];
|
QJsonValue json_attr = json_obj["@attr"];
|
||||||
if (!json_attr.isObject()) {
|
if (!json_attr.isObject()) {
|
||||||
Error("Json scrobbles attr is not an object.", json_attr);
|
Error("Json scrobbles attr is not an object.", json_attr);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json_obj_attr = json_attr.toObject();
|
QJsonObject json_obj_attr = json_attr.toObject();
|
||||||
if (json_obj_attr.isEmpty()) {
|
if (json_obj_attr.isEmpty()) {
|
||||||
Error("Json scrobbles attr is empty.", json_attr);
|
Error("Json scrobbles attr is empty.", json_attr);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!json_obj_attr.contains("accepted") || !json_obj_attr.contains("ignored")) {
|
if (!json_obj_attr.contains("accepted") || !json_obj_attr.contains("ignored")) {
|
||||||
Error("Json scrobbles attr is missing values.", json_obj_attr);
|
Error("Json scrobbles attr is missing values.", json_obj_attr);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int accepted = json_obj_attr["accepted"].toInt();
|
int accepted = json_obj_attr["accepted"].toInt();
|
||||||
@@ -531,11 +557,13 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QList<quint6
|
|||||||
QJsonValue json_scrobble = json_obj["scrobble"];
|
QJsonValue json_scrobble = json_obj["scrobble"];
|
||||||
if (!json_scrobble.isArray()) {
|
if (!json_scrobble.isArray()) {
|
||||||
Error("Json scrobbles scrobble is not array.", json_scrobble);
|
Error("Json scrobbles scrobble is not array.", json_scrobble);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonArray json_array_scrobble = json_scrobble.toArray();
|
QJsonArray json_array_scrobble = json_scrobble.toArray();
|
||||||
if (json_array_scrobble.isEmpty()) {
|
if (json_array_scrobble.isEmpty()) {
|
||||||
Error("Json scrobbles scrobble array is empty.", json_scrobble);
|
Error("Json scrobbles scrobble array is empty.", json_scrobble);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,7 +586,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QList<quint6
|
|||||||
!json_track.contains("ignoredMessage")
|
!json_track.contains("ignoredMessage")
|
||||||
) {
|
) {
|
||||||
Error("Json scrobbles scrobble is missing values.", json_track);
|
Error("Json scrobbles scrobble is missing values.", json_track);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonValue json_value_artist = json_track["artist"];
|
QJsonValue json_value_artist = json_track["artist"];
|
||||||
@@ -602,6 +630,8 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QList<quint6
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DoSubmit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrobblingAPI20::SendSingleScrobble(ScrobblerCacheItem *item) {
|
void ScrobblingAPI20::SendSingleScrobble(ScrobblerCacheItem *item) {
|
||||||
@@ -629,84 +659,139 @@ void ScrobblingAPI20::SingleScrobbleRequestFinished(QNetworkReply *reply, quint6
|
|||||||
ScrobblerCacheItem *item = cache()->Get(timestamp);
|
ScrobblerCacheItem *item = cache()->Get(timestamp);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
Error(QString("Received reply for non-existing cache entry %1.").arg(timestamp));
|
Error(QString("Received reply for non-existing cache entry %1.").arg(timestamp));
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray data = GetReplyData(reply);
|
QByteArray data = GetReplyData(reply);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
|
item->sent_ = false;
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject json_obj = ExtractJsonObj(data);
|
QJsonObject json_obj = ExtractJsonObj(data);
|
||||||
if (json_obj.isEmpty()) {
|
if (json_obj.isEmpty()) {
|
||||||
|
item->sent_ = false;
|
||||||
|
DoSubmit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json_obj.contains("error") && json_obj.contains("message")) {
|
||||||
|
int error_code = json_obj["error"].toInt();
|
||||||
|
QString error_message = json_obj["message"].toString();
|
||||||
|
QString error_reason = QString("%1 (%2)").arg(error_message).arg(error_code);
|
||||||
|
Error(error_reason);
|
||||||
|
item->sent_ = false;
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!json_obj.contains("scrobbles")) {
|
if (!json_obj.contains("scrobbles")) {
|
||||||
if (json_obj.contains("error")) {
|
Error("Json reply from server is missing scrobbles.", json_obj);
|
||||||
int error = json_obj["error"].toInt();
|
item->sent_ = false;
|
||||||
Error(QString("Error: %1: %2").arg(QString::number(error)).arg(error));
|
DoSubmit();
|
||||||
}
|
|
||||||
Error("Json reply from server is missing scrobbles.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache()->Remove(timestamp);
|
||||||
|
item = nullptr;
|
||||||
|
|
||||||
QJsonValue json_scrobbles = json_obj["scrobbles"];
|
QJsonValue json_scrobbles = json_obj["scrobbles"];
|
||||||
if (!json_scrobbles.isObject()) {
|
if (!json_scrobbles.isObject()) {
|
||||||
Error("Json scrobbles is not an object.", json_obj);
|
Error("Json scrobbles is not an object.", json_obj);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
json_obj = json_scrobbles.toObject();
|
json_obj = json_scrobbles.toObject();
|
||||||
if (json_obj.isEmpty()) {
|
if (json_obj.isEmpty()) {
|
||||||
Error("Json scrobbles object is empty.", json_scrobbles);
|
Error("Json scrobbles object is empty.", json_scrobbles);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!json_obj.contains("@attr") || !json_obj.contains("scrobble")) {
|
if (!json_obj.contains("@attr") || !json_obj.contains("scrobble")) {
|
||||||
Error("Json scrobbles object is missing values.", json_obj);
|
Error("Json scrobbles object is missing values.", json_obj);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonValue json_attr = json_obj["@attr"];
|
QJsonValue json_attr = json_obj["@attr"];
|
||||||
if (!json_attr.isObject()) {
|
if (!json_attr.isObject()) {
|
||||||
Error("Json scrobbles attr is not an object.", json_attr);
|
Error("Json scrobbles attr is not an object.", json_attr);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json_obj_attr = json_attr.toObject();
|
QJsonObject json_obj_attr = json_attr.toObject();
|
||||||
if (json_obj_attr.isEmpty()) {
|
if (json_obj_attr.isEmpty()) {
|
||||||
Error("Json scrobbles attr is empty.", json_attr);
|
Error("Json scrobbles attr is empty.", json_attr);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonValue json_scrobble = json_obj["scrobble"];
|
QJsonValue json_scrobble = json_obj["scrobble"];
|
||||||
if (!json_scrobble.isObject()) {
|
if (!json_scrobble.isObject()) {
|
||||||
Error("Json scrobbles scrobble is not an object.", json_scrobble);
|
Error("Json scrobbles scrobble is not an object.", json_scrobble);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json_obj_scrobble = json_scrobble.toObject();
|
QJsonObject json_obj_scrobble = json_scrobble.toObject();
|
||||||
if (json_obj_scrobble.isEmpty()) {
|
if (json_obj_scrobble.isEmpty()) {
|
||||||
Error("Json scrobbles scrobble is empty.", json_scrobble);
|
Error("Json scrobbles scrobble is empty.", json_scrobble);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!json_obj_attr.contains("accepted") || !json_obj_attr.contains("ignored")) {
|
if (!json_obj_attr.contains("accepted") || !json_obj_attr.contains("ignored")) {
|
||||||
Error("Json scrobbles attr is missing values.", json_obj_attr);
|
Error("Json scrobbles attr is missing values.", json_obj_attr);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!json_obj_scrobble.contains("artist") || !json_obj_scrobble.contains("album") || !json_obj_scrobble.contains("albumArtist") || !json_obj_scrobble.contains("track") || !json_obj_scrobble.contains("timestamp")) {
|
if (!json_obj_scrobble.contains("artist") || !json_obj_scrobble.contains("album") || !json_obj_scrobble.contains("albumArtist") || !json_obj_scrobble.contains("track") || !json_obj_scrobble.contains("timestamp")) {
|
||||||
Error("Json scrobbles scrobble is missing values.", json_obj_scrobble);
|
Error("Json scrobbles scrobble is missing values.", json_obj_scrobble);
|
||||||
|
DoSubmit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int accepted = json_obj_attr["accepted"].toVariant().toInt();
|
QJsonValue json_value_artist = json_obj_scrobble["artist"];
|
||||||
if (accepted == 1) {
|
QJsonValue json_value_album = json_obj_scrobble["album"];
|
||||||
qLog(Debug) << name_ << "Scrobble for" << item->song_ << "accepted";
|
QJsonValue json_value_song = json_obj_scrobble["track"];
|
||||||
}
|
|
||||||
else {
|
if (!json_value_artist.isObject() || !json_value_album.isObject() || !json_value_song.isObject()) {
|
||||||
Error(QString("Scrobble for \"%1\" not accepted").arg(item->song_));
|
Error("Json scrobbles scrobble values are not objects.", json_obj_scrobble);
|
||||||
|
DoSubmit();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache()->Remove(timestamp);
|
QJsonObject json_obj_artist = json_value_artist.toObject();
|
||||||
|
QJsonObject json_obj_album = json_value_album.toObject();
|
||||||
|
QJsonObject json_obj_song = json_value_song.toObject();
|
||||||
|
|
||||||
|
if (json_obj_artist.isEmpty() || json_obj_album.isEmpty() || json_obj_song.isEmpty()) {
|
||||||
|
Error("Json scrobbles scrobble values objects are empty.", json_obj_scrobble);
|
||||||
|
DoSubmit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!json_obj_artist.contains("#text") || !json_obj_album.contains("#text") || !json_obj_song.contains("#text")) {
|
||||||
|
Error("Json scrobbles scrobble values objects are missing #text.", json_obj_artist);
|
||||||
|
DoSubmit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString artist = json_obj_artist["#text"].toString();
|
||||||
|
QString album = json_obj_album["#text"].toString();
|
||||||
|
QString song = json_obj_song["#text"].toString();
|
||||||
|
|
||||||
|
int accepted = json_obj_attr["accepted"].toVariant().toInt();
|
||||||
|
if (accepted == 1) {
|
||||||
|
qLog(Debug) << name_ << "Scrobble for" << song << "accepted";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Error(QString("Scrobble for \"%1\" not accepted").arg(song));
|
||||||
|
}
|
||||||
|
|
||||||
|
DoSubmit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ class ScrobblingAPI20 : public ScrobblerService {
|
|||||||
void SendSingleScrobble(ScrobblerCacheItem *item);
|
void SendSingleScrobble(ScrobblerCacheItem *item);
|
||||||
void Error(QString error, QVariant debug = QVariant());
|
void Error(QString error, QVariant debug = QVariant());
|
||||||
QString ErrorString(ScrobbleErrorCode error) const;
|
QString ErrorString(ScrobbleErrorCode error) const;
|
||||||
|
void DoSubmit();
|
||||||
|
|
||||||
QString name_;
|
QString name_;
|
||||||
QString settings_group_;
|
QString settings_group_;
|
||||||
|
|||||||
Reference in New Issue
Block a user