diff --git a/src/libs/subsonic/impl/responses/Album.cpp b/src/libs/subsonic/impl/responses/Album.cpp index 0ec6dfb0..0394e46f 100644 --- a/src/libs/subsonic/impl/responses/Album.cpp +++ b/src/libs/subsonic/impl/responses/Album.cpp @@ -124,9 +124,10 @@ namespace API::Subsonic } // Report the first GENRE for this track - if (ClusterType::pointer clusterType{ ClusterType::find(dbSession, "GENRE") }) + const ClusterType::pointer genreClusterType{ ClusterType::find(dbSession, "GENRE") }; + if (genreClusterType) { - auto clusters{ release->getClusterGroups({clusterType}, 1) }; + auto clusters{ release->getClusterGroups({genreClusterType}, 1) }; if (!clusters.empty() && !clusters.front().empty()) albumNode.setAttribute("genre", clusters.front().front()->getName()); } @@ -173,13 +174,11 @@ namespace API::Subsonic // Genres { albumNode.createEmptyArrayChild("genres"); - - ClusterType::pointer clusterType{ ClusterType::find(dbSession, "GENRE") }; - if (clusterType) + if (genreClusterType) { Cluster::FindParameters params; params.setRelease(release->getId()); - params.setClusterType(clusterType->getId()); + params.setClusterType(genreClusterType->getId()); for (const ClusterId clusterId : Cluster::find(dbSession, params).results) { diff --git a/src/libs/subsonic/impl/responses/Song.cpp b/src/libs/subsonic/impl/responses/Song.cpp index c2a0fbc7..8870d8a8 100644 --- a/src/libs/subsonic/impl/responses/Song.cpp +++ b/src/libs/subsonic/impl/responses/Song.cpp @@ -152,7 +152,8 @@ namespace API::Subsonic trackResponse.setAttribute("starred", StringUtils::toISO8601String(dateTime)); // Report the first GENRE for this track - if (ClusterType::pointer genreClusterType{ ClusterType::find(dbSession, "GENRE") }) + const ClusterType::pointer genreClusterType{ ClusterType::find(dbSession, "GENRE") }; + if (genreClusterType) { auto clusters{ track->getClusterGroups({genreClusterType}, 1) }; if (!clusters.empty() && !clusters.front().empty()) @@ -235,12 +236,11 @@ namespace API::Subsonic { trackResponse.createEmptyArrayChild("genres"); - ClusterType::pointer clusterType{ ClusterType::find(dbSession, "GENRE") }; - if (clusterType) + if (genreClusterType) { Cluster::FindParameters params; params.setTrack(track->getId()); - params.setClusterType(clusterType->getId()); + params.setClusterType(genreClusterType->getId()); for (const ClusterId clusterId : Cluster::find(dbSession, params).results) {