parent
5844616ea8
commit
e3a4cf1cf5
@ -72,6 +72,7 @@ void AudioScrobbler::ReloadSettings() {
|
||||
scrobble_button_ = s.value("scrobble_button", false).toBool();
|
||||
love_button_ = s.value("love_button", false).toBool();
|
||||
submit_delay_ = s.value("submit", 0).toInt();
|
||||
prefer_albumartist_ = s.value("albumartist", false).toBool();
|
||||
s.endGroup();
|
||||
|
||||
emit ScrobblingEnabledChanged(enabled_);
|
||||
|
@ -48,6 +48,7 @@ class AudioScrobbler : public QObject {
|
||||
bool ScrobbleButton() const { return scrobble_button_; }
|
||||
bool LoveButton() const { return love_button_; }
|
||||
int SubmitDelay() const { return submit_delay_; }
|
||||
bool PreferAlbumArtist() const { return prefer_albumartist_; }
|
||||
|
||||
void UpdateNowPlaying(const Song &song);
|
||||
void ClearPlaying();
|
||||
@ -87,6 +88,7 @@ class AudioScrobbler : public QObject {
|
||||
bool scrobble_button_;
|
||||
bool love_button_;
|
||||
int submit_delay_;
|
||||
bool prefer_albumartist_;
|
||||
|
||||
};
|
||||
|
||||
|
@ -35,6 +35,8 @@ class ScrobblerCacheItem : public QObject {
|
||||
explicit ScrobblerCacheItem(const QString &artist, const QString &album, const QString &song, const QString &albumartist, const int track, const qint64 duration, const quint64 ×tamp);
|
||||
~ScrobblerCacheItem();
|
||||
|
||||
QString effective_albumartist() const { return albumartist_.isEmpty() ? artist_ : albumartist_; }
|
||||
|
||||
public:
|
||||
QString artist_;
|
||||
QString album_;
|
||||
|
@ -81,11 +81,16 @@ ScrobblingAPI20::~ScrobblingAPI20() {}
|
||||
void ScrobblingAPI20::ReloadSettings() {
|
||||
|
||||
QSettings s;
|
||||
|
||||
s.beginGroup(settings_group_);
|
||||
enabled_ = s.value("enabled", false).toBool();
|
||||
https_ = s.value("https", false).toBool();
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(ScrobblerSettingsPage::kSettingsGroup);
|
||||
prefer_albumartist_ = s.value("albumartist", false).toBool();
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
void ScrobblingAPI20::LoadSession() {
|
||||
@ -417,10 +422,11 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) {
|
||||
|
||||
ParamList params = ParamList()
|
||||
<< Param("method", "track.updateNowPlaying")
|
||||
<< Param("artist", song.artist())
|
||||
<< Param("artist", prefer_albumartist_ ? song.effective_albumartist() : song.artist())
|
||||
<< Param("track", song.title())
|
||||
<< Param("album", album);
|
||||
if (!song.albumartist().isEmpty()) params << Param("albumArtist", song.albumartist());
|
||||
|
||||
if (!prefer_albumartist_ && !song.albumartist().isEmpty()) params << Param("albumArtist", song.albumartist());
|
||||
|
||||
QNetworkReply *reply = CreateRequest(params);
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(UpdateNowPlayingRequestFinished(QNetworkReply*)), reply);
|
||||
@ -515,12 +521,12 @@ void ScrobblingAPI20::Submit() {
|
||||
if (!batch_) { SendSingleScrobble(item); continue; }
|
||||
i++;
|
||||
list << item->timestamp_;
|
||||
params << Param(QString("%1[%2]").arg("artist").arg(i), item->artist_);
|
||||
params << Param(QString("%1[%2]").arg("artist").arg(i), prefer_albumartist_ ? item->effective_albumartist() : item->artist_);
|
||||
params << Param(QString("%1[%2]").arg("album").arg(i), item->album_);
|
||||
params << Param(QString("%1[%2]").arg("track").arg(i), item->song_);
|
||||
params << Param(QString("%1[%2]").arg("timestamp").arg(i), QString::number(item->timestamp_));
|
||||
params << Param(QString("%1[%2]").arg("duration").arg(i), QString::number(item->duration_ / kNsecPerSec));
|
||||
if (!item->albumartist_.isEmpty()) params << Param(QString("%1[%2]").arg("albumArtist").arg(i), item->albumartist_);
|
||||
if (!prefer_albumartist_ && !item->albumartist_.isEmpty()) params << Param(QString("%1[%2]").arg("albumArtist").arg(i), item->albumartist_);
|
||||
if (item->track_ > 0) params << Param(QString("%1[%2]").arg(i).arg("trackNumber"), QString::number(item->track_));
|
||||
if (i >= kScrobblesPerRequest) break;
|
||||
}
|
||||
@ -692,13 +698,13 @@ void ScrobblingAPI20::SendSingleScrobble(ScrobblerCacheItem *item) {
|
||||
|
||||
ParamList params = ParamList()
|
||||
<< Param("method", "track.scrobble")
|
||||
<< Param("artist", item->artist_)
|
||||
<< Param("artist", prefer_albumartist_ ? item->effective_albumartist() : item->artist_)
|
||||
<< Param("album", item->album_)
|
||||
<< Param("track", item->song_)
|
||||
<< Param("timestamp", QString::number(item->timestamp_))
|
||||
<< Param("duration", QString::number(item->duration_ / kNsecPerSec));
|
||||
|
||||
if (!item->albumartist_.isEmpty()) params << Param("albumArtist", item->albumartist_);
|
||||
if (!prefer_albumartist_ && !item->albumartist_.isEmpty()) params << Param("albumArtist", item->albumartist_);
|
||||
if (item->track_ > 0) params << Param("trackNumber", QString::number(item->track_));
|
||||
|
||||
QNetworkReply *reply = CreateRequest(params);
|
||||
|
@ -147,6 +147,7 @@ class ScrobblingAPI20 : public ScrobblerService {
|
||||
|
||||
bool enabled_;
|
||||
bool https_;
|
||||
bool prefer_albumartist_;
|
||||
|
||||
bool subscriber_;
|
||||
QString username_;
|
||||
|
@ -84,6 +84,7 @@ void ScrobblerSettingsPage::Load() {
|
||||
ui_->checkbox_love_button->setChecked(scrobbler_->LoveButton());
|
||||
ui_->checkbox_offline->setChecked(scrobbler_->IsOffline());
|
||||
ui_->spinbox_submit->setValue(scrobbler_->SubmitDelay());
|
||||
ui_->checkbox_albumartist->setChecked(scrobbler_->PreferAlbumArtist());
|
||||
|
||||
ui_->checkbox_lastfm_enable->setChecked(lastfmscrobbler_->IsEnabled());
|
||||
ui_->checkbox_lastfm_https->setChecked(lastfmscrobbler_->IsUseHTTPS());
|
||||
@ -108,6 +109,7 @@ void ScrobblerSettingsPage::Save() {
|
||||
s.setValue("love_button", ui_->checkbox_love_button->isChecked());
|
||||
s.setValue("offline", ui_->checkbox_offline->isChecked());
|
||||
s.setValue("submit", ui_->spinbox_submit->value());
|
||||
s.setValue("albumartist", ui_->checkbox_albumartist->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(LastFMScrobbler::kSettingsGroup);
|
||||
|
@ -102,6 +102,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_albumartist">
|
||||
<property name="text">
|
||||
<string>Prefer album artist when sending scrobbles</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupbox_lastfm">
|
||||
<property name="title">
|
||||
|
Loading…
x
Reference in New Issue
Block a user