diff --git a/src/core/library/query/local/AlbumListQuery.cpp b/src/core/library/query/local/AlbumListQuery.cpp index 5a30af5ad..a3af87b81 100644 --- a/src/core/library/query/local/AlbumListQuery.cpp +++ b/src/core/library/query/local/AlbumListQuery.cpp @@ -118,9 +118,13 @@ bool AlbumListQuery::OnRun(Connection& db) { Apply(stmt, args); while (stmt.Step() == Row) { - std::shared_ptr row(new MetadataMap( - stmt.ColumnInt64(0), stmt.ColumnText(1), "album")); + int64_t albumId = stmt.ColumnInt64(0); + std::string albumName = stmt.ColumnText(1); + std::shared_ptr row(new MetadataMap(albumId, albumName, "album")); + row->SetValue(Track::ALBUM_ID, stmt.ColumnText(0)); + row->SetValue(Track::ALBUM, albumName); + row->SetValue(Track::ALBUM_ARTIST_ID, stmt.ColumnText(2)); row->SetValue(Track::ALBUM_ARTIST_ID, stmt.ColumnText(2)); row->SetValue(Track::ALBUM_ARTIST, stmt.ColumnText(3)); row->SetValue(Track::THUMBNAIL_ID, stmt.ColumnText(4)); diff --git a/src/core_c_demo/main.c b/src/core_c_demo/main.c index 2d9b0d14f..42a13b968 100644 --- a/src/core_c_demo/main.c +++ b/src/core_c_demo/main.c @@ -6,9 +6,19 @@ int main(int argc, char** argv) { mcsdk_context* context = NULL; mcsdk_context_init(&context); if (context) { - printf("omg"); + printf("initialized\n"); } - + mcsdk_map_list ml = mcsdk_svc_metadata_query_albums(context->metadata, "alice"); + int count = mcsdk_map_list_get_count(ml); + for (int i = 0; i < count; i++) { + mcsdk_map m = mcsdk_map_list_get_at(ml, i); + size_t len = mcsdk_map_get_string(m, "album", NULL, 0); + char* str = malloc(len * sizeof(char)); + mcsdk_map_get_string(m, "album", str, len); + printf("%s\n", str); + free(str); + } + mcsdk_map_list_release(ml); mcsdk_context_release(&context); return 0; }