extracted artist handling
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
|
||||
namespace API::Subsonic
|
||||
{
|
||||
static const std::string_view reportedDummyStarredDate {"2000-01-01T00:00:00"};
|
||||
static const std::string_view reportedDummyStarredDate{ "2000-01-01T00:00:00" };
|
||||
|
||||
using namespace Database;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Database
|
||||
{
|
||||
class Release;
|
||||
class User;
|
||||
class Session;
|
||||
}
|
||||
|
||||
namespace API::Subsonic
|
||||
|
||||
@@ -19,11 +19,19 @@
|
||||
|
||||
#include "responses/Artist.hpp"
|
||||
#include "services/database/Artist.hpp"
|
||||
#include "services/database/Release.hpp"
|
||||
#include "services/database/User.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "utils/Service.hpp"
|
||||
|
||||
#include "SubsonicId.hpp"
|
||||
|
||||
namespace API::Subsonic
|
||||
{
|
||||
static const std::string_view reportedDummyStarredDate{ "2000-01-01T00:00:00" };
|
||||
|
||||
using namespace Database;
|
||||
|
||||
|
||||
namespace utils
|
||||
{
|
||||
std::string joinArtistNames(const std::vector<Artist::pointer>& artists)
|
||||
@@ -43,4 +51,23 @@ namespace API::Subsonic
|
||||
return StringUtils::joinStrings(names, ", ");
|
||||
}
|
||||
}
|
||||
|
||||
Response::Node createArtistNode(const Artist::pointer& artist, Session& session, const User::pointer& user, bool id3)
|
||||
{
|
||||
Response::Node artistNode;
|
||||
|
||||
artistNode.setAttribute("id", idToString(artist->getId()));
|
||||
artistNode.setAttribute("name", artist->getName());
|
||||
|
||||
if (id3)
|
||||
{
|
||||
const auto releases{ Release::find(session, Release::FindParameters {}.setArtist(artist->getId())) };
|
||||
artistNode.setAttribute("albumCount", releases.results.size());
|
||||
}
|
||||
|
||||
if (Service<Scrobbling::IScrobblingService>::get()->isStarred(user->getId(), artist->getId()))
|
||||
artistNode.setAttribute("starred", reportedDummyStarredDate); // TODO handle date/time
|
||||
|
||||
return artistNode;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ namespace Database
|
||||
{
|
||||
class Artist;
|
||||
class User;
|
||||
class session;
|
||||
}
|
||||
|
||||
namespace API::Subsonic
|
||||
@@ -36,4 +37,5 @@ namespace API::Subsonic
|
||||
{
|
||||
std::string joinArtistNames(const std::vector<Database::ObjectPtr<Database::Artist>>& artists);
|
||||
}
|
||||
Response::Node createArtistNode(const Database::ObjectPtr<Database::Artist>& artist, Database::Session& session, const Database::ObjectPtr<Database::User>& user, bool id3);
|
||||
}
|
||||
Reference in New Issue
Block a user