Add an option to prefer AlbumArtist tag over Artist when scrobbling to Last.fm. Fixes issue 2901
This commit is contained in:
parent
c3fe642779
commit
f606ae9ba8
|
@ -1001,10 +1001,14 @@ void Song::BindToFtsQuery(QSqlQuery *query) const {
|
|||
}
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void Song::ToLastFM(lastfm::Track* track) const {
|
||||
void Song::ToLastFM(lastfm::Track* track, bool prefer_album_artist) const {
|
||||
lastfm::MutableTrack mtrack(*track);
|
||||
|
||||
mtrack.setArtist(d->artist_);
|
||||
if (prefer_album_artist && !d->albumartist_.isEmpty()) {
|
||||
mtrack.setArtist(d->albumartist_);
|
||||
} else {
|
||||
mtrack.setArtist(d->artist_);
|
||||
}
|
||||
mtrack.setAlbum(d->album_);
|
||||
mtrack.setTitle(d->title_);
|
||||
mtrack.setDuration(length_nanosec() / kNsecPerSec);
|
||||
|
|
|
@ -128,7 +128,7 @@ class Song {
|
|||
void BindToQuery(QSqlQuery* query) const;
|
||||
void BindToFtsQuery(QSqlQuery* query) const;
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void ToLastFM(lastfm::Track* track) const;
|
||||
void ToLastFM(lastfm::Track* track, bool prefer_album_artist) const;
|
||||
#endif
|
||||
void ToXesam(QVariantMap* map) const;
|
||||
void ToProtobuf(pb::tagreader::SongMetadata* pb) const;
|
||||
|
|
|
@ -149,6 +149,7 @@ void LastFMService::ReloadSettings() {
|
|||
scrobbling_enabled_ = settings.value("ScrobblingEnabled", true).toBool();
|
||||
buttons_visible_ = settings.value("ShowLoveBanButtons", true).toBool();
|
||||
scrobble_button_visible_ = settings.value("ShowScrobbleButton", true).toBool();
|
||||
prefer_albumartist_ = settings.value("PreferAlbumArtist", false).toBool();
|
||||
friend_names_.Load();
|
||||
|
||||
//avoid emitting signal if it's not changed
|
||||
|
@ -156,6 +157,7 @@ void LastFMService::ReloadSettings() {
|
|||
emit ScrobblingEnabledChanged(scrobbling_enabled_);
|
||||
emit ButtonVisibilityChanged(buttons_visible_);
|
||||
emit ScrobbleButtonVisibilityChanged(scrobble_button_visible_);
|
||||
emit PreferAlbumArtistChanged(prefer_albumartist_);
|
||||
}
|
||||
|
||||
void LastFMService::ShowConfig() {
|
||||
|
@ -496,7 +498,7 @@ lastfm::Track LastFMService::TrackFromSong(const Song &song) const {
|
|||
return last_track_;
|
||||
|
||||
lastfm::Track ret;
|
||||
song.ToLastFM(&ret);
|
||||
song.ToLastFM(&ret, PreferAlbumArtist());
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ class LastFMService : public InternetService {
|
|||
bool IsScrobblingEnabled() const { return scrobbling_enabled_; }
|
||||
bool AreButtonsVisible() const { return buttons_visible_; }
|
||||
bool IsScrobbleButtonVisible() const { return scrobble_button_visible_; }
|
||||
bool PreferAlbumArtist() const { return prefer_albumartist_; }
|
||||
bool HasConnectionProblems() const { return connection_problems_; }
|
||||
|
||||
void Authenticate(const QString& username, const QString& password);
|
||||
|
@ -132,6 +133,7 @@ class LastFMService : public InternetService {
|
|||
void ScrobblingEnabledChanged(bool value);
|
||||
void ButtonVisibilityChanged(bool value);
|
||||
void ScrobbleButtonVisibilityChanged(bool value);
|
||||
void PreferAlbumArtistChanged(bool value);
|
||||
void ScrobblerStatus(int value);
|
||||
void UpdatedSubscriberStatus(bool is_subscriber);
|
||||
void ScrobbledRadioStream();
|
||||
|
@ -212,6 +214,7 @@ class LastFMService : public InternetService {
|
|||
bool scrobbling_enabled_;
|
||||
bool buttons_visible_;
|
||||
bool scrobble_button_visible_;
|
||||
bool prefer_albumartist_;
|
||||
|
||||
QStandardItem* root_item_;
|
||||
QStandardItem* artist_list_;
|
||||
|
|
|
@ -86,6 +86,7 @@ void LastFMSettingsPage::Load() {
|
|||
ui_->scrobble->setChecked(service_->IsScrobblingEnabled());
|
||||
ui_->love_ban_->setChecked(service_->AreButtonsVisible());
|
||||
ui_->scrobble_button->setChecked(service_->IsScrobbleButtonVisible());
|
||||
ui_->prefer_albumartist->setChecked(service_->PreferAlbumArtist());
|
||||
|
||||
if (service_->IsAuthenticated()) {
|
||||
service_->UpdateSubscriberStatus();
|
||||
|
@ -116,6 +117,7 @@ void LastFMSettingsPage::Save() {
|
|||
s.setValue("ScrobblingEnabled", ui_->scrobble->isChecked());
|
||||
s.setValue("ShowLoveBanButtons", ui_->love_ban_->isChecked());
|
||||
s.setValue("ShowScrobbleButton", ui_->scrobble_button->isChecked());
|
||||
s.setValue("PreferAlbumArtist", ui_->prefer_albumartist->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
service_->ReloadSettings();
|
||||
|
|
|
@ -97,6 +97,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="prefer_albumartist">
|
||||
<property name="text">
|
||||
<string>Use Album Artist tag when available</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue