summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libpiano/piano.c25
-rw-r--r--src/libpiano/request.c26
-rw-r--r--src/libpiano/response.c5
3 files changed, 29 insertions, 27 deletions
diff --git a/src/libpiano/piano.c b/src/libpiano/piano.c
index bd8847b..9f4d7ec 100644
--- a/src/libpiano/piano.c
+++ b/src/libpiano/piano.c
@@ -206,31 +206,6 @@ void PianoDestroyRequest (PianoRequest_t *req) {
memset (req, 0, sizeof (*req));
}
-/* convert audio format id to string that can be used in xml requests
- * @param format id
- * @return constant string
- */
-static const char *PianoAudioFormatToString (PianoAudioFormat_t format) {
- switch (format) {
- case PIANO_AF_AACPLUS:
- return "aacplus";
- break;
-
- case PIANO_AF_MP3:
- return "mp3";
- break;
-
- case PIANO_AF_MP3_HI:
- return "mp3-hifi";
- break;
-
- default:
- return NULL;
- break;
- }
-}
-
-
/* get station from list by id
* @param search here
* @param search for this
diff --git a/src/libpiano/request.c b/src/libpiano/request.c
index 3a1d7fb..fcc13d4 100644
--- a/src/libpiano/request.c
+++ b/src/libpiano/request.c
@@ -36,6 +36,30 @@ THE SOFTWARE.
#include "piano.h"
#include "crypt.h"
+/* convert audio format id to string
+ * @param format id
+ * @return constant string
+ */
+static const char *PianoAudioFormatToString (PianoAudioFormat_t format) {
+ switch (format) {
+ case PIANO_AF_AACPLUS:
+ return "HTTP_64_AACPLUS";
+ break;
+
+ case PIANO_AF_MP3:
+ return "HTTP_128_MP3";
+ break;
+
+ case PIANO_AF_MP3_HI:
+ return "HTTP_192_MP3";
+ break;
+
+ default:
+ return NULL;
+ break;
+ }
+}
+
/* prepare piano request (initializes request type, urlpath and postData)
* @param piano handle
* @param request structure
@@ -133,6 +157,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
json_object_object_add (j, "stationToken",
json_object_new_string (reqData->station->id));
+ json_object_object_add (j, "additionalAudioUrl",
+ json_object_new_string (PianoAudioFormatToString (reqData->format)));
method = "station.getPlaylist";
break;
diff --git a/src/libpiano/response.c b/src/libpiano/response.c
index 4b33248..16b17a3 100644
--- a/src/libpiano/response.c
+++ b/src/libpiano/response.c
@@ -209,7 +209,8 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) {
free (song);
continue;
}
- song->audioUrl = strdup (json_object_get_string (json_object_object_get (json_object_object_get (json_object_object_get (s, "audioUrlMap"), "highQuality"), "audioUrl")));
+
+ song->audioUrl = PianoJsonStrdup (s, "additionalAudioUrl");
song->artist = PianoJsonStrdup (s, "artistName");
song->album = PianoJsonStrdup (s, "albumName");
song->title = PianoJsonStrdup (s, "songName");
@@ -217,7 +218,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) {
song->stationId = PianoJsonStrdup (s, "stationId");
song->fileGain = json_object_get_double (
json_object_object_get (s, "trackGain"));
- song->audioFormat = PIANO_AF_AACPLUS;
+ song->audioFormat = reqData->format;
switch (json_object_get_int (json_object_object_get (s,
"songRating"))) {
case 1: