diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-08-07 13:20:45 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-08-07 13:20:45 +0200 |
commit | 6a9579be3afecaae2f62baacca10335de1371cf1 (patch) | |
tree | b4937510e443d5c8aa41e63a93f4860a1668e8e4 /src/ui.c | |
parent | fcb0130deaf8483fa130a3af7a2bb3451c2206a9 (diff) | |
download | pianobar-6a9579be3afecaae2f62baacca10335de1371cf1.tar.gz pianobar-6a9579be3afecaae2f62baacca10335de1371cf1.tar.bz2 pianobar-6a9579be3afecaae2f62baacca10335de1371cf1.zip |
New feature: Seed suggestions
Diffstat (limited to 'src/ui.c')
-rw-r--r-- | src/ui.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -239,9 +239,11 @@ PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist, FILE *curFd) { /* search music: query, search request, return music id * @param piano handle + * @param read data from fd + * @param allow seed suggestions if != NULL * @return musicId or NULL on abort/error */ -char *BarUiSelectMusicId (PianoHandle_t *ph, FILE *curFd) { +char *BarUiSelectMusicId (PianoHandle_t *ph, FILE *curFd, char *similarToId) { char *musicId = NULL; char lineBuf[100], selectBuf[2]; PianoSearchResult_t searchResult; @@ -250,10 +252,18 @@ char *BarUiSelectMusicId (PianoHandle_t *ph, FILE *curFd) { BarUiMsg (MSG_QUESTION, "Search for artist/title: "); if (BarReadlineStr (lineBuf, sizeof (lineBuf), 0, curFd) > 0) { - BarUiMsg (MSG_INFO, "Searching... "); - if (BarUiPrintPianoStatus (PianoSearchMusic (ph, lineBuf, - &searchResult)) != PIANO_RET_OK) { - return NULL; + if (strcmp ("?", lineBuf) == 0 && similarToId != NULL) { + BarUiMsg (MSG_INFO, "Receiving suggestions... "); + if (BarUiPrintPianoStatus (PianoSeedSuggestions (ph, similarToId, + 20, &searchResult)) != PIANO_RET_OK) { + return NULL; + } + } else { + BarUiMsg (MSG_INFO, "Searching... "); + if (BarUiPrintPianoStatus (PianoSearchMusic (ph, lineBuf, + &searchResult)) != PIANO_RET_OK) { + return NULL; + } } BarUiMsg (MSG_NONE, "\r"); if (searchResult.songs != NULL && searchResult.artists != NULL) { |