From 455fb16d627e1f45c2651c35f743ef16e20b0c45 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 23 Jun 2008 22:08:18 +0200 Subject: client: Let user decide when song is submitted to last.fm --- src/main.c | 3 ++- src/pianobar.1 | 5 +++++ src/settings.c | 10 ++++++++++ src/settings.h | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src') 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 @@ -95,6 +95,11 @@ username. .B lastfm_password = plain_password 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; }; -- cgit v1.2.3