Separated feedback services (stars / love for LB) from scrobbling services, to ease last.fm integration
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "services/database/Session.hpp"
|
||||
#include "services/database/Track.hpp"
|
||||
#include "services/database/User.hpp"
|
||||
#include "services/feedback/IFeedbackService.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "responses/Album.hpp"
|
||||
#include "responses/Artist.hpp"
|
||||
@@ -49,7 +50,8 @@ namespace API::Subsonic
|
||||
const Range range{ offset, size };
|
||||
|
||||
RangeResults<ReleaseId> releases;
|
||||
Scrobbling::IScrobblingService& scrobbling{ *Service<Scrobbling::IScrobblingService>::get() };
|
||||
Scrobbling::IScrobblingService& scrobblingService{ *Service<Scrobbling::IScrobblingService>::get() };
|
||||
Feedback::IFeedbackService& feedbackService{ *Service<Feedback::IFeedbackService>::get() };
|
||||
|
||||
auto transaction{ context.dbSession.createSharedTransaction() };
|
||||
|
||||
@@ -101,7 +103,7 @@ namespace API::Subsonic
|
||||
}
|
||||
else if (type == "frequent")
|
||||
{
|
||||
releases = scrobbling.getTopReleases(context.userId, {}, range);
|
||||
releases = scrobblingService.getTopReleases(context.userId, {}, range);
|
||||
}
|
||||
else if (type == "newest")
|
||||
{
|
||||
@@ -123,11 +125,11 @@ namespace API::Subsonic
|
||||
}
|
||||
else if (type == "recent")
|
||||
{
|
||||
releases = scrobbling.getRecentReleases(context.userId, {}, range);
|
||||
releases = scrobblingService.getRecentReleases(context.userId, {}, range);
|
||||
}
|
||||
else if (type == "starred")
|
||||
{
|
||||
releases = scrobbling.getStarredReleases(context.userId, {}, range);
|
||||
releases = feedbackService.getStarredReleases(context.userId, {}, range);
|
||||
}
|
||||
else
|
||||
throw NotImplementedGenericError{};
|
||||
@@ -155,21 +157,21 @@ namespace API::Subsonic
|
||||
Response response{ Response::createOkResponse(context.serverProtocolVersion) };
|
||||
Response::Node& starredNode{ response.createNode(id3 ? Response::Node::Key{ "starred2" } : Response::Node::Key{ "starred" }) };
|
||||
|
||||
Scrobbling::IScrobblingService& scrobbling{ *Service<Scrobbling::IScrobblingService>::get() };
|
||||
Feedback::IFeedbackService& feedbackService{ *Service<Feedback::IFeedbackService>::get() };
|
||||
|
||||
for (const ArtistId artistId : scrobbling.getStarredArtists(context.userId, {} /* clusters */, std::nullopt /* linkType */, ArtistSortMethod::BySortName, Range{}).results)
|
||||
for (const ArtistId artistId : feedbackService.getStarredArtists(context.userId, {} /* clusters */, std::nullopt /* linkType */, ArtistSortMethod::BySortName, Range{}).results)
|
||||
{
|
||||
if (auto artist{ Artist::find(context.dbSession, artistId) })
|
||||
starredNode.addArrayChild("artist", createArtistNode(artist, context.dbSession, user, id3));
|
||||
}
|
||||
|
||||
for (const ReleaseId releaseId : scrobbling.getStarredReleases(context.userId, {} /* clusters */, Range{}).results)
|
||||
for (const ReleaseId releaseId : feedbackService.getStarredReleases(context.userId, {} /* clusters */, Range{}).results)
|
||||
{
|
||||
if (auto release{ Release::find(context.dbSession, releaseId) })
|
||||
starredNode.addArrayChild("album", createAlbumNode(release, context.dbSession, user, id3));
|
||||
}
|
||||
|
||||
for (const TrackId trackId : scrobbling.getStarredTracks(context.userId, {} /* clusters */, Range{}).results)
|
||||
for (const TrackId trackId : feedbackService.getStarredTracks(context.userId, {} /* clusters */, Range{}).results)
|
||||
{
|
||||
if (auto track{ Track::find(context.dbSession, trackId) })
|
||||
starredNode.addArrayChild("song", createSongNode(track, context.dbSession, user));
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "services/database/ArtistId.hpp"
|
||||
#include "services/database/ReleaseId.hpp"
|
||||
#include "services/database/TrackId.hpp"
|
||||
#include "services/feedback/IFeedbackService.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "utils/Service.hpp"
|
||||
#include "ParameterParsing.hpp"
|
||||
@@ -60,13 +61,13 @@ namespace API::Subsonic
|
||||
StarParameters params{ getStarParameters(context.parameters) };
|
||||
|
||||
for (const ArtistId id : params.artistIds)
|
||||
Service<Scrobbling::IScrobblingService>::get()->star(context.userId, id);
|
||||
Service<Feedback::IFeedbackService>::get()->star(context.userId, id);
|
||||
|
||||
for (const ReleaseId id : params.releaseIds)
|
||||
Service<Scrobbling::IScrobblingService>::get()->star(context.userId, id);
|
||||
Service<Feedback::IFeedbackService>::get()->star(context.userId, id);
|
||||
|
||||
for (const TrackId id : params.trackIds)
|
||||
Service<Scrobbling::IScrobblingService>::get()->star(context.userId, id);
|
||||
Service<Feedback::IFeedbackService>::get()->star(context.userId, id);
|
||||
|
||||
return Response::createOkResponse(context.serverProtocolVersion);
|
||||
}
|
||||
@@ -76,13 +77,13 @@ namespace API::Subsonic
|
||||
StarParameters params{ getStarParameters(context.parameters) };
|
||||
|
||||
for (const ArtistId id : params.artistIds)
|
||||
Service<Scrobbling::IScrobblingService>::get()->unstar(context.userId, id);
|
||||
Service<Feedback::IFeedbackService>::get()->unstar(context.userId, id);
|
||||
|
||||
for (const ReleaseId id : params.releaseIds)
|
||||
Service<Scrobbling::IScrobblingService>::get()->unstar(context.userId, id);
|
||||
Service<Feedback::IFeedbackService>::get()->unstar(context.userId, id);
|
||||
|
||||
for (const TrackId id : params.trackIds)
|
||||
Service<Scrobbling::IScrobblingService>::get()->unstar(context.userId, id);
|
||||
Service<Feedback::IFeedbackService>::get()->unstar(context.userId, id);
|
||||
|
||||
return Response::createOkResponse(context.serverProtocolVersion);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "services/database/Artist.hpp"
|
||||
#include "services/database/Release.hpp"
|
||||
#include "services/database/User.hpp"
|
||||
#include "services/feedback/IFeedbackService.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "utils/Service.hpp"
|
||||
#include "utils/String.hpp"
|
||||
@@ -132,7 +133,7 @@ namespace API::Subsonic
|
||||
albumNode.setAttribute("genre", clusters.front().front()->getName());
|
||||
}
|
||||
|
||||
if (const Wt::WDateTime dateTime{ Service<Scrobbling::IScrobblingService>::get()->getStarredDateTime(user->getId(), release->getId()) }; dateTime.isValid())
|
||||
if (const Wt::WDateTime dateTime{ Service<Feedback::IFeedbackService>::get()->getStarredDateTime(user->getId(), release->getId()) }; dateTime.isValid())
|
||||
albumNode.setAttribute("starred", StringUtils::toISO8601String(dateTime));
|
||||
|
||||
// OpenSubsonic specific fields (must always be set)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "services/database/Release.hpp"
|
||||
#include "services/database/TrackArtistLink.hpp"
|
||||
#include "services/database/User.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "services/feedback/IFeedbackService.hpp"
|
||||
#include "utils/Service.hpp"
|
||||
#include "utils/String.hpp"
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace API::Subsonic
|
||||
artistNode.setAttribute("albumCount", releases.results.size());
|
||||
}
|
||||
|
||||
if (const Wt::WDateTime dateTime{ Service<Scrobbling::IScrobblingService>::get()->getStarredDateTime(user->getId(), artist->getId()) }; dateTime.isValid())
|
||||
if (const Wt::WDateTime dateTime{ Service<Feedback::IFeedbackService>::get()->getStarredDateTime(user->getId(), artist->getId()) }; dateTime.isValid())
|
||||
artistNode.setAttribute("starred", StringUtils::toISO8601String(dateTime));
|
||||
|
||||
// OpenSubsonic specific fields (must always be set)
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "services/database/Track.hpp"
|
||||
#include "services/database/TrackArtistLink.hpp"
|
||||
#include "services/database/User.hpp"
|
||||
#include "services/feedback/IFeedbackService.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "utils/Service.hpp"
|
||||
#include "utils/String.hpp"
|
||||
@@ -148,7 +149,7 @@ namespace API::Subsonic
|
||||
trackResponse.setAttribute("type", "music");
|
||||
trackResponse.setAttribute("created", StringUtils::toISO8601String(track->getLastWritten()));
|
||||
|
||||
if (const Wt::WDateTime dateTime{ Service<Scrobbling::IScrobblingService>::get()->getStarredDateTime(user->getId(), track->getId()) }; dateTime.isValid())
|
||||
if (const Wt::WDateTime dateTime{ Service<Feedback::IFeedbackService>::get()->getStarredDateTime(user->getId(), track->getId()) }; dateTime.isValid())
|
||||
trackResponse.setAttribute("starred", StringUtils::toISO8601String(dateTime));
|
||||
|
||||
// Report the first GENRE for this track
|
||||
|
||||
Reference in New Issue
Block a user