Make scrobble submit delay configurable
This commit is contained in:
parent
7c3f3da07d
commit
bab01291b1
@ -39,11 +39,8 @@
|
||||
#include "core/application.h"
|
||||
#include "core/closure.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/network.h"
|
||||
#include "core/player.h"
|
||||
#include "core/song.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/timeconstants.h"
|
||||
#include "settings/settingsdialog.h"
|
||||
#include "settings/scrobblersettingspage.h"
|
||||
|
||||
@ -150,6 +147,9 @@ void AudioScrobbler::Love(const Song &song) {
|
||||
void AudioScrobbler::Submit() {
|
||||
for (ScrobblerService *service : scrobbler_services_->List()) {
|
||||
if (!service->IsEnabled() || !service->IsAuthenticated() || service->IsSubmitted()) continue;
|
||||
int msec = 300;
|
||||
if (submit_delay_ > 0) msec = (submit_delay_ * kMsecPerSec);
|
||||
DoAfter(this, SLOT(Submit()), msec);
|
||||
service->Submitted();
|
||||
DoInAMinuteOrSo(service, SLOT(Submit()));
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ class AudioScrobbler : public QObject {
|
||||
bool IsEnabled() const { return enabled_; }
|
||||
bool IsOffline() const { return offline_; }
|
||||
bool ScrobbleButton() const { return scrobble_button_; }
|
||||
int SubmitDelay() const { return submit_delay_; }
|
||||
|
||||
void UpdateNowPlaying(const Song &song);
|
||||
void Scrobble(const Song &song, const int scrobble_point);
|
||||
@ -82,6 +83,7 @@ class AudioScrobbler : public QObject {
|
||||
bool enabled_;
|
||||
bool offline_;
|
||||
bool scrobble_button_;
|
||||
int submit_delay_;
|
||||
|
||||
};
|
||||
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "core/closure.h"
|
||||
#include "core/network.h"
|
||||
#include "core/song.h"
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "core/closure.h"
|
||||
#include "core/network.h"
|
||||
#include "core/song.h"
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "core/closure.h"
|
||||
#include "core/network.h"
|
||||
#include "core/song.h"
|
||||
@ -387,8 +386,14 @@ void ListenBrainzScrobbler::Scrobble(const Song &song) {
|
||||
}
|
||||
|
||||
if (!submitted_) {
|
||||
DoInAMinuteOrSo(this, SLOT(Submit()));
|
||||
submitted_ = true;
|
||||
if (app_->scrobbler()->SubmitDelay() <= 0) {
|
||||
Submit();
|
||||
}
|
||||
else {
|
||||
int msec = (app_->scrobbler()->SubmitDelay() * kMsecPerSec);
|
||||
DoAfter(this, SLOT(Submit()), msec);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "core/closure.h"
|
||||
#include "core/network.h"
|
||||
#include "core/song.h"
|
||||
@ -420,8 +419,14 @@ void ScrobblingAPI20::Scrobble(const Song &song) {
|
||||
}
|
||||
|
||||
if (!submitted_) {
|
||||
DoInAMinuteOrSo(this, SLOT(Submit()));
|
||||
submitted_ = true;
|
||||
if (!batch_ || app_->scrobbler()->SubmitDelay() <= 0) {
|
||||
Submit();
|
||||
}
|
||||
else {
|
||||
int msec = (app_->scrobbler()->SubmitDelay() * kMsecPerSec);
|
||||
DoAfter(this, SLOT(Submit()), msec);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ void ScrobblerSettingsPage::Load() {
|
||||
ui_->checkbox_enable->setChecked(scrobbler_->IsEnabled());
|
||||
ui_->checkbox_scrobble_button->setChecked(scrobbler_->ScrobbleButton());
|
||||
ui_->checkbox_offline->setChecked(scrobbler_->IsOffline());
|
||||
ui_->spinbox_submit->setValue(scrobbler_->SubmitDelay());
|
||||
|
||||
ui_->checkbox_lastfm_enable->setChecked(lastfmscrobbler_->IsEnabled());
|
||||
LastFM_RefreshControls(lastfmscrobbler_->IsAuthenticated());
|
||||
@ -103,6 +104,7 @@ void ScrobblerSettingsPage::Save() {
|
||||
s.setValue("enabled", ui_->checkbox_enable->isChecked());
|
||||
s.setValue("scrobble_button", ui_->checkbox_scrobble_button->isChecked());
|
||||
s.setValue("offline", ui_->checkbox_offline->isChecked());
|
||||
s.setValue("submit", ui_->spinbox_submit->value());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(LastFMScrobbler::kSettingsGroup);
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>769</width>
|
||||
<height>611</height>
|
||||
<height>726</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -27,6 +27,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_scrobble_info">
|
||||
<property name="text">
|
||||
<string>Songs are scrobbled if they have valid metadata and are longer than 30 seconds, have been playing for at least half its duration or for 4 minutes (whichever occurs earlier).</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_offline">
|
||||
<property name="text">
|
||||
@ -41,6 +51,50 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_submit">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_submit">
|
||||
<property name="text">
|
||||
<string>Submit scrobbles every</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinbox_submit">
|
||||
<property name="suffix">
|
||||
<string> minutes</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_submit">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_submit_info">
|
||||
<property name="text">
|
||||
<string>(This is the delay between when a song is scrobbled and when scrobbles are submitted to the server. Settings the time to 0 minutes will submit scrobbles immediately).</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupbox_lastfm">
|
||||
<property name="title">
|
||||
|
Loading…
x
Reference in New Issue
Block a user