Allowed custom release types + handle more MusicBrainz secondary types in UI. fixes #373
This commit is contained in:
@@ -37,43 +37,6 @@ namespace API::Subsonic
|
||||
{
|
||||
using namespace Database;
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string_view toString(ReleaseTypePrimary releaseType)
|
||||
{
|
||||
switch (releaseType)
|
||||
{
|
||||
case ReleaseTypePrimary::Album: return "album";
|
||||
case ReleaseTypePrimary::Broadcast: return "broadcast";
|
||||
case ReleaseTypePrimary::EP: return "ep";
|
||||
case ReleaseTypePrimary::Single: return "single";
|
||||
case ReleaseTypePrimary::Other: return "other";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
std::string_view toString(ReleaseTypeSecondary releaseType)
|
||||
{
|
||||
switch (releaseType)
|
||||
{
|
||||
case ReleaseTypeSecondary::Audiobook: return "audiobook";
|
||||
case ReleaseTypeSecondary::AudioDrama: return "audiodrama";
|
||||
case ReleaseTypeSecondary::Compilation: return "compilation";
|
||||
case ReleaseTypeSecondary::Demo: return "demo";
|
||||
case ReleaseTypeSecondary::DJMix: return "djmix";
|
||||
case ReleaseTypeSecondary::Interview: return "interview";
|
||||
case ReleaseTypeSecondary::Live: return "live";
|
||||
case ReleaseTypeSecondary::Mixtape_Street: return "mixtapestreet";
|
||||
case ReleaseTypeSecondary::Remix: return "remix";
|
||||
case ReleaseTypeSecondary::Soundtrack: return "soundtrack";
|
||||
case ReleaseTypeSecondary::Spokenword: return "soundtrack";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
Response::Node createAlbumNode(RequestContext& context, const Release::pointer& release, const User::pointer& user, bool id3)
|
||||
{
|
||||
Response::Node albumNode;
|
||||
@@ -192,12 +155,20 @@ namespace API::Subsonic
|
||||
albumNode.setAttribute("originalReleaseDate", originalReleaseDate.isValid() ? StringUtils::toISO8601String(originalReleaseDate) : "");
|
||||
}
|
||||
|
||||
albumNode.setAttribute("isCompilation", release->getSecondaryTypes().contains(ReleaseTypeSecondary::Compilation));
|
||||
albumNode.createEmptyArrayValue("releaseTypes");
|
||||
if (auto releaseType{ release->getPrimaryType() })
|
||||
albumNode.addArrayValue("releaseTypes", toString(*releaseType));
|
||||
for (const ReleaseTypeSecondary releaseType : release->getSecondaryTypes())
|
||||
albumNode.addArrayValue("releaseTypes", toString(releaseType));
|
||||
{
|
||||
bool isCompilation{};
|
||||
albumNode.createEmptyArrayValue("releaseTypes");
|
||||
for (std::string_view releaseType : release->getReleaseTypeNames())
|
||||
{
|
||||
if (StringUtils::stringCaseInsensitiveEqual(releaseType, "compilation"))
|
||||
isCompilation = true;
|
||||
|
||||
albumNode.addArrayValue("releaseTypes", releaseType);
|
||||
}
|
||||
|
||||
// TODO: the Compilation tag does not have the same meaning
|
||||
albumNode.setAttribute("isCompilation", isCompilation);
|
||||
}
|
||||
|
||||
// disc titles
|
||||
albumNode.createEmptyArrayChild("discTitles");
|
||||
|
||||
Reference in New Issue
Block a user