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()) {

View File

@@ -23,8 +23,10 @@
#include "config.h"
#include <QObject>
#include <QList>
#include <QString>
#include "core/song.h"
#include "scrobblerservices.h"
class Application;
@@ -46,6 +48,7 @@ class AudioScrobbler : public QObject {
int SubmitDelay() const { return submit_delay_; }
bool PreferAlbumArtist() const { return prefer_albumartist_; }
bool ShowErrorDialog() const { return show_error_dialog_; }
QList<Song::Source> sources() const { return sources_; }
void UpdateNowPlaying(const Song &song);
void ClearPlaying();
@@ -86,6 +89,7 @@ class AudioScrobbler : public QObject {
int submit_delay_;
bool prefer_albumartist_;
bool show_error_dialog_;
QList<Song::Source> sources_;
};