diff options
author | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-07-18 12:17:55 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-07-18 12:17:55 +0200 |
commit | 4887e066d00e33f706ae07518ed6faf2d2a62fc8 (patch) | |
tree | b8d6d589a52435c6570d90e4d189080bcec1abad /src | |
parent | 71064f98988a490ae972e36533d6af05557ed3c1 (diff) | |
download | pianobar-4887e066d00e33f706ae07518ed6faf2d2a62fc8.tar.gz pianobar-4887e066d00e33f706ae07518ed6faf2d2a62fc8.tar.bz2 pianobar-4887e066d00e33f706ae07518ed6faf2d2a62fc8.zip |
Initial support for adding genre stations
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 70 | ||||
-rw-r--r-- | src/pianobar.1 | 4 |
2 files changed, 74 insertions, 0 deletions
@@ -216,6 +216,71 @@ inline void BarUiMsg (char *msg) { fflush (stdout); } +/* browse genre stations and create shared station + * @param piano handle + */ +void BarStationFromGenre (PianoHandle_t *ph) { + int i; + PianoGenreCategory_t *curCat; + PianoStation_t *curStation; + + /* receive genre stations list if not yet available */ + if (ph->genreStations == NULL) { + BarUiMsg ("Receiving genre stations... "); + if (PianoGetGenreStations (ph) != PIANO_RET_OK) { + BarUiMsg ("Error.\n"); + return; + } else { + BarUiMsg ("Ok.\n"); + } + } + + /* print all available categories */ + curCat = ph->genreStations; + i = 0; + while (curCat != NULL) { + printf ("%2i) %s\n", i, curCat->name); + i++; + curCat = curCat->next; + } + /* select category or exit */ + if (!BarReadlineInt (NULL, &i)) { + BarUiMsg ("Aborted.\n"); + return; + } + curCat = ph->genreStations; + while (curCat != NULL && i > 0) { + curCat = curCat->next; + i--; + } + + /* print all available stations */ + curStation = curCat->stations; + i = 0; + while (curStation != NULL) { + printf ("%2i) %s\n", i, curStation->name); + i++; + curStation = curStation->next; + } + if (!BarReadlineInt (NULL, &i)) { + BarUiMsg ("Aborted.\n"); + return; + } + curStation = curCat->stations; + while (curStation != NULL && i > 0) { + curStation = curStation->next; + i--; + } + /* create station */ + printf ("Adding shared station \"%s\"... ", curStation->name); + fflush (stdout); + if (PianoCreateStation (ph, "sh", curStation->id) != PIANO_RET_OK) { + BarUiMsg ("Error.\n"); + } else { + BarUiMsg ("Ok.\n"); + } +} + int main (int argc, char **argv) { PianoHandle_t ph; struct aacPlayer player; @@ -466,6 +531,11 @@ int main (int argc, char **argv) { } break; + case 'g': + /* use genre station */ + BarStationFromGenre (&ph); + break; + case 'l': if (curStation == NULL || curSong == NULL) { BarUiMsg ("No song playing.\n"); diff --git a/src/pianobar.1 b/src/pianobar.1 index 500b7ae..5cf9983 100644 --- a/src/pianobar.1 +++ b/src/pianobar.1 @@ -35,6 +35,10 @@ artist of your choice. Delete current station. .TP +.B g +Add genre station provided by pandora. + +.TP .B l Love currently played song. |