Subsonic API: added common answer fields

This commit is contained in:
emeric
2023-10-06 08:41:53 +02:00
parent 06b0880a7d
commit 621e1f98db
3 changed files with 11 additions and 6 deletions
@@ -31,6 +31,7 @@ namespace API::Subsonic
};
static inline constexpr ProtocolVersion defaultServerProtocolVersion{ 1, 16, 0 };
static inline constexpr std::string_view serverVersion{ "1" };
}
namespace StringUtils
+5 -1
View File
@@ -130,7 +130,11 @@ namespace API::Subsonic
responseNode.setAttribute("status", "ok");
responseNode.setVersionAttribute(protocolVersion);
responseNode.setAttribute("type", "lms"); // non standard field to ease client hacks
// OpenSubsonic mandatory fields
responseNode.setAttribute("type", "lms");
responseNode.setAttribute("serverVersion", serverVersion);
responseNode.setAttribute("openSubsonic", true);
return response;
}
+5 -5
View File
@@ -132,7 +132,7 @@ namespace API::Subsonic
// OpenSubsonic specific fields (must always be set)
{
std::optional<UUID> mbid {release->getMBID()};
std::optional<UUID> mbid{ release->getMBID() };
albumNode.setAttribute("musicBrainzId", mbid ? mbid->getAsString() : "");
}
@@ -149,9 +149,9 @@ namespace API::Subsonic
for (const ClusterId clusterId : Cluster::find(dbSession, params).results)
{
Cluster::pointer cluster {Cluster::find(dbSession, clusterId)};
Cluster::pointer cluster{ Cluster::find(dbSession, clusterId) };
if (cluster)
albumNode.addArrayValue(field, cluster->getName());
albumNode.addArrayValue(field, cluster->getName());
}
}
} };
@@ -160,11 +160,11 @@ namespace API::Subsonic
addClusters("moods", "MOOD");
albumNode.createEmptyArrayChild("artists");
for (const Artist::pointer& artist : release->getReleaseArtists() )
for (const Artist::pointer& artist : release->getReleaseArtists())
albumNode.addArrayChild("artists", createArtistNode(artist));
{
const Wt::WDate originalReleaseDate{release->getOriginalReleaseDate()};
const Wt::WDate originalReleaseDate{ release->getOriginalReleaseDate() };
albumNode.setAttribute("originalReleaseDate", originalReleaseDate.isValid() ? StringUtils::toISO8601String(originalReleaseDate) : "");
}