summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-23 22:08:18 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-23 22:08:18 +0200
commit455fb16d627e1f45c2651c35f743ef16e20b0c45 (patch)
treeac4bb54750d0882a8267dc1a9baf1ac2e55effef
parentf0bab69d9d09fb0a80091d813cc57a85fc3d8c61 (diff)
downloadpianobar-windows-455fb16d627e1f45c2651c35f743ef16e20b0c45.tar.gz
pianobar-windows-455fb16d627e1f45c2651c35f743ef16e20b0c45.tar.bz2
pianobar-windows-455fb16d627e1f45c2651c35f743ef16e20b0c45.zip
client: Let user decide when song is submitted to last.fm
-rw-r--r--src/main.c3
-rw-r--r--src/pianobar.15
-rw-r--r--src/settings.c10
-rw-r--r--src/settings.h1
4 files changed, 18 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index f08adeb..0b8b4e0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -264,7 +264,8 @@ int main (int argc, char **argv) {
/* scrobble when >= 90% are played */
if (BarSamplesToSeconds (player.samplerate,
player.channels, player.sampleSizeCurr) * 100 /
- scrobbleSong.length >= 90 &&
+ scrobbleSong.length >=
+ bsettings.lastfmScrobblePercent &&
bsettings.enableScrobbling) {
if (WardrobeSubmit (&wh, &scrobbleSong) ==
WARDROBE_RET_OK) {
diff --git a/src/pianobar.1 b/src/pianobar.1
index c17a3c3..6201d8c 100644
--- a/src/pianobar.1
+++ b/src/pianobar.1
@@ -96,6 +96,11 @@ username.
A password is needed too if you want to scrobble your played song.
.TP
+.B lastfm_scrobble_percent = 50-100
+When should a track be submitted to last.fm. Percent value. Don't append
+percent sign.
+
+.TP
.B password = plaintext_password
Your pandora.com password. Plain-text.
diff --git a/src/settings.c b/src/settings.c
index 91cd851..3a0ed4a 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -111,8 +111,18 @@ void BarSettingsRead (BarSettings_t *settings) {
settings->lastfmUser = strdup (val);
} else if (strcmp ("lastfm_password", key) == 0) {
settings->lastfmPassword = strdup (val);
+ } else if (strcmp ("lastfm_scrobble_percent", key) == 0) {
+ settings->lastfmScrobblePercent = atoi (val);
}
}
+
+ /* some checks */
+ /* last.fm requests tracks to be played at least 50% */
+ if (settings->lastfmScrobblePercent < 50 ||
+ settings->lastfmScrobblePercent > 100) {
+ settings->lastfmScrobblePercent = 50;
+ }
+ /* only scrobble tracks if username and password are set */
if (settings->lastfmUser != NULL && settings->lastfmPassword != NULL) {
settings->enableScrobbling = 1;
}
diff --git a/src/settings.h b/src/settings.h
index 2a6d8c3..b3604fa 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -32,6 +32,7 @@ struct BarSettings {
curl_proxytype controlProxyType;
char *lastfmUser;
char *lastfmPassword;
+ unsigned char lastfmScrobblePercent;
char enableScrobbling;
};