Make Listenbrainz send playing now
This commit is contained in:
parent
b0c951cdd2
commit
07cfdbbc25
|
@ -151,7 +151,7 @@ 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;
|
int msec = 300;
|
||||||
if (submit_delay_ > 0) msec = (submit_delay_ * kMsecPerSec);
|
if (submit_delay_ != 0) msec = (submit_delay_ * kMsecPerSec);
|
||||||
DoAfter(this, SLOT(Submit()), msec);
|
DoAfter(this, SLOT(Submit()), msec);
|
||||||
service->Submitted();
|
service->Submitted();
|
||||||
DoInAMinuteOrSo(service, SLOT(Submit()));
|
DoInAMinuteOrSo(service, SLOT(Submit()));
|
||||||
|
|
|
@ -333,15 +333,12 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) {
|
||||||
|
|
||||||
if (!song.is_metadata_good()) return;
|
if (!song.is_metadata_good()) return;
|
||||||
|
|
||||||
// FIXME: This does not work: BAD REQUEST (302)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QJsonObject object_listen;
|
|
||||||
object_listen.insert("listened_at", QJsonValue::fromVariant(timestamp_));
|
|
||||||
QJsonObject object_track_metadata;
|
QJsonObject object_track_metadata;
|
||||||
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(song.artist()));
|
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(song.artist()));
|
||||||
object_track_metadata.insert("release_name", QJsonValue::fromVariant(song.album()));
|
object_track_metadata.insert("release_name", QJsonValue::fromVariant(song.album()));
|
||||||
object_track_metadata.insert("track_name", QJsonValue::fromVariant(song.title()));
|
object_track_metadata.insert("track_name", QJsonValue::fromVariant(song.title()));
|
||||||
|
|
||||||
|
QJsonObject object_listen;
|
||||||
object_listen.insert("track_metadata", object_track_metadata);
|
object_listen.insert("track_metadata", object_track_metadata);
|
||||||
|
|
||||||
QJsonArray array_payload;
|
QJsonArray array_payload;
|
||||||
|
@ -366,9 +363,28 @@ void ListenBrainzScrobbler::UpdateNowPlayingRequestFinished(QNetworkReply *reply
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qLog(Debug) << data;
|
|
||||||
|
|
||||||
// TODO
|
QJsonObject json_obj = ExtractJsonObj(data);
|
||||||
|
if (json_obj.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json_obj.contains("error") && json_obj.contains("error_description")) {
|
||||||
|
QString error_code = json_obj["error"].toString();
|
||||||
|
QString error_desc = json_obj["error_description"].toString();
|
||||||
|
Error(error_desc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!json_obj.contains("status")) {
|
||||||
|
Error("Missing status from server.", json_obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString status = json_obj["status"].toString();
|
||||||
|
if (status.toLower() != "ok") {
|
||||||
|
Error(status);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue