Add setting for enabling scrobbling based on song source

Fixes #416
This commit is contained in:
Jonas Kvinge
2020-08-25 23:44:27 +02:00
parent ae48008803
commit 1431916183
6 changed files with 193 additions and 1 deletions

View File

@@ -74,8 +74,28 @@ void AudioScrobbler::ReloadSettings() {
submit_delay_ = s.value("submit", 0).toInt();
prefer_albumartist_ = s.value("albumartist", false).toBool();
show_error_dialog_ = s.value("show_error_dialog", true).toBool();
QStringList sources = s.value("sources").toStringList();
s.endGroup();
sources_.clear();
if (sources.isEmpty()) {
sources_ << Song::Source_Unknown
<< Song::Source_LocalFile
<< Song::Source_Collection
<< Song::Source_CDDA
<< Song::Source_Device
<< Song::Source_Stream
<< Song::Source_Tidal
<< Song::Source_Subsonic
<< Song::Source_Qobuz;
}
else {
for (const QString &source : sources) {
sources_ << Song::SourceFromText(source);
}
}
emit ScrobblingEnabledChanged(enabled_);
emit ScrobbleButtonVisibilityChanged(scrobble_button_);
emit LoveButtonVisibilityChanged(love_button_);
@@ -122,6 +142,8 @@ void AudioScrobbler::ShowConfig() {
void AudioScrobbler::UpdateNowPlaying(const Song &song) {
if (!sources_.contains(song.source())) return;
qLog(Debug) << "Sending now playing for song" << song.artist() << song.album() << song.title();
for (ScrobblerService *service : scrobbler_services_->List()) {
@@ -142,6 +164,8 @@ void AudioScrobbler::ClearPlaying() {
void AudioScrobbler::Scrobble(const Song &song, const int scrobble_point) {
if (!sources_.contains(song.source())) return;
qLog(Debug) << "Scrobbling song" << song.artist() << song.album() << song.title() << "at" << scrobble_point;
for (ScrobblerService *service : scrobbler_services_->List()) {