Metadata querying seems to work!

This commit is contained in:
casey langen 2020-01-26 16:11:25 -08:00
parent dc340265e3
commit 3b7c263aea
2 changed files with 18 additions and 4 deletions

View File

@ -118,9 +118,13 @@ bool AlbumListQuery::OnRun(Connection& db) {
Apply(stmt, args);
while (stmt.Step() == Row) {
std::shared_ptr<MetadataMap> 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<MetadataMap> 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));

View File

@ -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;
}