Subsonic API: added genres/moods tags for albums

This commit is contained in:
emeric
2023-10-04 23:26:58 +02:00
parent a47f463ca9
commit a359e4acf5
4 changed files with 41 additions and 3 deletions
@@ -98,6 +98,29 @@ namespace API::Subsonic
std::optional<UUID> mbid {release->getMBID()};
albumNode.setAttribute("musicBrainzId", mbid ? mbid->getAsString() : "");
}
auto addClusters{ [&](std::string_view field, std::string_view clusterTypeName)
{
albumNode.createEmptyArrayValue(field);
ClusterType::pointer clusterType{ ClusterType::find(dbSession, clusterTypeName) };
if (clusterType)
{
Cluster::FindParameters params;
params.setRelease(release->getId());
params.setClusterType(clusterType->getId());
for (const ClusterId clusterId : Cluster::find(dbSession, params).results)
{
Cluster::pointer cluster {Cluster::find(dbSession, clusterId)};
if (cluster)
albumNode.addArrayValue(field, cluster->getName());
}
}
} };
addClusters("genres", "GENRE");
addClusters("moods", "MOOD");
return albumNode;
}