Auto reformatted the base, ref #470
This commit is contained in:
@@ -19,21 +19,21 @@
|
||||
|
||||
#include "responses/Album.hpp"
|
||||
|
||||
#include "core/ITraceLogger.hpp"
|
||||
#include "core/Service.hpp"
|
||||
#include "core/String.hpp"
|
||||
#include "database/Artist.hpp"
|
||||
#include "database/Cluster.hpp"
|
||||
#include "database/Release.hpp"
|
||||
#include "database/User.hpp"
|
||||
#include "services/feedback/IFeedbackService.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "core/ITraceLogger.hpp"
|
||||
#include "core/Service.hpp"
|
||||
#include "core/String.hpp"
|
||||
|
||||
#include "SubsonicId.hpp"
|
||||
#include "responses/Artist.hpp"
|
||||
#include "responses/DiscTitle.hpp"
|
||||
#include "responses/ItemDate.hpp"
|
||||
#include "responses/ItemGenre.hpp"
|
||||
#include "SubsonicId.hpp"
|
||||
|
||||
namespace lms::api::subsonic
|
||||
{
|
||||
@@ -45,13 +45,14 @@ namespace lms::api::subsonic
|
||||
|
||||
Response::Node albumNode;
|
||||
|
||||
if (id3) {
|
||||
if (id3)
|
||||
{
|
||||
albumNode.setAttribute("name", release->getName());
|
||||
albumNode.setAttribute("songCount", release->getTrackCount());
|
||||
albumNode.setAttribute(
|
||||
"duration", std::chrono::duration_cast<std::chrono::seconds>(
|
||||
release->getDuration())
|
||||
.count());
|
||||
release->getDuration())
|
||||
.count());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,7 +98,7 @@ namespace lms::api::subsonic
|
||||
const ClusterType::pointer genreClusterType{ ClusterType::find(context.dbSession, "GENRE") };
|
||||
if (genreClusterType)
|
||||
{
|
||||
auto clusters{ release->getClusterGroups({genreClusterType->getId()}, 1) };
|
||||
auto clusters{ release->getClusterGroups({ genreClusterType->getId() }, 1) };
|
||||
if (!clusters.empty() && !clusters.front().empty())
|
||||
albumNode.setAttribute("genre", clusters.front().front()->getName());
|
||||
}
|
||||
@@ -124,19 +125,17 @@ namespace lms::api::subsonic
|
||||
albumNode.setAttribute("musicBrainzId", mbid ? mbid->getAsString() : "");
|
||||
}
|
||||
|
||||
auto addClusters{ [&](Response::Node::Key field, std::string_view clusterTypeName)
|
||||
{
|
||||
auto addClusters{ [&](Response::Node::Key field, std::string_view clusterTypeName) {
|
||||
albumNode.createEmptyArrayValue(field);
|
||||
|
||||
Cluster::FindParameters params;
|
||||
params.setRelease(release->getId());
|
||||
params.setClusterTypeName(clusterTypeName);
|
||||
|
||||
Cluster::find(context.dbSession, params, [&](const Cluster::pointer& cluster)
|
||||
{
|
||||
albumNode.addArrayValue(field, cluster->getName());
|
||||
});
|
||||
}};
|
||||
Cluster::find(context.dbSession, params, [&](const Cluster::pointer& cluster) {
|
||||
albumNode.addArrayValue(field, cluster->getName());
|
||||
});
|
||||
} };
|
||||
|
||||
addClusters("moods", "MOOD");
|
||||
|
||||
@@ -148,10 +147,9 @@ namespace lms::api::subsonic
|
||||
params.setRelease(release->getId());
|
||||
params.setClusterType(genreClusterType->getId());
|
||||
|
||||
Cluster::find(context.dbSession, params, [&](const Cluster::pointer& cluster)
|
||||
{
|
||||
albumNode.addArrayChild("genres", createItemGenreNode(cluster->getName()));
|
||||
});
|
||||
Cluster::find(context.dbSession, params, [&](const Cluster::pointer& cluster) {
|
||||
albumNode.addArrayChild("genres", createItemGenreNode(cluster->getName()));
|
||||
});
|
||||
}
|
||||
|
||||
albumNode.createEmptyArrayChild("artists");
|
||||
@@ -186,4 +184,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return albumNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/Object.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
@@ -27,7 +28,7 @@ namespace lms::db
|
||||
class Release;
|
||||
class User;
|
||||
class Session;
|
||||
}
|
||||
} // namespace lms::db
|
||||
|
||||
namespace lms::api::subsonic
|
||||
{
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
|
||||
#include "responses/Artist.hpp"
|
||||
|
||||
#include "core/ITraceLogger.hpp"
|
||||
#include "core/Service.hpp"
|
||||
#include "core/String.hpp"
|
||||
#include "database/Artist.hpp"
|
||||
#include "database/Release.hpp"
|
||||
#include "database/TrackArtistLink.hpp"
|
||||
#include "database/User.hpp"
|
||||
#include "services/feedback/IFeedbackService.hpp"
|
||||
#include "core/ITraceLogger.hpp"
|
||||
#include "core/Service.hpp"
|
||||
#include "core/String.hpp"
|
||||
|
||||
#include "SubsonicId.hpp"
|
||||
|
||||
@@ -45,8 +45,7 @@ namespace lms::api::subsonic
|
||||
names.resize(artists.size());
|
||||
|
||||
std::transform(std::cbegin(artists), std::cend(artists), std::begin(names),
|
||||
[](const Artist::pointer& artist)
|
||||
{
|
||||
[](const Artist::pointer& artist) {
|
||||
return artist->getName();
|
||||
});
|
||||
|
||||
@@ -57,22 +56,33 @@ namespace lms::api::subsonic
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TrackArtistLinkType::Arranger: return "arranger";
|
||||
case TrackArtistLinkType::Artist: return "artist";
|
||||
case TrackArtistLinkType::Composer: return "composer";
|
||||
case TrackArtistLinkType::Conductor: return "conductor";
|
||||
case TrackArtistLinkType::Lyricist: return "lyricist";
|
||||
case TrackArtistLinkType::Mixer: return "mixer";
|
||||
case TrackArtistLinkType::Performer: return "performer";
|
||||
case TrackArtistLinkType::Producer: return "producer";
|
||||
case TrackArtistLinkType::ReleaseArtist: return "albumartist";
|
||||
case TrackArtistLinkType::Remixer: return "remixer";
|
||||
case TrackArtistLinkType::Writer: return "writer";
|
||||
case TrackArtistLinkType::Arranger:
|
||||
return "arranger";
|
||||
case TrackArtistLinkType::Artist:
|
||||
return "artist";
|
||||
case TrackArtistLinkType::Composer:
|
||||
return "composer";
|
||||
case TrackArtistLinkType::Conductor:
|
||||
return "conductor";
|
||||
case TrackArtistLinkType::Lyricist:
|
||||
return "lyricist";
|
||||
case TrackArtistLinkType::Mixer:
|
||||
return "mixer";
|
||||
case TrackArtistLinkType::Performer:
|
||||
return "performer";
|
||||
case TrackArtistLinkType::Producer:
|
||||
return "producer";
|
||||
case TrackArtistLinkType::ReleaseArtist:
|
||||
return "albumartist";
|
||||
case TrackArtistLinkType::Remixer:
|
||||
return "remixer";
|
||||
case TrackArtistLinkType::Writer:
|
||||
return "writer";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
|
||||
Response::Node createArtistNode(RequestContext& context, const Artist::pointer& artist, const User::pointer& user, bool id3)
|
||||
{
|
||||
@@ -86,7 +96,7 @@ namespace lms::api::subsonic
|
||||
|
||||
if (id3)
|
||||
{
|
||||
const std::size_t count{ Release::getCount(context.dbSession, Release::FindParameters {}.setArtist(artist->getId())) };
|
||||
const std::size_t count{ Release::getCount(context.dbSession, Release::FindParameters{}.setArtist(artist->getId())) };
|
||||
artistNode.setAttribute("albumCount", count);
|
||||
}
|
||||
|
||||
@@ -125,4 +135,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return artistNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -21,8 +21,10 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "database/Object.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
@@ -30,7 +32,7 @@ namespace lms::db
|
||||
class Artist;
|
||||
class User;
|
||||
class Session;
|
||||
}
|
||||
} // namespace lms::db
|
||||
|
||||
namespace lms::api::subsonic
|
||||
{
|
||||
@@ -38,7 +40,7 @@ namespace lms::api::subsonic
|
||||
{
|
||||
std::string joinArtistNames(const std::vector<db::ObjectPtr<db::Artist>>& artists);
|
||||
std::string_view toString(db::TrackArtistLinkType type);
|
||||
}
|
||||
} // namespace utils
|
||||
Response::Node createArtistNode(RequestContext& context, const db::ObjectPtr<db::Artist>& artist, const db::ObjectPtr<db::User>& user, bool id3);
|
||||
Response::Node createArtistNode(const db::ObjectPtr<db::Artist>& artist); // only minimal info
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -39,4 +39,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return trackBookmarkNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/Object.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "database/Object.hpp"
|
||||
#include "database/TrackArtistLink.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
#include "responses/Artist.hpp"
|
||||
|
||||
@@ -37,4 +38,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return contributorNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,13 +20,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/Object.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
{
|
||||
class Artist;
|
||||
class TrackArtistLink;
|
||||
}
|
||||
} // namespace lms::db
|
||||
|
||||
namespace lms::api::subsonic
|
||||
{
|
||||
|
||||
@@ -30,4 +30,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return discTitleNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::api::subsonic
|
||||
|
||||
@@ -33,4 +33,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return clusterNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/Object.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
|
||||
@@ -40,4 +40,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return itemDateNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WDate.h>
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::api::subsonic
|
||||
|
||||
@@ -31,4 +31,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return genreNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "database/Track.hpp"
|
||||
#include "database/TrackList.hpp"
|
||||
#include "database/User.hpp"
|
||||
|
||||
#include "SubsonicId.hpp"
|
||||
|
||||
namespace lms::api::subsonic
|
||||
@@ -42,9 +43,9 @@ namespace lms::api::subsonic
|
||||
playlistNode.setAttribute("created", reportedDummyDate);
|
||||
playlistNode.setAttribute("owner", tracklist->getUser()->getLoginName());
|
||||
|
||||
if (const auto entry {tracklist->getEntry(0)})
|
||||
if (const auto entry{ tracklist->getEntry(0) })
|
||||
playlistNode.setAttribute("coverArt", idToString(entry->getTrack()->getId()));
|
||||
|
||||
return playlistNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,13 +20,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/Object.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
{
|
||||
class TrackList;
|
||||
class Session;
|
||||
}
|
||||
} // namespace lms::db
|
||||
|
||||
namespace lms::api::subsonic
|
||||
{
|
||||
|
||||
@@ -35,4 +35,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return replayGainNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/Object.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include <string_view>
|
||||
|
||||
#include "av/IAudioFile.hpp"
|
||||
#include "core/ITraceLogger.hpp"
|
||||
#include "core/Service.hpp"
|
||||
#include "core/String.hpp"
|
||||
#include "database/Artist.hpp"
|
||||
#include "database/Cluster.hpp"
|
||||
#include "database/Release.hpp"
|
||||
@@ -30,15 +33,13 @@
|
||||
#include "database/User.hpp"
|
||||
#include "services/feedback/IFeedbackService.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "core/ITraceLogger.hpp"
|
||||
#include "core/Service.hpp"
|
||||
#include "core/String.hpp"
|
||||
|
||||
#include "SubsonicId.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "responses/Artist.hpp"
|
||||
#include "responses/Contributor.hpp"
|
||||
#include "responses/ItemGenre.hpp"
|
||||
#include "responses/ReplayGain.hpp"
|
||||
#include "SubsonicId.hpp"
|
||||
#include "Utils.hpp"
|
||||
|
||||
namespace lms::api::subsonic
|
||||
{
|
||||
@@ -50,16 +51,21 @@ namespace lms::api::subsonic
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case TranscodingOutputFormat::MP3: return "mp3";
|
||||
case TranscodingOutputFormat::OGG_OPUS: return "opus";
|
||||
case TranscodingOutputFormat::MATROSKA_OPUS: return "mka";
|
||||
case TranscodingOutputFormat::OGG_VORBIS: return "ogg";
|
||||
case TranscodingOutputFormat::WEBM_VORBIS: return "webm";
|
||||
case TranscodingOutputFormat::MP3:
|
||||
return "mp3";
|
||||
case TranscodingOutputFormat::OGG_OPUS:
|
||||
return "opus";
|
||||
case TranscodingOutputFormat::MATROSKA_OPUS:
|
||||
return "mka";
|
||||
case TranscodingOutputFormat::OGG_VORBIS:
|
||||
return "ogg";
|
||||
case TranscodingOutputFormat::WEBM_VORBIS:
|
||||
return "webm";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Response::Node createSongNode(RequestContext& context, const Track::pointer& track, const User::pointer& user)
|
||||
{
|
||||
@@ -94,7 +100,7 @@ namespace lms::api::subsonic
|
||||
|
||||
trackResponse.setAttribute("coverArt", idToString(track->getId()));
|
||||
|
||||
const std::vector<Artist::pointer>& artists{ track->getArtists({TrackArtistLinkType::Artist}) };
|
||||
const std::vector<Artist::pointer>& artists{ track->getArtists({ TrackArtistLinkType::Artist }) };
|
||||
if (!artists.empty())
|
||||
{
|
||||
if (!track->getArtistDisplayName().empty())
|
||||
@@ -160,18 +166,17 @@ namespace lms::api::subsonic
|
||||
trackResponse.createEmptyArrayChild("artists");
|
||||
trackResponse.createEmptyArrayChild("contributors");
|
||||
|
||||
TrackArtistLink::find(context.dbSession, track->getId(), [&](const TrackArtistLink::pointer& link, const Artist::pointer& artist)
|
||||
{
|
||||
TrackArtistLink::find(context.dbSession, track->getId(), [&](const TrackArtistLink::pointer& link, const Artist::pointer& artist) {
|
||||
switch (link->getType())
|
||||
{
|
||||
case TrackArtistLinkType::Artist:
|
||||
trackResponse.addArrayChild("artists", createArtistNode(artist));
|
||||
break;
|
||||
case TrackArtistLinkType::ReleaseArtist:
|
||||
trackResponse.addArrayChild("albumartists", createArtistNode(artist));
|
||||
break;
|
||||
default:
|
||||
trackResponse.addArrayChild("contributors", createContributorNode(link, artist));
|
||||
case TrackArtistLinkType::Artist:
|
||||
trackResponse.addArrayChild("artists", createArtistNode(artist));
|
||||
break;
|
||||
case TrackArtistLinkType::ReleaseArtist:
|
||||
trackResponse.addArrayChild("albumartists", createArtistNode(artist));
|
||||
break;
|
||||
default:
|
||||
trackResponse.addArrayChild("contributors", createContributorNode(link, artist));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -180,8 +185,7 @@ namespace lms::api::subsonic
|
||||
if (release)
|
||||
trackResponse.setAttribute("displayAlbumArtist", release->getArtistDisplayName());
|
||||
|
||||
auto addClusters{ [&](Response::Node::Key field, std::string_view clusterTypeName)
|
||||
{
|
||||
auto addClusters{ [&](Response::Node::Key field, std::string_view clusterTypeName) {
|
||||
trackResponse.createEmptyArrayValue(field);
|
||||
|
||||
Cluster::FindParameters params;
|
||||
@@ -203,4 +207,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return trackResponse;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/Object.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
@@ -27,7 +28,7 @@ namespace lms::db
|
||||
class Track;
|
||||
class User;
|
||||
class Session;
|
||||
}
|
||||
} // namespace lms::db
|
||||
|
||||
namespace lms::api::subsonic
|
||||
{
|
||||
|
||||
@@ -49,4 +49,4 @@ namespace lms::api::subsonic
|
||||
|
||||
return userNode;
|
||||
}
|
||||
}
|
||||
} // namespace lms::api::subsonic
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/Object.hpp"
|
||||
|
||||
#include "SubsonicResponse.hpp"
|
||||
|
||||
namespace lms::db
|
||||
|
||||
Reference in New Issue
Block a user