summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-04-03 17:09:03 +0200
committerLars-Dominik Braun <lars@6xq.net>2011-04-04 10:20:56 +0200
commitd6bdaaa776b38451d70cef6e77976fd0f3765583 (patch)
treeb24b34274bc3dd0ddf592f54cffc49dc3cd71e28
parenta04409f1061c23409f73d3be9ca31a364645b215 (diff)
downloadpianobar-windows-d6bdaaa776b38451d70cef6e77976fd0f3765583.tar.gz
pianobar-windows-d6bdaaa776b38451d70cef6e77976fd0f3765583.tar.bz2
pianobar-windows-d6bdaaa776b38451d70cef6e77976fd0f3765583.zip
Expose songDetailUrl to eventcmd script
See #99.
-rw-r--r--src/ui.c82
-rw-r--r--src/ui_act.c2
2 files changed, 45 insertions, 39 deletions
diff --git a/src/ui.c b/src/ui.c
index 7372384..f9ed975 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -680,50 +680,13 @@ void BarUiStartEventCmd (const BarSettings_t *settings, const char *type,
const struct audioPlayer *player, PianoStation_t *stations,
PianoReturn_t pRet, WaitressReturn_t wRet) {
pid_t chld;
- char pipeBuf[1024];
int pipeFd[2];
- PianoStation_t *songStation = NULL;
if (settings->eventCmd == NULL) {
/* nothing to do... */
return;
}
- if (curSong != NULL && stations != NULL && curStation->isQuickMix) {
- songStation = PianoFindStationById (stations, curSong->stationId);
- }
-
- /* prepare stdin content */
- memset (pipeBuf, 0, sizeof (pipeBuf));
- snprintf (pipeBuf, sizeof (pipeBuf),
- "artist=%s\n"
- "title=%s\n"
- "album=%s\n"
- "coverArt=%s\n"
- "stationName=%s\n"
- "songStationName=%s\n"
- "pRet=%i\n"
- "pRetStr=%s\n"
- "wRet=%i\n"
- "wRetStr=%s\n"
- "songDuration=%lu\n"
- "songPlayed=%lu\n"
- "rating=%i\n",
- curSong == NULL ? "" : curSong->artist,
- curSong == NULL ? "" : curSong->title,
- curSong == NULL ? "" : curSong->album,
- curSong == NULL ? "" : curSong->coverArt,
- curStation == NULL ? "" : curStation->name,
- songStation == NULL ? "" : songStation->name,
- pRet,
- PianoErrorToStr (pRet),
- wRet,
- WaitressErrorToStr (wRet),
- player->songDuration,
- player->songPlayed,
- curSong == NULL ? PIANO_RATE_NONE : curSong->rating
- );
-
if (pipe (pipeFd) == -1) {
BarUiMsg (MSG_ERR, "Cannot create eventcmd pipe. (%s)\n", strerror (errno));
return;
@@ -742,8 +705,48 @@ void BarUiStartEventCmd (const BarSettings_t *settings, const char *type,
BarUiMsg (MSG_ERR, "Cannot fork eventcmd. (%s)\n", strerror (errno));
} else {
/* parent */
- int status;
+ int status, printfret;
+ char pipeBuf[1024];
+ PianoStation_t *songStation = NULL;
+
close (pipeFd[0]);
+
+ if (curSong != NULL && stations != NULL && curStation->isQuickMix) {
+ songStation = PianoFindStationById (stations, curSong->stationId);
+ }
+
+ printfret = snprintf (pipeBuf, sizeof (pipeBuf),
+ "artist=%s\n"
+ "title=%s\n"
+ "album=%s\n"
+ "coverArt=%s\n"
+ "stationName=%s\n"
+ "songStationName=%s\n"
+ "pRet=%i\n"
+ "pRetStr=%s\n"
+ "wRet=%i\n"
+ "wRetStr=%s\n"
+ "songDuration=%lu\n"
+ "songPlayed=%lu\n"
+ "rating=%i\n"
+ "detailUrl=%s\n",
+ curSong == NULL ? "" : curSong->artist,
+ curSong == NULL ? "" : curSong->title,
+ curSong == NULL ? "" : curSong->album,
+ curSong == NULL ? "" : curSong->coverArt,
+ curStation == NULL ? "" : curStation->name,
+ songStation == NULL ? "" : songStation->name,
+ pRet,
+ PianoErrorToStr (pRet),
+ wRet,
+ WaitressErrorToStr (wRet),
+ player->songDuration,
+ player->songPlayed,
+ curSong == NULL ? PIANO_RATE_NONE : curSong->rating,
+ curSong == NULL ? "" : curSong->detailUrl
+ );
+ assert (printfret < sizeof (pipeBuf));
+
write (pipeFd[1], pipeBuf, strlen (pipeBuf));
if (stations != NULL) {
@@ -759,8 +762,9 @@ void BarUiStartEventCmd (const BarSettings_t *settings, const char *type,
for (size_t i = 0; i < stationCount; i++) {
const PianoStation_t *currStation = sortedStations[i];
- snprintf (pipeBuf, sizeof (pipeBuf), "station%zd=%s\n", i,
+ printfret = snprintf (pipeBuf, sizeof (pipeBuf), "station%zd=%s\n", i,
currStation->name);
+ assert (printfret < sizeof (pipeBuf));
write (pipeFd[1], pipeBuf, strlen (pipeBuf));
}
free (sortedStations);
diff --git a/src/ui_act.c b/src/ui_act.c
index 67fc0ca..9a8f67b 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -251,6 +251,7 @@ BarUiActCallback(BarUiActDebug) {
"audioFormat:\t%i\n"
"audioUrl:\t%s\n"
"coverArt:\t%s\n"
+ "detailUrl:\t%s\n"
"fileGain:\t%f\n"
"musicId:\t%s\n"
"rating:\t%i\n"
@@ -264,6 +265,7 @@ BarUiActCallback(BarUiActDebug) {
selSong->audioFormat,
selSong->audioUrl,
selSong->coverArt,
+ selSong->detailUrl,
selSong->fileGain,
selSong->musicId,
selSong->rating,