diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2017-09-30 17:06:41 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2017-09-30 17:06:41 +0200 |
commit | 41a00cc1e643d9e9a69991ead268777ecd17c154 (patch) | |
tree | 83df94f477f8ca5380ff10a2843d3cc9b92508e6 | |
parent | d9cdc86e4b84be863099f8cadfc54a176aaf5c90 (diff) | |
download | pianobar-41a00cc1e643d9e9a69991ead268777ecd17c154.tar.gz pianobar-41a00cc1e643d9e9a69991ead268777ecd17c154.tar.bz2 pianobar-41a00cc1e643d9e9a69991ead268777ecd17c154.zip |
Add tired rating to song
Now we can show a tired icon in the history.
Closes #637.
-rw-r--r-- | contrib/config-example | 6 | ||||
-rw-r--r-- | contrib/pianobar.1 | 10 | ||||
-rw-r--r-- | src/libpiano/piano.h | 3 | ||||
-rw-r--r-- | src/libpiano/request.c | 3 | ||||
-rw-r--r-- | src/libpiano/response.c | 7 | ||||
-rw-r--r-- | src/settings.c | 5 | ||||
-rw-r--r-- | src/settings.h | 3 | ||||
-rw-r--r-- | src/ui.c | 22 |
8 files changed, 46 insertions, 13 deletions
diff --git a/contrib/config-example b/contrib/config-example index 0a69526..6a40937 100644 --- a/contrib/config-example +++ b/contrib/config-example @@ -46,14 +46,16 @@ #event_command = /home/user/.config/pianobar/eventcmd #fifo = /tmp/pianobar #sort = quickmix_10_name_az -#love_icon = [+] -#ban_icon = [-] #volume = 0 #ca_bundle = /etc/ssl/certs/ca-certificates.crt #gain_mul = 1.0 # Format strings #format_nowplaying_song = [32m%t[0m by [34m%a[0m on %l[31m%r[0m%@%s +#format_nowplaying_song = [32m%t[0m by [34m%a[0m on %l%r%@%s +#ban_icon = [32m</3[0m +#love_icon = [31m<3[0m +#tired_icon = [33mzZ[0m #format_nowplaying_station = Station [35m%n[0m #format_list_song = %i) %a - %t%r diff --git a/contrib/pianobar.1 b/contrib/pianobar.1 index 6aee0b6..512c55a 100644 --- a/contrib/pianobar.1 +++ b/contrib/pianobar.1 @@ -194,7 +194,7 @@ or the key you defined in .B act_songinfo. .TP -.B ban_icon = </3 +.B ban_icon = </3 Icon for banned songs. .TP @@ -288,7 +288,7 @@ Song artist Album name .B %r -Rating icon (only love icon) +Rating icon .B %@ .B at_icon @@ -321,7 +321,7 @@ of gain adjustment. Keep a history of the last n songs (5, by default). You can rate these songs. .TP -.B love_icon = <3 +.B love_icon = <3 Icon for loved songs. .TP @@ -362,6 +362,10 @@ sorts by name from a to z, quickmix_01_name_za by type (quickmix at the bottom) and name from z to a. .TP +.B tired_icon = zZ +Icon for temporarily suspended songs. + +.TP .B user = your@user.name Your pandora.com username. diff --git a/src/libpiano/piano.h b/src/libpiano/piano.h index 7f31397..0ec6c49 100644 --- a/src/libpiano/piano.h +++ b/src/libpiano/piano.h @@ -65,7 +65,8 @@ typedef struct PianoStation { typedef enum { PIANO_RATE_NONE = 0, PIANO_RATE_LOVE = 1, - PIANO_RATE_BAN = 2 + PIANO_RATE_BAN = 2, + PIANO_RATE_TIRED = 3, } PianoSongRating_t; /* UNKNOWN should be 0, because memset sets audio format to 0 */ diff --git a/src/libpiano/request.c b/src/libpiano/request.c index 02b4b43..66c34d7 100644 --- a/src/libpiano/request.c +++ b/src/libpiano/request.c @@ -146,7 +146,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, assert (reqData != NULL); assert (reqData->trackToken != NULL); assert (reqData->stationId != NULL); - assert (reqData->rating != PIANO_RATE_NONE); + assert (reqData->rating != PIANO_RATE_NONE && + reqData->rating != PIANO_RATE_TIRED); json_object_object_add (j, "stationToken", json_object_new_string (reqData->stationId)); diff --git a/src/libpiano/response.c b/src/libpiano/response.c index 0e8c783..fd342ed 100644 --- a/src/libpiano/response.c +++ b/src/libpiano/response.c @@ -436,8 +436,13 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { break; } + case PIANO_REQUEST_ADD_TIRED_SONG: { + PianoSong_t * const song = req->data; + song->rating = PIANO_RATE_TIRED; + break; + } + case PIANO_REQUEST_ADD_SEED: - case PIANO_REQUEST_ADD_TIRED_SONG: case PIANO_REQUEST_SET_QUICKMIX: case PIANO_REQUEST_BOOKMARK_SONG: case PIANO_REQUEST_BOOKMARK_ARTIST: diff --git a/src/settings.c b/src/settings.c index 9dababc..9f05adc 100644 --- a/src/settings.c +++ b/src/settings.c @@ -119,6 +119,7 @@ void BarSettingsDestroy (BarSettings_t *settings) { free (settings->eventCmd); free (settings->loveIcon); free (settings->banIcon); + free (settings->tiredIcon); free (settings->atIcon); free (settings->npSongFormat); free (settings->npStationFormat); @@ -165,6 +166,7 @@ void BarSettingsRead (BarSettings_t *settings) { settings->sortOrder = BAR_SORT_NAME_AZ; settings->loveIcon = strdup (" <3"); settings->banIcon = strdup (" </3"); + settings->tiredIcon = strdup (" zZ"); settings->atIcon = strdup (" @ "); settings->npSongFormat = strdup ("\"%t\" by \"%a\" on \"%l\"%r%@%s"); settings->npStationFormat = strdup ("Station \"%n\" (%i)"); @@ -358,6 +360,9 @@ void BarSettingsRead (BarSettings_t *settings) { } else if (streq ("ban_icon", key)) { free (settings->banIcon); settings->banIcon = strdup (val); + } else if (streq ("tired_icon", key)) { + free (settings->tiredIcon); + settings->tiredIcon = strdup (val); } else if (streq ("at_icon", key)) { free (settings->atIcon); settings->atIcon = strdup (val); diff --git a/src/settings.h b/src/settings.h index 083e610..b70e4f9 100644 --- a/src/settings.h +++ b/src/settings.h @@ -96,8 +96,7 @@ typedef struct { char *bindTo; char *autostartStation; char *eventCmd; - char *loveIcon; - char *banIcon; + char *loveIcon, *banIcon, *tiredIcon; char *atIcon; char *npSongFormat; char *npStationFormat; @@ -714,6 +714,23 @@ void BarUiPrintStation (const BarSettings_t *settings, BarUiMsg (settings, MSG_PLAYING, "%s", outstr); } +static const char *ratingToIcon (const BarSettings_t * const settings, + const PianoSong_t * const song) { + switch (song->rating) { + case PIANO_RATE_LOVE: + return settings->loveIcon; + + case PIANO_RATE_BAN: + return settings->banIcon; + + case PIANO_RATE_TIRED: + return settings->tiredIcon; + + default: + return ""; + } +} + /* Print song infos (artist, title, album, loved) * @param pianobar settings * @param the song @@ -723,7 +740,7 @@ void BarUiPrintSong (const BarSettings_t *settings, const PianoSong_t *song, const PianoStation_t *station) { char outstr[512]; const char *vals[] = {song->title, song->artist, song->album, - (song->rating == PIANO_RATE_LOVE) ? settings->loveIcon : "", + ratingToIcon (settings, song), station != NULL ? settings->atIcon : "", station != NULL ? station->name : "", song->detailUrl}; @@ -750,8 +767,7 @@ size_t BarUiListSongs (const BarSettings_t *settings, BarStrCaseStr (song->title, filter) != NULL))) { char outstr[512], digits[8], duration[8] = "??:??"; const char *vals[] = {digits, song->artist, song->title, - (song->rating == PIANO_RATE_LOVE) ? settings->loveIcon : - ((song->rating == PIANO_RATE_BAN) ? settings->banIcon : ""), + ratingToIcon (settings, song), duration}; /* pre-format a few strings */ |