API Subsonic: added getSimilarSongs functions, corrected a bug in the file path generation

This commit is contained in:
emeric
2019-04-16 13:13:01 +02:00
parent cc437c7cfe
commit e2cb6917eb
4 changed files with 89 additions and 6 deletions
+15
View File
@@ -212,6 +212,21 @@ Artist::getTracks() const
return std::vector<Wt::Dbo::ptr<Track>>(_tracks.begin(), _tracks.end());
}
std::vector<Wt::Dbo::ptr<Track>>
Artist::getRandomTracks(boost::optional<std::size_t> count) const
{
assert(self());
assert(IdIsValid(self()->id()));
assert(session());
Wt::Dbo::collection<Wt::Dbo::ptr<Track>> tracks {session()->query<Wt::Dbo::ptr<Track>>("SELECT t from Track t INNER JOIN artist a ON t_a.artist_id = a.id INNER JOIN track_artist t_a ON t_a.track_id = t.id")
.where("a.id = ?").bind(self()->id())
.orderBy("RANDOM()")
.limit(count ? static_cast<int>(*count) : -1)};
return std::vector<Wt::Dbo::ptr<Track>>(tracks.begin(), tracks.end());
}
std::vector<std::vector<Wt::Dbo::ptr<Cluster>>>
Artist::getClusterGroups(std::vector<ClusterType::pointer> clusterTypes, std::size_t size) const
{
+1
View File
@@ -68,6 +68,7 @@ class Artist : public Wt::Dbo::Dbo<Artist>
// Get the releases that have at least one track for this artist that belongs to optional cluster filters
std::vector<Wt::Dbo::ptr<Release>> getReleases(const std::set<IdType>& clusterIds = std::set<IdType>()) const;
std::vector<Wt::Dbo::ptr<Track>> getTracks() const;
std::vector<Wt::Dbo::ptr<Track>> getRandomTracks(boost::optional<std::size_t> count) const;
// Get the cluster of the tracks made by this artist
// Each clusters are grouped by cluster type, sorted by the number of occurence