Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for prefer album artist option to ListenBrainz #989

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/scrobbler/listenbrainzscrobbler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "core/timeconstants.h"
#include "core/logging.h"
#include "internet/localredirectserver.h"
#include "settings/scrobblersettingspage.h"

#include "audioscrobbler.h"
#include "scrobblerservice.h"
Expand Down Expand Up @@ -76,7 +77,8 @@ ListenBrainzScrobbler::ListenBrainzScrobbler(Application *app, QObject *parent)
submitted_(false),
scrobbled_(false),
timestamp_(0),
submit_error_(false) {
submit_error_(false),
prefer_albumartist_(false) {

refresh_login_timer_.setSingleShot(true);
QObject::connect(&refresh_login_timer_, &QTimer::timeout, this, &ListenBrainzScrobbler::RequestNewAccessToken);
Expand Down Expand Up @@ -114,6 +116,10 @@ void ListenBrainzScrobbler::ReloadSettings() {
user_token_ = s.value("user_token").toString();
s.endGroup();

s.beginGroup(ScrobblerSettingsPage::kSettingsGroup);
prefer_albumartist_ = s.value("albumartist", false).toBool();
s.endGroup();

}

void ListenBrainzScrobbler::LoadSession() {
Expand Down Expand Up @@ -429,7 +435,7 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) {
title = title.remove(Song::kTitleRemoveMisc);

QJsonObject object_track_metadata;
if (song.albumartist().isEmpty() || song.albumartist().compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0) {
staticssleever668 marked this conversation as resolved.
Show resolved Hide resolved
if (!prefer_albumartist_ || song.albumartist().isEmpty() || song.albumartist().compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0) {
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(song.artist()));
}
else {
Expand Down Expand Up @@ -552,7 +558,7 @@ void ListenBrainzScrobbler::Submit() {
QJsonObject object_listen;
object_listen.insert("listened_at", QJsonValue::fromVariant(item->timestamp_));
QJsonObject object_track_metadata;
if (item->albumartist_.isEmpty() || item->albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0) {
if (!prefer_albumartist_ || item->albumartist_.isEmpty() || item->albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0) {
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(item->artist_));
}
else {
Expand Down
2 changes: 2 additions & 0 deletions src/scrobbler/listenbrainzscrobbler.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class ListenBrainzScrobbler : public ScrobblerService {
QTimer timer_submit_;
bool submit_error_;

bool prefer_albumartist_;
staticssleever668 marked this conversation as resolved.
Show resolved Hide resolved

QList<QNetworkReply*> replies_;

};
Expand Down