Subsonic API: can now search albums and artists using mbid, fixes #826

This commit is contained in:
emeric
2026-03-10 16:32:38 +01:00
parent f9ae188be3
commit 52d31dbec4
+33 -11
View File
@@ -24,6 +24,7 @@
#include <mutex>
#include "core/Random.hpp"
#include "core/UUID.hpp"
#include "database/Session.hpp"
#include "database/objects/Artist.hpp"
#include "database/objects/Directory.hpp"
@@ -172,10 +173,22 @@ namespace lms::api::subsonic
if (!keywords.empty())
{
findArtists();
}
else
if (keywords.size() == 1)
{
if (const auto mbid{ core::UUID::fromString(keywords.front()) })
{
if (const auto artist{ Artist::find(context.getDbSession(), *mbid) })
{
searchResultNode.addArrayChild("artist", createArtistNode(context, artist));
return;
}
}
}
findArtists();
return;
}
ScanTracker<ArtistId>::ScanInfo scanInfo{
.clientAddress = context.getClientIpAddr(),
.clientName = std::string{ context.getClientName() },
@@ -204,7 +217,6 @@ namespace lms::api::subsonic
currentScansInProgress.setObjectId(scanInfo, lastRetrievedId);
}
}
}
void findRequestedAlbums(RequestContext& context, bool id3, const std::vector<std::string_view>& keywords, MediaLibraryId mediaLibrary, Response::Node& searchResultNode)
{
@@ -236,10 +248,22 @@ namespace lms::api::subsonic
if (!keywords.empty())
{
findReleases();
}
else
if (keywords.size() == 1)
{
if (const auto mbid{ core::UUID::fromString(keywords.front()) })
{
if (const auto release{ Release::find(context.getDbSession(), *mbid) })
{
searchResultNode.addArrayChild("album", createAlbumNode(context, release, id3));
return;
}
}
}
findReleases();
return;
}
ScanTracker<ReleaseId>::ScanInfo scanInfo{
.clientAddress = context.getClientIpAddr(),
.clientName = std::string{ context.getClientName() },
@@ -268,7 +292,6 @@ namespace lms::api::subsonic
currentScansInProgress.setObjectId(scanInfo, lastRetrievedId);
}
}
}
void findRequestedTracks(RequestContext& context, bool id3, const std::vector<std::string_view>& keywords, MediaLibraryId mediaLibrary, Response::Node& searchResultNode)
{
@@ -301,9 +324,9 @@ namespace lms::api::subsonic
if (!keywords.empty())
{
findTracks();
return;
}
else
{
ScanTracker<TrackId>::ScanInfo scanInfo{
.clientAddress = context.getClientIpAddr(),
.clientName = std::string{ context.getClientName() },
@@ -332,7 +355,6 @@ namespace lms::api::subsonic
currentScansInProgress.setObjectId(scanInfo, lastRetrievedId);
}
}
}
Response handleSearchRequestCommon(RequestContext& context, bool id3)
{