aboutsummaryrefslogtreecommitdiffstats
path: root/binding/media-api.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-10-01 16:38:49 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-10-05 20:13:15 -0700
commit47593c4e5a71a95fb5ee9824e7bef8bf31d4f41f (patch)
tree6e3f3954b8aa8ed2ac9b3fe1c3973b4bd2ba9c4f /binding/media-api.c
parentaa7bfb7a49ef4e2b9e7334330650c9550eb3892a (diff)
binding: mediascanner: add media metadata to JSON output
Add metadata of the tracks artist, title, album and genre to the JSON output for media results. Bug-AGL: SPEC-924 Change-Id: I240481b3b36909cb2de6ff7ba5c0a168d7973dc2 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/media-api.c')
-rw-r--r--binding/media-api.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/binding/media-api.c b/binding/media-api.c
index 8f7503d..4a5b5f6 100644
--- a/binding/media-api.c
+++ b/binding/media-api.c
@@ -82,8 +82,38 @@ static json_object *new_json_object_from_device(GList *list)
for (l = list; l; l = l->next)
{
- jstring = json_object_new_string(l->data);
- json_object_array_add(jarray, jstring);
+ struct Media_Item *item = l->data;
+ json_object *jdict = json_object_new_object();
+
+ jstring = json_object_new_string(item->path);
+ json_object_object_add(jdict, "path", jstring);
+
+ if (item->metadata.title) {
+ jstring = json_object_new_string(item->metadata.title);
+ json_object_object_add(jdict, "title", jstring);
+ }
+
+ if (item->metadata.artist) {
+ jstring = json_object_new_string(item->metadata.artist);
+ json_object_object_add(jdict, "artist", jstring);
+ }
+
+ if (item->metadata.album) {
+ jstring = json_object_new_string(item->metadata.album);
+ json_object_object_add(jdict, "album", jstring);
+ }
+
+ if (item->metadata.genre) {
+ jstring = json_object_new_string(item->metadata.genre);
+ json_object_object_add(jdict, "genre", jstring);
+ }
+
+ if (item->metadata.duration) {
+ json_object *jint = json_object_new_int(item->metadata.duration);
+ json_object_object_add(jdict, "duration", jint);
+ }
+
+ json_object_array_add(jarray, jdict);
}
if (jstring == NULL)