parent
d398c86b0c
commit
1dae80a633
|
@ -68,6 +68,7 @@ class AudioScrobbler : public QObject {
|
||||||
int submit_delay() const { return settings_->submit_delay(); }
|
int submit_delay() const { return settings_->submit_delay(); }
|
||||||
bool prefer_albumartist() const { return settings_->prefer_albumartist(); }
|
bool prefer_albumartist() const { return settings_->prefer_albumartist(); }
|
||||||
bool ShowErrorDialog() const { return settings_->show_error_dialog(); }
|
bool ShowErrorDialog() const { return settings_->show_error_dialog(); }
|
||||||
|
bool strip_remastered() const { return settings_->strip_remastered(); }
|
||||||
QList<Song::Source> sources() const { return settings_->sources(); }
|
QList<Song::Source> sources() const { return settings_->sources(); }
|
||||||
|
|
||||||
void ShowConfig();
|
void ShowConfig();
|
||||||
|
|
|
@ -67,8 +67,7 @@ const char *ListenBrainzScrobbler::kCacheFile = "listenbrainzscrobbler.cache";
|
||||||
const int ListenBrainzScrobbler::kScrobblesPerRequest = 10;
|
const int ListenBrainzScrobbler::kScrobblesPerRequest = 10;
|
||||||
|
|
||||||
ListenBrainzScrobbler::ListenBrainzScrobbler(SharedPtr<ScrobblerSettings> settings, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
ListenBrainzScrobbler::ListenBrainzScrobbler(SharedPtr<ScrobblerSettings> settings, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||||
: ScrobblerService(kName, parent),
|
: ScrobblerService(kName, settings, parent),
|
||||||
settings_(settings),
|
|
||||||
network_(network),
|
network_(network),
|
||||||
cache_(new ScrobblerCache(kCacheFile, this)),
|
cache_(new ScrobblerCache(kCacheFile, this)),
|
||||||
server_(nullptr),
|
server_(nullptr),
|
||||||
|
|
|
@ -110,7 +110,6 @@ class ListenBrainzScrobbler : public ScrobblerService {
|
||||||
static const char *kCacheFile;
|
static const char *kCacheFile;
|
||||||
static const int kScrobblesPerRequest;
|
static const int kScrobblesPerRequest;
|
||||||
|
|
||||||
SharedPtr<ScrobblerSettings> settings_;
|
|
||||||
SharedPtr<NetworkAccessManager> network_;
|
SharedPtr<NetworkAccessManager> network_;
|
||||||
ScrobblerCache *cache_;
|
ScrobblerCache *cache_;
|
||||||
LocalRedirectServer *server_;
|
LocalRedirectServer *server_;
|
||||||
|
|
|
@ -27,10 +27,11 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include "scrobblerservice.h"
|
#include "scrobblerservice.h"
|
||||||
|
#include "scrobblersettings.h"
|
||||||
|
|
||||||
#include "core/song.h"
|
#include "core/song.h"
|
||||||
|
|
||||||
ScrobblerService::ScrobblerService(const QString &name, QObject *parent) : QObject(parent), name_(name) {}
|
ScrobblerService::ScrobblerService(const QString &name, SharedPtr<ScrobblerSettings> settings, QObject *parent) : QObject(parent), name_(name), settings_(settings) {}
|
||||||
|
|
||||||
bool ScrobblerService::ExtractJsonObj(const QByteArray &data, QJsonObject &json_obj, QString &error_description) {
|
bool ScrobblerService::ExtractJsonObj(const QByteArray &data, QJsonObject &json_obj, QString &error_description) {
|
||||||
|
|
||||||
|
@ -52,12 +53,20 @@ bool ScrobblerService::ExtractJsonObj(const QByteArray &data, QJsonObject &json_
|
||||||
|
|
||||||
QString ScrobblerService::StripAlbum(const QString &album) const {
|
QString ScrobblerService::StripAlbum(const QString &album) const {
|
||||||
|
|
||||||
return Song::AlbumRemoveDisc(album);
|
if (settings_->strip_remastered()) {
|
||||||
|
return Song::AlbumRemoveDiscMisc(album);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Song::AlbumRemoveDisc(album);;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ScrobblerService::StripTitle(const QString &title) const {
|
QString ScrobblerService::StripTitle(const QString &title) const {
|
||||||
|
|
||||||
return Song::TitleRemoveMisc(title);
|
if (settings_->strip_remastered()) {
|
||||||
|
return Song::TitleRemoveMisc(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
return title;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,13 @@
|
||||||
#include "core/shared_ptr.h"
|
#include "core/shared_ptr.h"
|
||||||
#include "core/song.h"
|
#include "core/song.h"
|
||||||
|
|
||||||
|
#include "scrobblersettings.h"
|
||||||
|
|
||||||
class ScrobblerService : public QObject {
|
class ScrobblerService : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ScrobblerService(const QString &name, QObject *parent);
|
explicit ScrobblerService(const QString &name, SharedPtr<ScrobblerSettings> settings, QObject *parent);
|
||||||
|
|
||||||
QString name() const { return name_; }
|
QString name() const { return name_; }
|
||||||
|
|
||||||
|
@ -71,8 +73,9 @@ class ScrobblerService : public QObject {
|
||||||
signals:
|
signals:
|
||||||
void ErrorMessage(const QString &error);
|
void ErrorMessage(const QString &error);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QString name_;
|
QString name_;
|
||||||
|
SharedPtr<ScrobblerSettings> settings_;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ScrobblerServicePtr = SharedPtr<ScrobblerService>;
|
using ScrobblerServicePtr = SharedPtr<ScrobblerService>;
|
||||||
|
|
|
@ -38,7 +38,8 @@ ScrobblerSettings::ScrobblerSettings(Application *app, QObject *parent)
|
||||||
love_button_(false),
|
love_button_(false),
|
||||||
submit_delay_(0),
|
submit_delay_(0),
|
||||||
prefer_albumartist_(false),
|
prefer_albumartist_(false),
|
||||||
show_error_dialog_(false) {
|
show_error_dialog_(false),
|
||||||
|
strip_remastered_(false) {
|
||||||
|
|
||||||
ReloadSettings();
|
ReloadSettings();
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ void ScrobblerSettings::ReloadSettings() {
|
||||||
submit_delay_ = s.value("submit", 0).toInt();
|
submit_delay_ = s.value("submit", 0).toInt();
|
||||||
prefer_albumartist_ = s.value("albumartist", false).toBool();
|
prefer_albumartist_ = s.value("albumartist", false).toBool();
|
||||||
show_error_dialog_ = s.value("show_error_dialog", true).toBool();
|
show_error_dialog_ = s.value("show_error_dialog", true).toBool();
|
||||||
|
strip_remastered_ = s.value("strip_remastered", true).toBool();
|
||||||
QStringList sources = s.value("sources").toStringList();
|
QStringList sources = s.value("sources").toStringList();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ class ScrobblerSettings : public QObject {
|
||||||
int submit_delay() const { return submit_delay_; }
|
int submit_delay() const { return submit_delay_; }
|
||||||
bool prefer_albumartist() const { return prefer_albumartist_; }
|
bool prefer_albumartist() const { return prefer_albumartist_; }
|
||||||
bool show_error_dialog() const { return show_error_dialog_; }
|
bool show_error_dialog() const { return show_error_dialog_; }
|
||||||
|
bool strip_remastered() const { return strip_remastered_; }
|
||||||
QList<Song::Source> sources() const { return sources_; }
|
QList<Song::Source> sources() const { return sources_; }
|
||||||
|
|
||||||
void ShowConfig();
|
void ShowConfig();
|
||||||
|
@ -73,6 +74,7 @@ class ScrobblerSettings : public QObject {
|
||||||
int submit_delay_;
|
int submit_delay_;
|
||||||
bool prefer_albumartist_;
|
bool prefer_albumartist_;
|
||||||
bool show_error_dialog_;
|
bool show_error_dialog_;
|
||||||
|
bool strip_remastered_;
|
||||||
QList<Song::Source> sources_;
|
QList<Song::Source> sources_;
|
||||||
|
|
||||||
Q_DISABLE_COPY(ScrobblerSettings)
|
Q_DISABLE_COPY(ScrobblerSettings)
|
||||||
|
|
|
@ -64,13 +64,12 @@ const char *ScrobblingAPI20::kSecret = "80fd738f49596e9709b1bf9319c444a8";
|
||||||
const int ScrobblingAPI20::kScrobblesPerRequest = 50;
|
const int ScrobblingAPI20::kScrobblesPerRequest = 50;
|
||||||
|
|
||||||
ScrobblingAPI20::ScrobblingAPI20(const QString &name, const QString &settings_group, const QString &auth_url, const QString &api_url, const bool batch, const QString &cache_file, SharedPtr<ScrobblerSettings> settings, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
ScrobblingAPI20::ScrobblingAPI20(const QString &name, const QString &settings_group, const QString &auth_url, const QString &api_url, const bool batch, const QString &cache_file, SharedPtr<ScrobblerSettings> settings, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||||
: ScrobblerService(name, parent),
|
: ScrobblerService(name, settings, parent),
|
||||||
name_(name),
|
name_(name),
|
||||||
settings_group_(settings_group),
|
settings_group_(settings_group),
|
||||||
auth_url_(auth_url),
|
auth_url_(auth_url),
|
||||||
api_url_(api_url),
|
api_url_(api_url),
|
||||||
batch_(batch),
|
batch_(batch),
|
||||||
settings_(settings),
|
|
||||||
network_(network),
|
network_(network),
|
||||||
cache_(new ScrobblerCache(cache_file, this)),
|
cache_(new ScrobblerCache(cache_file, this)),
|
||||||
server_(nullptr),
|
server_(nullptr),
|
||||||
|
|
|
@ -141,7 +141,6 @@ class ScrobblingAPI20 : public ScrobblerService {
|
||||||
QString api_url_;
|
QString api_url_;
|
||||||
bool batch_;
|
bool batch_;
|
||||||
|
|
||||||
SharedPtr<ScrobblerSettings> settings_;
|
|
||||||
SharedPtr<NetworkAccessManager> network_;
|
SharedPtr<NetworkAccessManager> network_;
|
||||||
ScrobblerCache *cache_;
|
ScrobblerCache *cache_;
|
||||||
LocalRedirectServer *server_;
|
LocalRedirectServer *server_;
|
||||||
|
|
|
@ -43,8 +43,7 @@
|
||||||
const char *SubsonicScrobbler::kName = "Subsonic";
|
const char *SubsonicScrobbler::kName = "Subsonic";
|
||||||
|
|
||||||
SubsonicScrobbler::SubsonicScrobbler(SharedPtr<ScrobblerSettings> settings, Application *app, QObject *parent)
|
SubsonicScrobbler::SubsonicScrobbler(SharedPtr<ScrobblerSettings> settings, Application *app, QObject *parent)
|
||||||
: ScrobblerService(kName, parent),
|
: ScrobblerService(kName, settings, parent),
|
||||||
settings_(settings),
|
|
||||||
app_(app),
|
app_(app),
|
||||||
service_(nullptr),
|
service_(nullptr),
|
||||||
enabled_(false),
|
enabled_(false),
|
||||||
|
|
|
@ -65,7 +65,6 @@ class SubsonicScrobbler : public ScrobblerService {
|
||||||
void Submit() override;
|
void Submit() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SharedPtr<ScrobblerSettings> settings_;
|
|
||||||
Application *app_;
|
Application *app_;
|
||||||
SharedPtr<SubsonicService> service_;
|
SharedPtr<SubsonicService> service_;
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
|
|
|
@ -98,6 +98,7 @@ void ScrobblerSettingsPage::Load() {
|
||||||
ui_->spinbox_submit->setValue(scrobbler_->submit_delay());
|
ui_->spinbox_submit->setValue(scrobbler_->submit_delay());
|
||||||
ui_->checkbox_albumartist->setChecked(scrobbler_->prefer_albumartist());
|
ui_->checkbox_albumartist->setChecked(scrobbler_->prefer_albumartist());
|
||||||
ui_->checkbox_show_error_dialog->setChecked(scrobbler_->ShowErrorDialog());
|
ui_->checkbox_show_error_dialog->setChecked(scrobbler_->ShowErrorDialog());
|
||||||
|
ui_->checkbox_strip_remastered->setChecked(scrobbler_->strip_remastered());
|
||||||
|
|
||||||
ui_->checkbox_source_collection->setChecked(scrobbler_->sources().contains(Song::Source::Collection));
|
ui_->checkbox_source_collection->setChecked(scrobbler_->sources().contains(Song::Source::Collection));
|
||||||
ui_->checkbox_source_local->setChecked(scrobbler_->sources().contains(Song::Source::LocalFile));
|
ui_->checkbox_source_local->setChecked(scrobbler_->sources().contains(Song::Source::LocalFile));
|
||||||
|
@ -139,6 +140,7 @@ void ScrobblerSettingsPage::Save() {
|
||||||
s.setValue("submit", ui_->spinbox_submit->value());
|
s.setValue("submit", ui_->spinbox_submit->value());
|
||||||
s.setValue("albumartist", ui_->checkbox_albumartist->isChecked());
|
s.setValue("albumartist", ui_->checkbox_albumartist->isChecked());
|
||||||
s.setValue("show_error_dialog", ui_->checkbox_show_error_dialog->isChecked());
|
s.setValue("show_error_dialog", ui_->checkbox_show_error_dialog->isChecked());
|
||||||
|
s.setValue("strip_remastered", ui_->checkbox_strip_remastered->isChecked());
|
||||||
|
|
||||||
QStringList sources;
|
QStringList sources;
|
||||||
if (ui_->checkbox_source_collection->isChecked()) sources << Song::TextForSource(Song::Source::Collection);
|
if (ui_->checkbox_source_collection->isChecked()) sources << Song::TextForSource(Song::Source::Collection);
|
||||||
|
|
|
@ -119,6 +119,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkbox_strip_remastered">
|
||||||
|
<property name="text">
|
||||||
|
<string>Strip "remastered" and similar from album and title</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupbox_sources">
|
<widget class="QGroupBox" name="groupbox_sources">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
Loading…
Reference in New Issue