summaryrefslogtreecommitdiff
path: root/libpiano/src/main.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-12 22:36:48 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-12 22:36:48 +0200
commitbfda4e40cce3aa986e4fe8d3881a689cd6ef411f (patch)
tree561b24a1e4f3d54f0cc30c4160322e7a9c4bf74d /libpiano/src/main.c
parent4878f5911d05af7bfa1917daf984dab0fd07eb42 (diff)
downloadpianobar-bfda4e40cce3aa986e4fe8d3881a689cd6ef411f.tar.gz
pianobar-bfda4e40cce3aa986e4fe8d3881a689cd6ef411f.tar.bz2
pianobar-bfda4e40cce3aa986e4fe8d3881a689cd6ef411f.zip
Initial "narrative" implementation
"Why did you play this song?"
Diffstat (limited to 'libpiano/src/main.c')
-rw-r--r--libpiano/src/main.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libpiano/src/main.c b/libpiano/src/main.c
index 7887132..2b51303 100644
--- a/libpiano/src/main.c
+++ b/libpiano/src/main.c
@@ -779,6 +779,37 @@ PianoReturn_t PianoTransformShared (PianoHandle_t *ph,
return ret;
}
+PianoReturn_t PianoExplain (const PianoHandle_t *ph, const PianoSong_t *song,
+ char **retExplain) {
+ char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], url[PIANO_URL_BUFFER_SIZE];
+ char *requestStr, *retStr;
+ PianoReturn_t ret;
+
+ snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>"
+ "<methodCall><methodName>playlist.narrative</methodName>"
+ "<params><param><value><int>%li</int></value></param>"
+ "<param><value><string>%s</string></value></param>"
+ "<param><value><string>%s</string></value></param>"
+ "<param><value><string>%s</string></value></param>"
+ "</params></methodCall>", time (NULL), ph->user.authToken,
+ song->stationId, song->musicId);
+ requestStr = PianoEncryptString (xmlSendBuf);
+
+ snprintf (url, sizeof (url), PIANO_RPC_URL "rid=%s&lid=%s&"
+ "method=method=narrative&arg1=%s&arg2=%s", ph->routeId,
+ ph->user.listenerId, song->stationId, song->musicId);
+
+ if ((ret = PianoHttpPost (ph->curlHandle, url, requestStr, &retStr)) ==
+ PIANO_RET_OK) {
+ ret = PianoXmlParseNarrative (retStr, retExplain);
+ PianoFree (retStr, 0);
+ }
+
+ PianoFree (requestStr, 0);
+
+ return ret;
+}
+
/* convert return value to human-readable string
* @param enum
* @return error string