summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-09-22 12:22:14 +0200
committerLars-Dominik Braun <lars@6xq.net>2011-09-22 12:24:59 +0200
commit349bb987049eac94867c6a556449b57ca4674546 (patch)
tree243ef5fcda1fa3a909fb424d525104b9d29212a4 /src
parent17825f0bca1d946df98e952db16e9480bb6699d8 (diff)
downloadpianobar-windows-349bb987049eac94867c6a556449b57ca4674546.tar.gz
pianobar-windows-349bb987049eac94867c6a556449b57ca4674546.tar.bz2
pianobar-windows-349bb987049eac94867c6a556449b57ca4674546.zip
piano: Protocol version bump (v32)
Keys stay the same. Quickmix and seed suggestion API calls changed. Listener id is not part of the url any more. Bookmark API calls seem to be deprecated.
Diffstat (limited to 'src')
-rw-r--r--src/libpiano/piano.c94
-rw-r--r--src/libpiano/piano.h2
-rw-r--r--src/libpiano/xml.c2
-rw-r--r--src/ui.c12
-rw-r--r--src/ui.h2
-rw-r--r--src/ui_act.c6
6 files changed, 59 insertions, 59 deletions
diff --git a/src/libpiano/piano.c b/src/libpiano/piano.c
index addb988..d6071f2 100644
--- a/src/libpiano/piano.c
+++ b/src/libpiano/piano.c
@@ -42,7 +42,7 @@ THE SOFTWARE.
#include "crypt.h"
#include "config.h"
-#define PIANO_PROTOCOL_VERSION "31"
+#define PIANO_PROTOCOL_VERSION "32"
#define PIANO_RPC_HOST "www.pandora.com"
#define PIANO_RPC_PORT "80"
#define PIANO_RPC_PATH "/radio/xmlrpc/v" PIANO_PROTOCOL_VERSION "?"
@@ -163,7 +163,6 @@ void PianoDestroyGenres (PianoGenre_t *genres) {
void PianoDestroyUserInfo (PianoUserInfo_t *user) {
free (user->webAuthToken);
free (user->authToken);
- free (user->listenerId);
}
/* frees the whole piano handle structure
@@ -281,8 +280,6 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
case PIANO_REQUEST_GET_STATIONS:
/* get stations, user must be authenticated */
- assert (ph->user.listenerId != NULL);
-
snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>"
"<methodCall><methodName>station.getStations</methodName>"
"<params><param><value><int>%lu</int></value></param>"
@@ -290,8 +287,7 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=getStations", ph->routeId,
- ph->user.listenerId);
+ "rid=%s&method=getStations", ph->routeId);
break;
case PIANO_REQUEST_GET_PLAYLIST: {
@@ -326,10 +322,10 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
ph->user.authToken, reqData->station->id,
PianoAudioFormatToString (reqData->format));
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=getFragment&arg1=%s&arg2=0"
+ "rid=%s&method=getFragment&arg1=%s&arg2=0"
"&arg3=&arg4=&arg5=%s&arg6=0&arg7=0", ph->routeId,
- ph->user.listenerId, reqData->station->id,
- PianoAudioFormatToString (reqData->format));
+ reqData->station->id, PianoAudioFormatToString
+ (reqData->format));
break;
}
@@ -368,9 +364,9 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
(reqData->rating == PIANO_RATE_LOVE) ? 1 : 0,
reqData->songType);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=addFeedback&arg1=%s&arg2=%s"
+ "rid=%s&method=addFeedback&arg1=%s&arg2=%s"
"&arg3=%s&arg4=%u&arg5=%s&arg6=false&arg7=%u",
- ph->routeId, ph->user.listenerId, reqData->stationId,
+ ph->routeId, reqData->stationId,
reqData->musicId,
(reqData->userSeed == NULL) ? "" : reqData->userSeed,
reqData->testStrategy,
@@ -406,9 +402,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
ph->user.authToken, reqData->station->id,
xmlencodedNewName);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=setStationName&arg1=%s&arg2=%s",
- ph->routeId, ph->user.listenerId, reqData->station->id,
- urlencodedNewName);
+ "rid=%s&method=setStationName&arg1=%s&arg2=%s",
+ ph->routeId, reqData->station->id, urlencodedNewName);
free (urlencodedNewName);
free (xmlencodedNewName);
@@ -431,8 +426,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken, station->id);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=removeStation&arg1=%s", ph->routeId,
- ph->user.listenerId, station->id);
+ "rid=%s&method=removeStation&arg1=%s", ph->routeId,
+ station->id);
break;
}
@@ -459,8 +454,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken, xmlencodedSearchStr);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=search&arg1=%s", ph->routeId,
- ph->user.listenerId, urlencodedSearchStr);
+ "rid=%s&method=search&arg1=%s", ph->routeId,
+ urlencodedSearchStr);
free (urlencodedSearchStr);
free (xmlencodedSearchStr);
@@ -489,8 +484,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
ph->user.authToken, reqData->type, reqData->id);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=createStation&arg1=%s%s&arg2=", ph->routeId,
- ph->user.listenerId, reqData->type, reqData->id);
+ "rid=%s&method=createStation&arg1=%s%s&arg2=", ph->routeId,
+ reqData->type, reqData->id);
break;
}
@@ -514,8 +509,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken, reqData->station->id, reqData->musicId);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=addSeed&arg1=%s&arg2=%s", ph->routeId,
- ph->user.listenerId, reqData->station->id, reqData->musicId);
+ "rid=%s&method=addSeed&arg1=%s&arg2=%s", ph->routeId,
+ reqData->station->id, reqData->musicId);
break;
}
@@ -541,8 +536,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
(song->userSeed == NULL) ? "" : song->userSeed,
song->stationId);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=addTiredSong&arg1=%s&arg2=%s&arg3=%s",
- ph->routeId, ph->user.listenerId,
+ "rid=%s&method=addTiredSong&arg1=%s&arg2=%s&arg3=%s",
+ ph->routeId,
(song->musicId == NULL) ? "" : song->musicId,
(song->userSeed == NULL) ? "" : song->userSeed,
song->stationId);
@@ -587,16 +582,16 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
}
strncat (xmlSendBuf,
"</data></array></value></param>"
- /* content type */
- "<param><value><string>CUSTOM</string></value></param>"
- /* genre */
+ /* empty */
+ "<param><value><string></string></value></param>"
+ /* empty */
"<param><value><string></string></value></param>"
"</params></methodCall>",
sizeof (xmlSendBuf) - strlen (xmlSendBuf) - 1);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=setQuickMix&arg1=RANDOM&arg2=%s&arg3=CUSTOM&arg4=",
- ph->routeId, ph->user.listenerId, urlArgBuf);
+ "rid=%s&method=setQuickMix&arg1=RANDOM&arg2=%s&arg3=&arg4=",
+ ph->routeId, urlArgBuf);
break;
}
@@ -623,8 +618,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken, station->id);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=transformShared&arg1=%s", ph->routeId,
- ph->user.listenerId, station->id);
+ "rid=%s&method=transformShared&arg1=%s", ph->routeId,
+ station->id);
break;
}
@@ -648,8 +643,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
ph->user.authToken, reqData->song->stationId,
reqData->song->musicId);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=narrative&arg1=%s&arg2=%s",
- ph->routeId, ph->user.listenerId, reqData->song->stationId,
+ "rid=%s&method=narrative&arg1=%s&arg2=%s",
+ ph->routeId, reqData->song->stationId,
reqData->song->musicId);
break;
}
@@ -667,15 +662,19 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"<params><param><value><int>%lu</int></value></param>"
/* auth token */
"<param><value><string>%s</string></value></param>"
+ /* station id */
+ "<param><value><string>%s</string></value></param>"
/* seed music id */
"<param><value><string>%s</string></value></param>"
/* max */
"<param><value><int>%u</int></value></param>"
"</params></methodCall>", (unsigned long) timestamp,
- ph->user.authToken, reqData->musicId, reqData->max);
+ ph->user.authToken, reqData->station->id, reqData->musicId,
+ reqData->max);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=getSeedSuggestions&arg1=%s&arg2=%u",
- ph->routeId, ph->user.listenerId, reqData->musicId, reqData->max);
+ "rid=%s&method=getSeedSuggestions&arg1=%s&arg2=%s&arg3=%u",
+ ph->routeId, reqData->station->id, reqData->musicId,
+ reqData->max);
break;
}
@@ -697,9 +696,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken, song->stationId, song->musicId);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=createBookmark&arg1=%s&arg2=%s",
- ph->routeId, ph->user.listenerId, song->stationId,
- song->musicId);
+ "rid=%s&method=createBookmark&arg1=%s&arg2=%s",
+ ph->routeId, song->stationId, song->musicId);
break;
}
@@ -719,8 +717,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken, song->artistMusicId);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=createArtistBookmark&arg1=%s",
- ph->routeId, ph->user.listenerId, song->artistMusicId);
+ "rid=%s&method=createArtistBookmark&arg1=%s",
+ ph->routeId, song->artistMusicId);
break;
}
@@ -741,8 +739,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken, reqData->station->id);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=getStation&arg1=%s",
- ph->routeId, ph->user.listenerId, reqData->station->id);
+ "rid=%s&method=getStation&arg1=%s",
+ ph->routeId, reqData->station->id);
break;
}
@@ -761,8 +759,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken, song->feedbackId);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=deleteFeedback&arg1=%s",
- ph->routeId, ph->user.listenerId, song->feedbackId);
+ "rid=%s&method=deleteFeedback&arg1=%s",
+ ph->routeId, song->feedbackId);
break;
}
@@ -791,8 +789,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
"</params></methodCall>", (unsigned long) timestamp,
ph->user.authToken, seedId);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
- "rid=%s&lid=%s&method=deleteSeed&arg1=%s",
- ph->routeId, ph->user.listenerId, seedId);
+ "rid=%s&method=deleteSeed&arg1=%s",
+ ph->routeId, seedId);
break;
}
@@ -925,7 +923,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) {
case 1:
/* information exists when reauthenticating, destroy to
* avoid memleak */
- if (ph->user.listenerId != NULL) {
+ if (ph->user.authToken != NULL) {
PianoDestroyUserInfo (&ph->user);
}
ret = PianoXmlParseUserinfo (ph, req->responseData);
diff --git a/src/libpiano/piano.h b/src/libpiano/piano.h
index 54eab3a..7b692c6 100644
--- a/src/libpiano/piano.h
+++ b/src/libpiano/piano.h
@@ -34,7 +34,6 @@ THE SOFTWARE.
typedef struct PianoUserInfo {
char *webAuthToken;
- char *listenerId;
char *authToken;
} PianoUserInfo_t;
@@ -217,6 +216,7 @@ typedef struct {
} PianoRequestDataExplain_t;
typedef struct {
+ PianoStation_t *station;
char *musicId;
unsigned short max;
PianoSearchResult_t searchResult;
diff --git a/src/libpiano/xml.c b/src/libpiano/xml.c
index a8dd576..7f21f8d 100644
--- a/src/libpiano/xml.c
+++ b/src/libpiano/xml.c
@@ -216,8 +216,6 @@ static void PianoXmlParseUserinfoCb (const char *key, const ezxml_t value,
user->webAuthToken = strdup (valueStr);
} else if (strcmp ("authToken", key) == 0) {
user->authToken = strdup (valueStr);
- } else if (strcmp ("listenerId", key) == 0) {
- user->listenerId = strdup (valueStr);
}
}
diff --git a/src/ui.c b/src/ui.c
index 0f74c2b..dc2acb3 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -466,11 +466,13 @@ PianoArtist_t *BarUiSelectArtist (BarApp_t *app, PianoArtist_t *startArtist) {
/* search music: query, search request, return music id
* @param app handle
- * @param allow seed suggestions if != NULL
+ * @param seed suggestion station
+ * @param seed suggestion musicid
* @param prompt string
* @return musicId or NULL on abort/error
*/
-char *BarUiSelectMusicId (BarApp_t *app, char *similarToId, const char *msg) {
+char *BarUiSelectMusicId (BarApp_t *app, PianoStation_t *station,
+ PianoSong_t *similarSong, const char *msg) {
char *musicId = NULL;
char lineBuf[100], selectBuf[2];
PianoSearchResult_t searchResult;
@@ -480,12 +482,14 @@ char *BarUiSelectMusicId (BarApp_t *app, char *similarToId, const char *msg) {
BarUiMsg (&app->settings, MSG_QUESTION, msg);
if (BarReadlineStr (lineBuf, sizeof (lineBuf), &app->input,
BAR_RL_DEFAULT) > 0) {
- if (strcmp ("?", lineBuf) == 0 && similarToId != NULL) {
+ if (strcmp ("?", lineBuf) == 0 && station != NULL &&
+ similarSong != NULL) {
PianoReturn_t pRet;
WaitressReturn_t wRet;
PianoRequestDataGetSeedSuggestions_t reqData;
- reqData.musicId = similarToId;
+ reqData.station = station;
+ reqData.musicId = similarSong->musicId;
reqData.max = 20;
BarUiMsg (&app->settings, MSG_INFO, "Receiving suggestions... ");
diff --git a/src/ui.h b/src/ui.h
index db90646..64899ef 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -40,7 +40,7 @@ PianoStation_t *BarUiSelectStation (BarApp_t *, const char *, BarUiSelectStation
PianoSong_t *BarUiSelectSong (const BarSettings_t *, PianoSong_t *,
BarReadlineFds_t *);
PianoArtist_t *BarUiSelectArtist (BarApp_t *, PianoArtist_t *);
-char *BarUiSelectMusicId (BarApp_t *, char *, const char *);
+char *BarUiSelectMusicId (BarApp_t *, PianoStation_t *, PianoSong_t *, const char *);
void BarStationFromGenre (BarApp_t *);
void BarUiPrintStation (const BarSettings_t *, PianoStation_t *);
void BarUiPrintSong (const BarSettings_t *, const PianoSong_t *,
diff --git a/src/ui_act.c b/src/ui_act.c
index 6bdecf4..c1e7cb7 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -98,8 +98,8 @@ BarUiActCallback(BarUiActAddMusic) {
assert (selStation != NULL);
- reqData.musicId = BarUiSelectMusicId (app, app->playlist->musicId,
- "Add artist or title to station: ");
+ reqData.musicId = BarUiSelectMusicId (app, selStation,
+ selSong, "Add artist or title to station: ");
if (reqData.musicId != NULL) {
if (!BarTransformIfShared (app, selStation)) {
return;
@@ -147,7 +147,7 @@ BarUiActCallback(BarUiActCreateStation) {
WaitressReturn_t wRet;
PianoRequestDataCreateStation_t reqData;
- reqData.id = BarUiSelectMusicId (app, NULL,
+ reqData.id = BarUiSelectMusicId (app, NULL, NULL,
"Create station from artist or title: ");
if (reqData.id != NULL) {
reqData.type = "mi";