Merge branch 'release-type' into develop
This commit is contained in:
+9
-8
@@ -20,14 +20,8 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${<if-has-releases>}
|
${release-containers}
|
||||||
${<if-release-title>}<h3>${tr:Lms.Explore.releases}</h3>${</if-release-title>}
|
${appears-on-releases}
|
||||||
${releases class="mb-3"}
|
|
||||||
${</if-has-releases>}
|
|
||||||
${<if-has-appears-on-releases>}
|
|
||||||
<h3>${tr:Lms.Explore.Artist.appears-on}</h3>
|
|
||||||
${appears-on-releases class="mb-3"}
|
|
||||||
${</if-has-appears-on-releases>}
|
|
||||||
${<if-has-non-release-tracks>}
|
${<if-has-non-release-tracks>}
|
||||||
<h3>${tr:Lms.Explore.tracks}</h3>
|
<h3>${tr:Lms.Explore.tracks}</h3>
|
||||||
${tracks class="mb-3"}
|
${tracks class="mb-3"}
|
||||||
@@ -38,4 +32,11 @@
|
|||||||
${</if-has-similar-artists>}
|
${</if-has-similar-artists>}
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<message id="Lms.Explore.Artist.template.release-container">
|
||||||
|
<div class="mb-3">
|
||||||
|
<h3>${release-type}</h3>
|
||||||
|
${releases}
|
||||||
|
</div>
|
||||||
|
</message>
|
||||||
|
|
||||||
</messages>
|
</messages>
|
||||||
|
|||||||
@@ -197,6 +197,23 @@
|
|||||||
<message id="Lms.Explore.Release.similar-releases">Similar albums</message>
|
<message id="Lms.Explore.Release.similar-releases">Similar albums</message>
|
||||||
<message id="Lms.Explore.Release.copyright">Copyright</message>
|
<message id="Lms.Explore.Release.copyright">Copyright</message>
|
||||||
<message id="Lms.Explore.Release.disc">Disc {1}</message>
|
<message id="Lms.Explore.Release.disc">Disc {1}</message>
|
||||||
|
<message id="Lms.Explore.Release.type">Type</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-album">Album</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-broadcast">Broadcast</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-ep">EP</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-other">Other</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-single">Single</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-audiobook">Audiobook</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-audiodrama">Audio drama</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-compilation">Compilation</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-demo">Demo</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-djmix">DJ-mix</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-interview">Interview</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-live">Live</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-mixtape-street">Mixtape/Street</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-remix">Remix</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-soundtrack">Soundtrack</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-spokenword">Spokenword</message>
|
||||||
|
|
||||||
<!--Explore:TrackLists-->
|
<!--Explore:TrackLists-->
|
||||||
<message id="Lms.Explore.TrackLists.del-tracklist-confirm">Delete playlist?</message>
|
<message id="Lms.Explore.TrackLists.del-tracklist-confirm">Delete playlist?</message>
|
||||||
|
|||||||
@@ -197,6 +197,23 @@
|
|||||||
<message id="Lms.Explore.Release.similar-releases">Albums similaires</message>
|
<message id="Lms.Explore.Release.similar-releases">Albums similaires</message>
|
||||||
<message id="Lms.Explore.Release.copyright">Copyright</message>
|
<message id="Lms.Explore.Release.copyright">Copyright</message>
|
||||||
<message id="Lms.Explore.Release.disc">Disque {1}</message>
|
<message id="Lms.Explore.Release.disc">Disque {1}</message>
|
||||||
|
<message id="Lms.Explore.Release.type">Type</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-album">Album</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-broadcast">Broadcast</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-ep">EP</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-other">Other</message>
|
||||||
|
<message id="Lms.Explore.Release.type-primary-single">Single</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-audiobook">Audiobook</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-audiodrama">Audio drama</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-compilation">Compilation</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-demo">Demo</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-djmix">DJ-mix</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-interview">Interview</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-live">Live</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-mixtape-street">Mixtape/Street</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-remix">Remix</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-soundtrack">Soundtrack</message>
|
||||||
|
<message id="Lms.Explore.Release.type-secondary-spokenword">Spokenword</message>
|
||||||
|
|
||||||
<!--Explore:TrackLists-->
|
<!--Explore:TrackLists-->
|
||||||
<message id="Lms.Explore.TrackLists.del-tracklist-confirm">Supprimer la liste de lecture ?</message>
|
<message id="Lms.Explore.TrackLists.del-tracklist-confirm">Supprimer la liste de lecture ?</message>
|
||||||
|
|||||||
@@ -198,6 +198,23 @@
|
|||||||
<message id="Lms.Explore.Release.copyright">Copyright</message>
|
<message id="Lms.Explore.Release.copyright">Copyright</message>
|
||||||
<message id="Lms.Explore.Release.disc">Disco {1}</message>
|
<message id="Lms.Explore.Release.disc">Disco {1}</message>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Explore:TrackLists-->
|
<!--Explore:TrackLists-->
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+17
-4
@@ -198,6 +198,23 @@
|
|||||||
<message id="Lms.Explore.Release.copyright">版权所有</message>
|
<message id="Lms.Explore.Release.copyright">版权所有</message>
|
||||||
<message id="Lms.Explore.Release.disc">唱片 {1}</message>
|
<message id="Lms.Explore.Release.disc">唱片 {1}</message>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Explore:TrackLists-->
|
<!--Explore:TrackLists-->
|
||||||
<message id="Lms.Explore.TrackLists.del-tracklist-confirm">删除播放列表?</message>
|
<message id="Lms.Explore.TrackLists.del-tracklist-confirm">删除播放列表?</message>
|
||||||
|
|
||||||
@@ -210,10 +227,6 @@
|
|||||||
<!--Playqueue-->
|
<!--Playqueue-->
|
||||||
<message id="Lms.PlayQueue.clear">清除</message>
|
<message id="Lms.PlayQueue.clear">清除</message>
|
||||||
<message id="Lms.PlayQueue.create-tracklist">创建新播放列表</message>
|
<message id="Lms.PlayQueue.create-tracklist">创建新播放列表</message>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<message id="Lms.PlayQueue.playqueue">播放队列</message>
|
<message id="Lms.PlayQueue.playqueue">播放队列</message>
|
||||||
<message id="Lms.PlayQueue.radio-mode">广播模式</message>
|
<message id="Lms.PlayQueue.radio-mode">广播模式</message>
|
||||||
<message id="Lms.PlayQueue.repeat">循环播放</message>
|
<message id="Lms.PlayQueue.repeat">循环播放</message>
|
||||||
|
|||||||
@@ -103,7 +103,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="container-fluid d-grid gap-2">
|
<div class="container-fluid d-grid gap-2">
|
||||||
|
${<if-has-release-type>}
|
||||||
|
<div class="row align-items-center">
|
||||||
|
<div class="col-4">
|
||||||
|
${tr:Lms.Explore.Release.type}
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
${release-type}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
${</if-has-release-type>}
|
||||||
|
${<if-has-artist>}
|
||||||
${artist-table class="d-grid gap-2"}
|
${artist-table class="d-grid gap-2"}
|
||||||
|
${</if-has-artist>}
|
||||||
${<if-has-codec>}
|
${<if-has-codec>}
|
||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
|
|||||||
@@ -100,7 +100,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${</if-has-clusters>}
|
${</if-has-clusters>}
|
||||||
|
${<if-has-artist>}
|
||||||
${artist-table class="d-grid gap-2"}
|
${artist-table class="d-grid gap-2"}
|
||||||
|
${</if-has-artist>}
|
||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
${tr:Lms.Explore.duration}
|
${tr:Lms.Explore.duration}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ using TagMap = std::map<std::string, std::vector<std::string>>;
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::vector<T>
|
std::vector<T>
|
||||||
getPropertyValuesFirstMatchAs(const TagMap& tags, const std::vector<std::string_view>& keys)
|
getPropertyValuesFirstMatchAs(const TagMap& tags, std::initializer_list<std::string_view> keys)
|
||||||
{
|
{
|
||||||
std::vector<T> res;
|
std::vector<T> res;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ getPropertyValuesFirstMatchAs(const TagMap& tags, const std::vector<std::string_
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::optional<T>
|
std::optional<T>
|
||||||
getPropertyValueFirstMatchAs(const TagMap& tags, const std::vector<std::string_view>& keys)
|
getPropertyValueFirstMatchAs(const TagMap& tags, std::initializer_list<std::string_view> keys)
|
||||||
{
|
{
|
||||||
std::optional<T> res;
|
std::optional<T> res;
|
||||||
std::vector<T> values {getPropertyValuesFirstMatchAs<T>(tags, keys)};
|
std::vector<T> values {getPropertyValuesFirstMatchAs<T>(tags, keys)};
|
||||||
@@ -95,14 +95,14 @@ getPropertyValueFirstMatchAs(const TagMap& tags, const std::vector<std::string_v
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::vector<T>
|
std::vector<T>
|
||||||
getPropertyValuesAs(const TagMap& tags, const std::string& key)
|
getPropertyValuesAs(const TagMap& tags, std::string_view key)
|
||||||
{
|
{
|
||||||
return getPropertyValuesFirstMatchAs<T>(tags, {key});
|
return getPropertyValuesFirstMatchAs<T>(tags, {key});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::optional<T>
|
std::optional<T>
|
||||||
getPropertyValueAs(const TagMap& tags, const std::string& key)
|
getPropertyValueAs(const TagMap& tags, std::string_view key)
|
||||||
{
|
{
|
||||||
return getPropertyValueFirstMatchAs<T>(tags, {key});
|
return getPropertyValueFirstMatchAs<T>(tags, {key});
|
||||||
}
|
}
|
||||||
@@ -121,22 +121,22 @@ splitAndTrimString(std::string_view str, std::string_view delimiters)
|
|||||||
static
|
static
|
||||||
std::vector<Artist>
|
std::vector<Artist>
|
||||||
getArtists(const TagMap& tags,
|
getArtists(const TagMap& tags,
|
||||||
const std::vector<std::string_view>& artistTagNames,
|
std::initializer_list<std::string_view> artistTagNames,
|
||||||
const std::vector<std::string_view>& artistSortTagNames,
|
std::initializer_list<std::string_view> artistSortTagNames,
|
||||||
const std::vector<std::string_view>& artistMBIDTagNames
|
std::initializer_list<std::string_view> artistMBIDTagNames
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const std::vector<std::string> artistNames {getPropertyValuesFirstMatchAs<std::string>(tags, artistTagNames)};
|
const std::vector<std::string_view> artistNames {getPropertyValuesFirstMatchAs<std::string_view>(tags, artistTagNames)};
|
||||||
if (artistNames.empty())
|
if (artistNames.empty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
std::vector<Artist> artists;
|
std::vector<Artist> artists;
|
||||||
artists.reserve(artistNames.size());
|
artists.reserve(artistNames.size());
|
||||||
std::transform(std::cbegin(artistNames), std::cend(artistNames), std::back_inserter(artists),
|
std::transform(std::cbegin(artistNames), std::cend(artistNames), std::back_inserter(artists),
|
||||||
[&](const std::string& name) { return Artist {name}; });
|
[&](std::string_view name) { return Artist {name}; });
|
||||||
|
|
||||||
{
|
{
|
||||||
const std::vector<std::string> artistSortNames {getPropertyValuesFirstMatchAs<std::string>(tags, artistSortTagNames)};
|
const std::vector<std::string_view> artistSortNames {getPropertyValuesFirstMatchAs<std::string_view>(tags, artistSortTagNames)};
|
||||||
if (artistSortNames.size() == artists.size())
|
if (artistSortNames.size() == artists.size())
|
||||||
{
|
{
|
||||||
for (std::size_t i {}; i < artistSortNames.size(); ++i)
|
for (std::size_t i {}; i < artistSortNames.size(); ++i)
|
||||||
@@ -161,14 +161,14 @@ getArtists(const TagMap& tags,
|
|||||||
static
|
static
|
||||||
PerformerContainer
|
PerformerContainer
|
||||||
getPerformerArtists(const TagMap& tags,
|
getPerformerArtists(const TagMap& tags,
|
||||||
const std::vector<std::string_view>& artistTagNames)
|
std::initializer_list<std::string_view> artistTagNames)
|
||||||
{
|
{
|
||||||
PerformerContainer performers;
|
PerformerContainer performers;
|
||||||
|
|
||||||
// picard stores like this: (see https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#performer)
|
// picard stores like this: (see https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#performer)
|
||||||
// We may hit both styles for the same track
|
// We may hit both styles for the same track
|
||||||
// PERFORMER: artist (role)
|
// PERFORMER: artist (role)
|
||||||
if (const std::vector<std::string> artistNames {getPropertyValuesFirstMatchAs<std::string>(tags, artistTagNames)}; !artistNames.empty())
|
if (const std::vector<std::string_view> artistNames {getPropertyValuesFirstMatchAs<std::string_view>(tags, artistTagNames)}; !artistNames.empty())
|
||||||
{
|
{
|
||||||
for (std::string_view entry : artistNames)
|
for (std::string_view entry : artistNames)
|
||||||
{
|
{
|
||||||
@@ -216,7 +216,7 @@ getRelease(const TagMap& tags)
|
|||||||
if (!release->mediumCount)
|
if (!release->mediumCount)
|
||||||
{
|
{
|
||||||
// mediumCount may be encoded as "position/count"
|
// mediumCount may be encoded as "position/count"
|
||||||
if (const auto value {getPropertyValueAs<std::string>(tags, "DISCNUMBER")})
|
if (const auto value {getPropertyValueAs<std::string_view>(tags, "DISCNUMBER")})
|
||||||
{
|
{
|
||||||
// Expecting 'Number/Total'
|
// Expecting 'Number/Total'
|
||||||
const std::vector<std::string_view> strings {StringUtils::splitString(*value, "/") };
|
const std::vector<std::string_view> strings {StringUtils::splitString(*value, "/") };
|
||||||
@@ -225,6 +225,13 @@ getRelease(const TagMap& tags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
release->primaryType = getPropertyValueFirstMatchAs<MetaData::Release::PrimaryType>(tags, {"MUSICBRAINZ_ALBUMTYPE", "RELEASETYPE", "MUSICBRAINZ ALBUM TYPE", "MUSICBRAINZ/ALBUM TYPE"});
|
||||||
|
if (release->primaryType)
|
||||||
|
{
|
||||||
|
const auto secondaryTypes {getPropertyValuesFirstMatchAs<MetaData::Release::SecondaryType>(tags, {"MUSICBRAINZ_ALBUMTYPE", "RELEASETYPE", "MUSICBRAINZ ALBUM TYPE", "MUSICBRAINZ/ALBUM TYPE"})};
|
||||||
|
release->secondaryTypes.assign(std::cbegin(secondaryTypes), std::cend(secondaryTypes));
|
||||||
|
}
|
||||||
|
|
||||||
return release;
|
return release;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +248,7 @@ getMedium(const TagMap& tags)
|
|||||||
if (!medium->trackCount)
|
if (!medium->trackCount)
|
||||||
{
|
{
|
||||||
// totalTracks may be encoded as "position/count"
|
// totalTracks may be encoded as "position/count"
|
||||||
if (const auto value {getPropertyValueAs<std::string>(tags, "TRACKNUMBER")})
|
if (const auto value {getPropertyValueAs<std::string_view>(tags, "TRACKNUMBER")})
|
||||||
{
|
{
|
||||||
// Expecting 'Number/Total'
|
// Expecting 'Number/Total'
|
||||||
const std::vector<std::string_view> strings {StringUtils::splitString(*value, "/") };
|
const std::vector<std::string_view> strings {StringUtils::splitString(*value, "/") };
|
||||||
@@ -445,7 +452,7 @@ TagLibParser::parse(const std::filesystem::path& p, bool debug)
|
|||||||
|
|
||||||
for (const auto& [name, attributeList] : tag->attributeListMap())
|
for (const auto& [name, attributeList] : tag->attributeListMap())
|
||||||
{
|
{
|
||||||
std::string strName {name.to8Bit(true)};
|
std::string strName {StringUtils::stringToUpper(name.to8Bit(true))};
|
||||||
if (strName.find("WM/") == 0 || tags.find(strName) != std::cend(tags))
|
if (strName.find("WM/") == 0 || tags.find(strName) != std::cend(tags))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -461,7 +468,7 @@ TagLibParser::parse(const std::filesystem::path& p, bool debug)
|
|||||||
if (debug)
|
if (debug)
|
||||||
std::cout << "ASF property: '" << name << "'" << std::endl;
|
std::cout << "ASF property: '" << name << "'" << std::endl;
|
||||||
|
|
||||||
tags[strName] = std::move(attributes);
|
tags.emplace(strName, std::move(attributes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,3 +119,50 @@ namespace MetaData::Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace StringUtils
|
||||||
|
{
|
||||||
|
static bool iequals(std::string_view a, std::string_view b)
|
||||||
|
{
|
||||||
|
return std::equal(std::cbegin(a), std::cend(a),
|
||||||
|
std::cbegin(b), std::cend(b),
|
||||||
|
[](char a, char b) { return tolower(a) == tolower(b);}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
std::optional<MetaData::Release::PrimaryType> readAs(std::string_view str)
|
||||||
|
{
|
||||||
|
str = stringTrim(str);
|
||||||
|
|
||||||
|
if (iequals(str, "album"))
|
||||||
|
return MetaData::Release::PrimaryType::Album;
|
||||||
|
else if (iequals(str, "single"))
|
||||||
|
return MetaData::Release::PrimaryType::Single;
|
||||||
|
else if (iequals(str, "EP"))
|
||||||
|
return MetaData::Release::PrimaryType::EP;
|
||||||
|
else if (iequals(str, "broadcast"))
|
||||||
|
return MetaData::Release::PrimaryType::Broadcast;
|
||||||
|
else if (iequals(str, "other"))
|
||||||
|
return MetaData::Release::PrimaryType::Other;
|
||||||
|
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
std::optional<MetaData::Release::SecondaryType> readAs(std::string_view str)
|
||||||
|
{
|
||||||
|
str = stringTrim(str);
|
||||||
|
|
||||||
|
if (iequals(str, "compilation"))
|
||||||
|
return MetaData::Release::SecondaryType::Compilation;
|
||||||
|
else if (iequals(str, "soundtrack"))
|
||||||
|
return MetaData::Release::SecondaryType::Soundtrack;
|
||||||
|
else if (iequals(str, "live"))
|
||||||
|
return MetaData::Release::SecondaryType::Live;
|
||||||
|
else if (iequals(str, "demo"))
|
||||||
|
return MetaData::Release::SecondaryType::Demo;
|
||||||
|
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ namespace MetaData::Utils
|
|||||||
|
|
||||||
// format is "artist name (role)"
|
// format is "artist name (role)"
|
||||||
PerformerArtist extractPerformerAndRole(std::string_view entry);
|
PerformerArtist extractPerformerAndRole(std::string_view entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace StringUtils
|
||||||
|
{
|
||||||
|
template<>
|
||||||
|
std::optional<MetaData::Release::PrimaryType> readAs(std::string_view str);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
std::optional<MetaData::Release::SecondaryType> readAs(std::string_view str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <Wt/WDate.h>
|
#include <Wt/WDate.h>
|
||||||
|
#include "utils/EnumSet.hpp"
|
||||||
#include "utils/UUID.hpp"
|
#include "utils/UUID.hpp"
|
||||||
|
|
||||||
namespace MetaData
|
namespace MetaData
|
||||||
@@ -51,10 +52,37 @@ namespace MetaData
|
|||||||
|
|
||||||
struct Release
|
struct Release
|
||||||
{
|
{
|
||||||
|
// see https://musicbrainz.org/doc/Release_Group/Type
|
||||||
|
enum class PrimaryType
|
||||||
|
{
|
||||||
|
Album,
|
||||||
|
Single,
|
||||||
|
EP,
|
||||||
|
Broadcast,
|
||||||
|
Other
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class SecondaryType
|
||||||
|
{
|
||||||
|
Compilation,
|
||||||
|
Soundtrack,
|
||||||
|
Spokenword,
|
||||||
|
Interview,
|
||||||
|
Audiobook,
|
||||||
|
AudioDrama,
|
||||||
|
Live,
|
||||||
|
Remix,
|
||||||
|
DJMix,
|
||||||
|
Mixtape_Street,
|
||||||
|
Demo,
|
||||||
|
};
|
||||||
|
|
||||||
std::optional<UUID> mbid;
|
std::optional<UUID> mbid;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<Artist> artists;
|
std::vector<Artist> artists;
|
||||||
std::optional<std::size_t> mediumCount;
|
std::optional<std::size_t> mediumCount;
|
||||||
|
std::optional<PrimaryType> primaryType;
|
||||||
|
EnumSet<SecondaryType> secondaryTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Medium
|
struct Medium
|
||||||
|
|||||||
@@ -115,3 +115,60 @@ TEST(MetaData, extractPerformerAndRole)
|
|||||||
EXPECT_EQ(performer.role, testCase.expectedRole) << " str was '" << testCase.str << "'";
|
EXPECT_EQ(performer.role, testCase.expectedRole) << " str was '" << testCase.str << "'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(MetaData, primaryReleaseTypes)
|
||||||
|
{
|
||||||
|
using namespace MetaData;
|
||||||
|
|
||||||
|
struct TestCase
|
||||||
|
{
|
||||||
|
std::string str;
|
||||||
|
std::optional<Release::PrimaryType> result;
|
||||||
|
} testCases []
|
||||||
|
{
|
||||||
|
{ "", std::nullopt },
|
||||||
|
{ "album", Release::PrimaryType::Album },
|
||||||
|
{ "Album", Release::PrimaryType::Album },
|
||||||
|
{ " Album", Release::PrimaryType::Album },
|
||||||
|
{ "Album ", Release::PrimaryType::Album },
|
||||||
|
{ "ep", Release::PrimaryType::EP },
|
||||||
|
{ " ep ", Release::PrimaryType::EP },
|
||||||
|
{ "broadcast", Release::PrimaryType::Broadcast },
|
||||||
|
{ "single", Release::PrimaryType::Single },
|
||||||
|
{ "other", Release::PrimaryType::Other },
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const TestCase& testCase : testCases)
|
||||||
|
{
|
||||||
|
std::optional<Release::PrimaryType> parsed {StringUtils::readAs<Release::PrimaryType>(testCase.str)};
|
||||||
|
|
||||||
|
EXPECT_EQ(parsed, testCase.result) << " str was '" << testCase.str << "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MetaData, secondaryReleaseTypes)
|
||||||
|
{
|
||||||
|
using namespace MetaData;
|
||||||
|
|
||||||
|
struct TestCase
|
||||||
|
{
|
||||||
|
std::string str;
|
||||||
|
std::optional<Release::SecondaryType> result;
|
||||||
|
} testCases []
|
||||||
|
{
|
||||||
|
{ "", std::nullopt },
|
||||||
|
{ "compilation", Release::SecondaryType::Compilation },
|
||||||
|
{ " compilation ", Release::SecondaryType::Compilation },
|
||||||
|
{ "soundtrack", Release::SecondaryType::Soundtrack },
|
||||||
|
{ "live", Release::SecondaryType::Live },
|
||||||
|
{ "demo", Release::SecondaryType::Demo },
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const TestCase& testCase : testCases)
|
||||||
|
{
|
||||||
|
std::optional<Release::SecondaryType> parsed {StringUtils::readAs<Release::SecondaryType>(testCase.str)};
|
||||||
|
|
||||||
|
EXPECT_EQ(parsed, testCase.result) << " str was '" << testCase.str << "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "utils/Logger.hpp"
|
#include "utils/Logger.hpp"
|
||||||
#include "SqlQuery.hpp"
|
#include "SqlQuery.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
#include "EnumSetTraits.hpp"
|
||||||
#include "IdTypeTraits.hpp"
|
#include "IdTypeTraits.hpp"
|
||||||
|
|
||||||
namespace Database
|
namespace Database
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
#include <Wt/Dbo/StdSqlTraits.h>
|
||||||
|
|
||||||
|
#include "utils/EnumSet.hpp"
|
||||||
|
|
||||||
|
namespace Wt::Dbo
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct sql_value_traits<EnumSet<T>, void> : public sql_value_traits<long long>
|
||||||
|
{
|
||||||
|
using ValueType = typename EnumSet<T>::ValueType;
|
||||||
|
static_assert(sizeof(long long) > sizeof(ValueType));
|
||||||
|
|
||||||
|
static void bind(EnumSet<T> v, SqlStatement *statement, int column, int size)
|
||||||
|
{
|
||||||
|
sql_value_traits<long long>::bind(static_cast<long long>(v.getBitfield()), statement, column, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool read(EnumSet<T>& v, SqlStatement *statement, int column, int size)
|
||||||
|
{
|
||||||
|
long long val;
|
||||||
|
if (sql_value_traits<long long>::read(val, statement, column, size))
|
||||||
|
{
|
||||||
|
v.setBitfield(val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
v.clear();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@@ -653,6 +653,18 @@ CREATE TABLE IF NOT EXISTS "track_backup" (
|
|||||||
ScanSettings::get(session).modify()->incScanVersion();
|
ScanSettings::get(session).modify()->incScanVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
migrateFromV39(Session& session)
|
||||||
|
{
|
||||||
|
// add release type
|
||||||
|
session.getDboSession().execute("ALTER TABLE release ADD primary_type INTEGER");
|
||||||
|
session.getDboSession().execute("ALTER TABLE release ADD secondary_types INTEGER");
|
||||||
|
|
||||||
|
// Just increment the scan version of the settings to make the next scheduled scan rescan everything
|
||||||
|
ScanSettings::get(session).modify()->incScanVersion();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
doDbMigration(Session& session)
|
doDbMigration(Session& session)
|
||||||
{
|
{
|
||||||
@@ -698,6 +710,7 @@ CREATE TABLE IF NOT EXISTS "track_backup" (
|
|||||||
{36, migrateFromV36},
|
{36, migrateFromV36},
|
||||||
{37, migrateFromV37},
|
{37, migrateFromV37},
|
||||||
{38, migrateFromV38},
|
{38, migrateFromV38},
|
||||||
|
{39, migrateFromV39},
|
||||||
};
|
};
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Database
|
|||||||
class Session;
|
class Session;
|
||||||
|
|
||||||
using Version = std::size_t;
|
using Version = std::size_t;
|
||||||
static constexpr Version LMS_DATABASE_VERSION {39};
|
static constexpr Version LMS_DATABASE_VERSION {40};
|
||||||
class VersionInfo
|
class VersionInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "services/database/User.hpp"
|
#include "services/database/User.hpp"
|
||||||
#include "utils/Logger.hpp"
|
#include "utils/Logger.hpp"
|
||||||
#include "SqlQuery.hpp"
|
#include "SqlQuery.hpp"
|
||||||
|
#include "EnumSetTraits.hpp"
|
||||||
#include "IdTypeTraits.hpp"
|
#include "IdTypeTraits.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
|
||||||
@@ -138,6 +139,11 @@ createQuery(Session& session, const Release::FindParameters& params)
|
|||||||
query.where(oss.str());
|
query.where(oss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.primaryType)
|
||||||
|
query.where("primary_type = ?").bind(*params.primaryType);
|
||||||
|
if (!params.secondaryTypes.empty())
|
||||||
|
query.where("secondary_type = ?").bind(params.secondaryTypes);
|
||||||
|
|
||||||
switch (params.sortMethod)
|
switch (params.sortMethod)
|
||||||
{
|
{
|
||||||
case ReleaseSortMethod::None:
|
case ReleaseSortMethod::None:
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "services/database/TrackList.hpp"
|
#include "services/database/TrackList.hpp"
|
||||||
#include "services/database/TrackFeatures.hpp"
|
#include "services/database/TrackFeatures.hpp"
|
||||||
#include "services/database/User.hpp"
|
#include "services/database/User.hpp"
|
||||||
|
#include "EnumSetTraits.hpp"
|
||||||
#include "Migration.hpp"
|
#include "Migration.hpp"
|
||||||
|
|
||||||
namespace Database
|
namespace Database
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ class Release : public Object<Release, ReleaseId>
|
|||||||
ArtistId artist; // only releases that involved this user
|
ArtistId artist; // only releases that involved this user
|
||||||
EnumSet<TrackArtistLinkType> trackArtistLinkTypes; // and for these link types
|
EnumSet<TrackArtistLinkType> trackArtistLinkTypes; // and for these link types
|
||||||
EnumSet<TrackArtistLinkType> excludedTrackArtistLinkTypes; // but not for these link types
|
EnumSet<TrackArtistLinkType> excludedTrackArtistLinkTypes; // but not for these link types
|
||||||
|
std::optional<ReleaseTypePrimary> primaryType; // if, set, matching this primary type
|
||||||
|
EnumSet<ReleaseTypeSecondary> secondaryTypes; // Matching all this (if any)
|
||||||
|
|
||||||
FindParameters& setClusters(const std::vector<ClusterId>& _clusters) { clusters = _clusters; return *this; }
|
FindParameters& setClusters(const std::vector<ClusterId>& _clusters) { clusters = _clusters; return *this; }
|
||||||
FindParameters& setKeywords(const std::vector<std::string_view>& _keywords) { keywords = _keywords; return *this; }
|
FindParameters& setKeywords(const std::vector<std::string_view>& _keywords) { keywords = _keywords; return *this; }
|
||||||
@@ -109,11 +111,15 @@ class Release : public Object<Release, ReleaseId>
|
|||||||
std::size_t getDiscCount() const; // may not be total disc (if incomplete for example)
|
std::size_t getDiscCount() const; // may not be total disc (if incomplete for example)
|
||||||
std::chrono::milliseconds getDuration() const;
|
std::chrono::milliseconds getDuration() const;
|
||||||
Wt::WDateTime getLastWritten() const;
|
Wt::WDateTime getLastWritten() const;
|
||||||
|
std::optional<ReleaseTypePrimary> getPrimaryType() const { return _primaryType; }
|
||||||
|
EnumSet<ReleaseTypeSecondary> getSecondaryTypes() const { return _secondaryTypes; }
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
void setName(std::string_view name) { _name = name; }
|
void setName(std::string_view name) { _name = name; }
|
||||||
void setMBID(const std::optional<UUID>& mbid) { _MBID = mbid ? mbid->getAsString() : ""; }
|
void setMBID(const std::optional<UUID>& mbid) { _MBID = mbid ? mbid->getAsString() : ""; }
|
||||||
void setTotalDisc(std::optional<int> totalDisc) { _totalDisc = totalDisc; }
|
void setTotalDisc(std::optional<int> totalDisc) { _totalDisc = totalDisc; }
|
||||||
|
void setPrimaryType(std::optional<ReleaseTypePrimary> type) { _primaryType = type; }
|
||||||
|
void setSecondaryTypes(EnumSet<ReleaseTypeSecondary> types) { _secondaryTypes = types; }
|
||||||
|
|
||||||
// Get the artists of this release
|
// Get the artists of this release
|
||||||
std::vector<ObjectPtr<Artist>> getArtists(TrackArtistLinkType type = TrackArtistLinkType::Artist) const;
|
std::vector<ObjectPtr<Artist>> getArtists(TrackArtistLinkType type = TrackArtistLinkType::Artist) const;
|
||||||
@@ -128,6 +134,8 @@ class Release : public Object<Release, ReleaseId>
|
|||||||
Wt::Dbo::field(a, _name, "name");
|
Wt::Dbo::field(a, _name, "name");
|
||||||
Wt::Dbo::field(a, _MBID, "mbid");
|
Wt::Dbo::field(a, _MBID, "mbid");
|
||||||
Wt::Dbo::field(a, _totalDisc, "total_disc");
|
Wt::Dbo::field(a, _totalDisc, "total_disc");
|
||||||
|
Wt::Dbo::field(a, _primaryType, "primary_type");
|
||||||
|
Wt::Dbo::field(a, _secondaryTypes, "secondary_types");
|
||||||
|
|
||||||
Wt::Dbo::hasMany(a, _tracks, Wt::Dbo::ManyToOne, "release");
|
Wt::Dbo::hasMany(a, _tracks, Wt::Dbo::ManyToOne, "release");
|
||||||
}
|
}
|
||||||
@@ -139,9 +147,11 @@ class Release : public Object<Release, ReleaseId>
|
|||||||
|
|
||||||
static constexpr std::size_t _maxNameLength {128};
|
static constexpr std::size_t _maxNameLength {128};
|
||||||
|
|
||||||
std::string _name;
|
std::string _name;
|
||||||
std::string _MBID;
|
std::string _MBID;
|
||||||
std::optional<int> _totalDisc {};
|
std::optional<int> _totalDisc {};
|
||||||
|
std::optional<ReleaseTypePrimary> _primaryType;
|
||||||
|
EnumSet<ReleaseTypeSecondary> _secondaryTypes;
|
||||||
|
|
||||||
Wt::Dbo::collection<Wt::Dbo::ptr<Track>> _tracks; // Tracks in the release
|
Wt::Dbo::collection<Wt::Dbo::ptr<Track>> _tracks; // Tracks in the release
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -191,5 +191,30 @@ namespace Database
|
|||||||
Playlist, // user controlled playlists
|
Playlist, // user controlled playlists
|
||||||
Internal, // internal usage (current playqueue, history, ...)
|
Internal, // internal usage (current playqueue, history, ...)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// as defined in https://musicbrainz.org/doc/Release_Group/Type
|
||||||
|
enum class ReleaseTypePrimary
|
||||||
|
{
|
||||||
|
Album,
|
||||||
|
Single,
|
||||||
|
EP,
|
||||||
|
Broadcast,
|
||||||
|
Other,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ReleaseTypeSecondary
|
||||||
|
{
|
||||||
|
Compilation,
|
||||||
|
Soundtrack,
|
||||||
|
Spokenword,
|
||||||
|
Interview,
|
||||||
|
Audiobook,
|
||||||
|
AudioDrama,
|
||||||
|
Live,
|
||||||
|
Remix,
|
||||||
|
DJMix,
|
||||||
|
Mixtape_Street,
|
||||||
|
Demo,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -507,3 +507,26 @@ TEST_F(DatabaseFixture, Release_getDiscCount)
|
|||||||
EXPECT_EQ(release.get()->getDiscCount(), 2);
|
EXPECT_EQ(release.get()->getDiscCount(), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DatabaseFixture, Release_releaseType)
|
||||||
|
{
|
||||||
|
ScopedRelease release {session, "MyRelease"};
|
||||||
|
|
||||||
|
{
|
||||||
|
auto transaction {session.createSharedTransaction()};
|
||||||
|
EXPECT_EQ(release.get()->getPrimaryType(), std::nullopt);
|
||||||
|
EXPECT_EQ(release.get()->getSecondaryTypes(), EnumSet<ReleaseTypeSecondary> {});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto transaction {session.createUniqueTransaction()};
|
||||||
|
release.get().modify()->setPrimaryType({ ReleaseTypePrimary::Album });
|
||||||
|
release.get().modify()->setSecondaryTypes({ ReleaseTypeSecondary::Compilation });
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto transaction {session.createSharedTransaction()};
|
||||||
|
EXPECT_EQ(release.get()->getPrimaryType(), ReleaseTypePrimary::Album);
|
||||||
|
EXPECT_TRUE(release.get()->getSecondaryTypes().contains(ReleaseTypeSecondary::Compilation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -115,6 +115,67 @@ namespace
|
|||||||
return artists;
|
return artists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReleaseTypePrimary convertReleaseTypePrimary(MetaData::Release::PrimaryType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MetaData::Release::PrimaryType::Album: return ReleaseTypePrimary::Album;
|
||||||
|
case MetaData::Release::PrimaryType::Single: return ReleaseTypePrimary::Single;
|
||||||
|
case MetaData::Release::PrimaryType::EP: return ReleaseTypePrimary::EP;
|
||||||
|
case MetaData::Release::PrimaryType::Broadcast: return ReleaseTypePrimary::Broadcast;
|
||||||
|
case MetaData::Release::PrimaryType::Other: return ReleaseTypePrimary::Other;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReleaseTypePrimary::Other;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnumSet<ReleaseTypeSecondary> convertReleaseTypesSecondary(EnumSet<MetaData::Release::SecondaryType> types)
|
||||||
|
{
|
||||||
|
EnumSet<ReleaseTypeSecondary> res;
|
||||||
|
|
||||||
|
for (MetaData::Release::SecondaryType type : types)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MetaData::Release::SecondaryType::Compilation:
|
||||||
|
res.insert(ReleaseTypeSecondary::Compilation);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::Soundtrack:
|
||||||
|
res.insert(ReleaseTypeSecondary::Soundtrack);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::Spokenword:
|
||||||
|
res.insert(ReleaseTypeSecondary::Spokenword);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::Interview:
|
||||||
|
res.insert(ReleaseTypeSecondary::Interview);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::Audiobook:
|
||||||
|
res.insert(ReleaseTypeSecondary::Audiobook);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::AudioDrama:
|
||||||
|
res.insert(ReleaseTypeSecondary::AudioDrama);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::Live:
|
||||||
|
res.insert(ReleaseTypeSecondary::Live);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::Remix:
|
||||||
|
res.insert(ReleaseTypeSecondary::Remix);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::DJMix:
|
||||||
|
res.insert(ReleaseTypeSecondary::DJMix);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::Mixtape_Street:
|
||||||
|
res.insert(ReleaseTypeSecondary::Mixtape_Street);
|
||||||
|
break;
|
||||||
|
case MetaData::Release::SecondaryType::Demo:
|
||||||
|
res.insert(ReleaseTypeSecondary::Demo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updateReleaseIfNeeded(Release::pointer release, const MetaData::Release& releaseInfo)
|
updateReleaseIfNeeded(Release::pointer release, const MetaData::Release& releaseInfo)
|
||||||
{
|
{
|
||||||
@@ -122,6 +183,15 @@ namespace
|
|||||||
release.modify()->setName(releaseInfo.name);
|
release.modify()->setName(releaseInfo.name);
|
||||||
if (release->getTotalDisc() != releaseInfo.mediumCount)
|
if (release->getTotalDisc() != releaseInfo.mediumCount)
|
||||||
release.modify()->setTotalDisc(releaseInfo.mediumCount);
|
release.modify()->setTotalDisc(releaseInfo.mediumCount);
|
||||||
|
if (releaseInfo.primaryType)
|
||||||
|
{
|
||||||
|
const ReleaseTypePrimary primaryType {convertReleaseTypePrimary(*releaseInfo.primaryType)};
|
||||||
|
if (release->getPrimaryType() != primaryType)
|
||||||
|
release.modify()->setPrimaryType(primaryType);
|
||||||
|
}
|
||||||
|
const EnumSet<ReleaseTypeSecondary> secondaryTypes {convertReleaseTypesSecondary(releaseInfo.secondaryTypes)};
|
||||||
|
if (release->getSecondaryTypes() != secondaryTypes)
|
||||||
|
release.modify()->setSecondaryTypes(secondaryTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
Release::pointer
|
Release::pointer
|
||||||
|
|||||||
@@ -63,6 +63,13 @@ readAs(std::string_view str)
|
|||||||
return std::string {str};
|
return std::string {str};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
std::optional<std::string_view>
|
||||||
|
readAs(std::string_view str)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::optional<bool>
|
std::optional<bool>
|
||||||
readAs(std::string_view str)
|
readAs(std::string_view str)
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ class EnumSet
|
|||||||
static_assert(std::is_enum<T>::value);
|
static_assert(std::is_enum<T>::value);
|
||||||
static_assert(std::is_same<underlying_type, std::uint64_t>::value || std::is_same<underlying_type, std::uint32_t>::value);
|
static_assert(std::is_same<underlying_type, std::uint64_t>::value || std::is_same<underlying_type, std::uint32_t>::value);
|
||||||
|
|
||||||
using index_type = std::uint_fast8_t;
|
using IndexType = std::uint_fast8_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using ValueType = underlying_type;
|
||||||
|
|
||||||
EnumSet() = default;
|
EnumSet() = default;
|
||||||
constexpr EnumSet(std::initializer_list<T> values)
|
constexpr EnumSet(std::initializer_list<T> values)
|
||||||
{
|
{
|
||||||
@@ -44,6 +46,13 @@ class EnumSet
|
|||||||
template <typename It>
|
template <typename It>
|
||||||
constexpr EnumSet(It begin, It end)
|
constexpr EnumSet(It begin, It end)
|
||||||
{
|
{
|
||||||
|
assign(begin, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename It>
|
||||||
|
constexpr void assign(It begin, It end)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
for (It it {begin}; it != end; ++it)
|
for (It it {begin}; it != end; ++it)
|
||||||
insert(*it);
|
insert(*it);
|
||||||
}
|
}
|
||||||
@@ -71,6 +80,11 @@ class EnumSet
|
|||||||
return _bitfield & (underlying_type{ 1 } << static_cast<underlying_type>(value));
|
return _bitfield & (underlying_type{ 1 } << static_cast<underlying_type>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr void clear()
|
||||||
|
{
|
||||||
|
_bitfield = 0;
|
||||||
|
}
|
||||||
|
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -100,14 +114,14 @@ class EnumSet
|
|||||||
private:
|
private:
|
||||||
friend class EnumSet;
|
friend class EnumSet;
|
||||||
|
|
||||||
constexpr iterator(const EnumSet& _container, index_type _index)
|
constexpr iterator(const EnumSet& _container, IndexType _index)
|
||||||
: _container {_container}
|
: _container {_container}
|
||||||
, _index {_index}
|
, _index {_index}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const EnumSet& _container;
|
const EnumSet& _container;
|
||||||
index_type _index;
|
IndexType _index;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr iterator begin() const
|
constexpr iterator begin() const
|
||||||
@@ -120,25 +134,45 @@ class EnumSet
|
|||||||
return iterator {*this, npos};
|
return iterator {*this, npos};
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
constexpr underlying_type getBitfield() const
|
||||||
static_assert(std::numeric_limits<index_type>::max() >= sizeof(underlying_type) * 8);
|
{
|
||||||
enum : index_type { npos = sizeof(underlying_type) * 8 };
|
return _bitfield;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr index_type getFirstBitSetIndex(index_type start = {}) const
|
constexpr void setBitfield(underlying_type bitfield)
|
||||||
|
{
|
||||||
|
_bitfield = bitfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool operator==(const EnumSet other) const
|
||||||
|
{
|
||||||
|
return _bitfield == other._bitfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool operator!=(const EnumSet other) const
|
||||||
|
{
|
||||||
|
return _bitfield != other._bitfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static_assert(std::numeric_limits<IndexType>::max() >= sizeof(underlying_type) * 8);
|
||||||
|
enum : IndexType { npos = sizeof(underlying_type) * 8 };
|
||||||
|
|
||||||
|
constexpr IndexType getFirstBitSetIndex(IndexType start = {}) const
|
||||||
{
|
{
|
||||||
assert(start < npos);
|
assert(start < npos);
|
||||||
|
|
||||||
// return npos if no bit found
|
// return npos if no bit found
|
||||||
index_type res {countTrailingZero(_bitfield >> start)};
|
IndexType res {countTrailingZero(_bitfield >> start)};
|
||||||
if (res == npos)
|
if (res == npos)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
return res + start;
|
return res + start;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr index_type countTrailingZero(underlying_type bitField)
|
static constexpr IndexType countTrailingZero(underlying_type bitField)
|
||||||
{
|
{
|
||||||
index_type res {};
|
IndexType res {};
|
||||||
|
|
||||||
while (res < (sizeof(underlying_type) * 8) && (bitField & 1) == 0)
|
while (res < (sizeof(underlying_type) * 8) && (bitField & 1) == 0)
|
||||||
{
|
{
|
||||||
@@ -154,5 +188,3 @@ class EnumSet
|
|||||||
|
|
||||||
underlying_type _bitfield{};
|
underlying_type _bitfield{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ template<>
|
|||||||
std::optional<std::string>
|
std::optional<std::string>
|
||||||
readAs(std::string_view str);
|
readAs(std::string_view str);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
[[nodiscard]]
|
||||||
|
std::optional<std::string_view>
|
||||||
|
readAs(std::string_view str);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
std::optional<bool>
|
std::optional<bool>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
|
|
||||||
add_executable(test-utils
|
add_executable(test-utils
|
||||||
String.cpp
|
EnumSet.cpp
|
||||||
RecursiveSharedMutex.cpp
|
RecursiveSharedMutex.cpp
|
||||||
|
String.cpp
|
||||||
Utils.cpp
|
Utils.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "utils/EnumSet.hpp"
|
||||||
|
|
||||||
|
TEST(EnumSet, ctr)
|
||||||
|
{
|
||||||
|
enum class Foo
|
||||||
|
{
|
||||||
|
One,
|
||||||
|
Two,
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
constexpr EnumSet<Foo> test {Foo::One};
|
||||||
|
|
||||||
|
static_assert(!test.empty());
|
||||||
|
static_assert(test.contains(Foo::One));
|
||||||
|
static_assert(!test.contains(Foo::Two));
|
||||||
|
|
||||||
|
EXPECT_TRUE(!test.empty());
|
||||||
|
EXPECT_TRUE(test.contains(Foo::One));
|
||||||
|
EXPECT_FALSE(test.contains(Foo::Two));
|
||||||
|
|
||||||
|
static_assert(test.getBitfield() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
constexpr EnumSet<Foo> test {Foo::One, Foo::Two};
|
||||||
|
constexpr auto bitfield {test.getBitfield()};
|
||||||
|
|
||||||
|
EnumSet<Foo> test2;
|
||||||
|
EXPECT_FALSE(test2.contains(Foo::One));
|
||||||
|
EXPECT_FALSE(test2.contains(Foo::Two));
|
||||||
|
|
||||||
|
test2.setBitfield(bitfield);
|
||||||
|
|
||||||
|
EXPECT_TRUE(test2.contains(Foo::One));
|
||||||
|
EXPECT_TRUE(test2.contains(Foo::Two));
|
||||||
|
EXPECT_EQ(test, test2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,7 +34,7 @@ add_executable(lms
|
|||||||
ui/explore/Filters.cpp
|
ui/explore/Filters.cpp
|
||||||
ui/explore/PlayQueueController.cpp
|
ui/explore/PlayQueueController.cpp
|
||||||
ui/explore/ReleaseCollector.cpp
|
ui/explore/ReleaseCollector.cpp
|
||||||
ui/explore/ReleaseListHelpers.cpp
|
ui/explore/ReleaseHelpers.cpp
|
||||||
ui/explore/ReleasesView.cpp
|
ui/explore/ReleasesView.cpp
|
||||||
ui/explore/ReleaseView.cpp
|
ui/explore/ReleaseView.cpp
|
||||||
ui/explore/SearchView.cpp
|
ui/explore/SearchView.cpp
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#include "LmsApplication.hpp"
|
#include "LmsApplication.hpp"
|
||||||
#include "LmsApplicationException.hpp"
|
#include "LmsApplicationException.hpp"
|
||||||
#include "PlayQueueController.hpp"
|
#include "PlayQueueController.hpp"
|
||||||
#include "ReleaseListHelpers.hpp"
|
#include "ReleaseHelpers.hpp"
|
||||||
#include "TrackListHelpers.hpp"
|
#include "TrackListHelpers.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
|
||||||
@@ -48,6 +48,19 @@ using namespace Database;
|
|||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
|
|
||||||
|
bool
|
||||||
|
Artist::ReleaseType::operator<(const ReleaseType& other) const
|
||||||
|
{
|
||||||
|
if (!primaryType && other.primaryType)
|
||||||
|
return false;
|
||||||
|
else if (primaryType && !other.primaryType)
|
||||||
|
return true;
|
||||||
|
else if (*primaryType == *other.primaryType)
|
||||||
|
return secondaryTypes.getBitfield() < other.secondaryTypes.getBitfield();
|
||||||
|
else
|
||||||
|
return static_cast<int>(*primaryType) < static_cast<int>(*other.primaryType);
|
||||||
|
}
|
||||||
|
|
||||||
Artist::Artist(Filters& filters, PlayQueueController& controller)
|
Artist::Artist(Filters& filters, PlayQueueController& controller)
|
||||||
: Template {Wt::WString::tr("Lms.Explore.Artist.template")}
|
: Template {Wt::WString::tr("Lms.Explore.Artist.template")}
|
||||||
, _filters {filters}
|
, _filters {filters}
|
||||||
@@ -114,15 +127,12 @@ Artist::refreshView()
|
|||||||
LmsApp->setTitle(artist->getName());
|
LmsApp->setTitle(artist->getName());
|
||||||
_artistId = *artistId;
|
_artistId = *artistId;
|
||||||
|
|
||||||
bool setReleaseTitle {};
|
|
||||||
refreshReleases();
|
refreshReleases();
|
||||||
setReleaseTitle |= refreshAppearsOnReleases();
|
refreshAppearsOnReleases();
|
||||||
setReleaseTitle |= refreshNonReleaseTracks();
|
refreshNonReleaseTracks();
|
||||||
refreshLinks(artist);
|
refreshLinks(artist);
|
||||||
refreshSimilarArtists(similarArtistIds);
|
refreshSimilarArtists(similarArtistIds);
|
||||||
|
|
||||||
setCondition("if-release-title", setReleaseTitle);
|
|
||||||
|
|
||||||
Wt::WContainerWidget* clusterContainers {bindNew<Wt::WContainerWidget>("clusters")};
|
Wt::WContainerWidget* clusterContainers {bindNew<Wt::WContainerWidget>("clusters")};
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -184,25 +194,57 @@ Artist::refreshView()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
Artist::refreshReleases()
|
Artist::refreshReleases()
|
||||||
{
|
{
|
||||||
_releaseContainer = bindNew<InfiniteScrollingContainer>("releases", Wt::WString::tr("Lms.Explore.Releases.template.container"));
|
_releaseContainers.clear();
|
||||||
_releaseContainer->onRequestElements.connect(this, [this]
|
|
||||||
|
Release::FindParameters params;
|
||||||
|
params.setClusters(_filters.getClusterIds());
|
||||||
|
params.setArtist(_artistId, {TrackArtistLinkType::ReleaseArtist}, {});
|
||||||
|
params.setSortMethod(ReleaseSortMethod::DateDesc);
|
||||||
|
|
||||||
|
const auto releases {Release::find(LmsApp->getDbSession(), params)};
|
||||||
|
if (!releases.results.empty())
|
||||||
{
|
{
|
||||||
addSomeReleases(*_releaseContainer, {TrackArtistLinkType::ReleaseArtist}, {});
|
// first pass: gather all ids and sort by type
|
||||||
});
|
for (const ReleaseId releaseId : releases.results)
|
||||||
|
{
|
||||||
|
const Database::Release::pointer release {Database::Release::find(LmsApp->getDbSession(), releaseId)};
|
||||||
|
|
||||||
const bool added {addSomeReleases(*_releaseContainer, {TrackArtistLinkType::ReleaseArtist}, {})};
|
ReleaseType releaseType {release->getPrimaryType(), release->getSecondaryTypes()};
|
||||||
setCondition("if-has-releases", added);
|
_releaseContainers[releaseType].releases.push_back(releaseId);
|
||||||
|
}
|
||||||
|
|
||||||
return added;
|
// second pass: construct widgets
|
||||||
|
Wt::WContainerWidget* releaseContainers {bindNew<Wt::WContainerWidget>("release-containers")};
|
||||||
|
for (auto& [releaseType, releases] : _releaseContainers)
|
||||||
|
{
|
||||||
|
Wt::WTemplate* releaseContainer {releaseContainers->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Artist.template.release-container"))};
|
||||||
|
|
||||||
|
if (releaseType.primaryType)
|
||||||
|
releaseContainer->bindString("release-type", ReleaseHelpers::buildReleaseTypeString(*releaseType.primaryType, releaseType.secondaryTypes));
|
||||||
|
else
|
||||||
|
releaseContainer->bindString("release-type", Wt::WString::tr("Lms.Explore.releases")); // fallback when not tagged with MB
|
||||||
|
|
||||||
|
releases.container = releaseContainer->bindNew<InfiniteScrollingContainer>("releases", Wt::WString::tr("Lms.Explore.Releases.template.container"));
|
||||||
|
releases.container->onRequestElements.connect(this, [this, &releases = releases]
|
||||||
|
{
|
||||||
|
addSomeReleases(releases);
|
||||||
|
});
|
||||||
|
releases.container->setHasMore(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bindEmpty("release-containers");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
Artist::refreshAppearsOnReleases()
|
Artist::refreshAppearsOnReleases()
|
||||||
{
|
{
|
||||||
const EnumSet<TrackArtistLinkType> types
|
constexpr EnumSet<TrackArtistLinkType> types
|
||||||
{
|
{
|
||||||
TrackArtistLinkType::Artist,
|
TrackArtistLinkType::Artist,
|
||||||
TrackArtistLinkType::Arranger,
|
TrackArtistLinkType::Arranger,
|
||||||
@@ -216,18 +258,33 @@ Artist::refreshAppearsOnReleases()
|
|||||||
TrackArtistLinkType::Writer,
|
TrackArtistLinkType::Writer,
|
||||||
};
|
};
|
||||||
|
|
||||||
_appearsOnReleaseContainer = bindNew<InfiniteScrollingContainer>("appears-on-releases", Wt::WString::tr("Lms.Explore.Releases.template.container"));
|
_appearsOnReleaseContainer = {};
|
||||||
_appearsOnReleaseContainer->onRequestElements.connect(this, [=]
|
|
||||||
{
|
|
||||||
addSomeReleases(*_appearsOnReleaseContainer, types, {TrackArtistLinkType::ReleaseArtist});
|
|
||||||
});
|
|
||||||
|
|
||||||
const bool added {addSomeReleases(*_appearsOnReleaseContainer, types, {TrackArtistLinkType::ReleaseArtist})};
|
Release::FindParameters params;
|
||||||
setCondition("if-has-appears-on-releases", added);
|
params.setClusters(_filters.getClusterIds());
|
||||||
return added;
|
params.setArtist(_artistId, types, {TrackArtistLinkType::ReleaseArtist});
|
||||||
|
params.setSortMethod(ReleaseSortMethod::DateDesc);
|
||||||
|
|
||||||
|
const auto releases {Release::find(LmsApp->getDbSession(), params)};
|
||||||
|
if (!releases.results.empty())
|
||||||
|
{
|
||||||
|
Wt::WTemplate* releaseContainer {bindNew<Wt::WTemplate>("appears-on-releases", Wt::WString::tr("Lms.Explore.Artist.template.release-container"))};
|
||||||
|
releaseContainer->bindString("release-type", Wt::WString::tr("Lms.Explore.Artist.appears-on"));
|
||||||
|
_appearsOnReleaseContainer.releases = releases.results;
|
||||||
|
_appearsOnReleaseContainer.container = releaseContainer->bindNew<InfiniteScrollingContainer>("releases", Wt::WString::tr("Lms.Explore.Releases.template.container"));
|
||||||
|
_appearsOnReleaseContainer.container->onRequestElements.connect(this, [this, &releases]
|
||||||
|
{
|
||||||
|
addSomeReleases(_appearsOnReleaseContainer);
|
||||||
|
});
|
||||||
|
_appearsOnReleaseContainer.container->setHasMore(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bindEmpty("appears-on-releases");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
Artist::refreshNonReleaseTracks()
|
Artist::refreshNonReleaseTracks()
|
||||||
{
|
{
|
||||||
setCondition("if-has-non-release-tracks", true);
|
setCondition("if-has-non-release-tracks", true);
|
||||||
@@ -239,7 +296,6 @@ Artist::refreshNonReleaseTracks()
|
|||||||
|
|
||||||
const bool added {addSomeNonReleaseTracks()};
|
const bool added {addSomeNonReleaseTracks()};
|
||||||
setCondition("if-has-non-release-tracks", added);
|
setCondition("if-has-non-release-tracks", added);
|
||||||
return added;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -272,35 +328,24 @@ Artist::refreshLinks(const Database::Artist::pointer& artist)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
Artist::addSomeReleases(InfiniteScrollingContainer& releaseContainer, EnumSet<Database::TrackArtistLinkType> linkTypes, EnumSet<Database::TrackArtistLinkType> excludedLinkTypes)
|
Artist::addSomeReleases(ReleaseContainer& releaseContainer)
|
||||||
{
|
{
|
||||||
bool areArtistsAdded{};
|
|
||||||
auto transaction {LmsApp->getDbSession().createSharedTransaction()};
|
auto transaction {LmsApp->getDbSession().createSharedTransaction()};
|
||||||
|
|
||||||
const Database::Artist::pointer artist {Database::Artist::find(LmsApp->getDbSession(), _artistId)};
|
if (const Database::Artist::pointer artist {Database::Artist::find(LmsApp->getDbSession(), _artistId)})
|
||||||
if (!artist)
|
|
||||||
return areArtistsAdded;
|
|
||||||
|
|
||||||
const Range range {static_cast<std::size_t>(releaseContainer.getCount()), _releasesBatchSize};
|
|
||||||
|
|
||||||
Release::FindParameters params;
|
|
||||||
params.setClusters(_filters.getClusterIds());
|
|
||||||
params.setArtist(_artistId, linkTypes, excludedLinkTypes);
|
|
||||||
params.setRange(range);
|
|
||||||
params.setSortMethod(ReleaseSortMethod::DateDesc);
|
|
||||||
|
|
||||||
const auto releases {Release::find(LmsApp->getDbSession(), params)};
|
|
||||||
for (const ReleaseId releaseId : releases.results)
|
|
||||||
{
|
{
|
||||||
const Database::Release::pointer release {Database::Release::find(LmsApp->getDbSession(), releaseId)};
|
for (std::size_t i {static_cast<std::size_t>(releaseContainer.container->getCount())}; i < releaseContainer.releases.size(); ++i)
|
||||||
releaseContainer.add(ReleaseListHelpers::createEntryForArtist(release, artist));
|
{
|
||||||
areArtistsAdded = true;
|
const Database::Release::pointer release {Database::Release::find(LmsApp->getDbSession(), releaseContainer.releases[i])};
|
||||||
|
releaseContainer.container->add(ReleaseListHelpers::createEntryForArtist(release, artist));
|
||||||
|
}
|
||||||
|
releaseContainer.container->setHasMore(releaseContainer.container->getCount() < releaseContainer.releases.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
releaseContainer.container->setHasMore(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseContainer.setHasMore(releases.moreResults);
|
|
||||||
|
|
||||||
return areArtistsAdded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -19,8 +19,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <optional>
|
||||||
#include "services/database/ArtistId.hpp"
|
#include "services/database/ArtistId.hpp"
|
||||||
#include "services/database/Object.hpp"
|
#include "services/database/Object.hpp"
|
||||||
|
#include "services/database/ReleaseId.hpp"
|
||||||
#include "services/database/Types.hpp"
|
#include "services/database/Types.hpp"
|
||||||
#include "utils/EnumSet.hpp"
|
#include "utils/EnumSet.hpp"
|
||||||
#include "common/Template.hpp"
|
#include "common/Template.hpp"
|
||||||
@@ -44,13 +47,14 @@ namespace UserInterface
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void refreshView();
|
void refreshView();
|
||||||
bool refreshReleases();
|
void refreshReleases();
|
||||||
bool refreshAppearsOnReleases();
|
void refreshAppearsOnReleases();
|
||||||
bool refreshNonReleaseTracks();
|
void refreshNonReleaseTracks();
|
||||||
void refreshSimilarArtists(const std::vector<Database::ArtistId>& similarArtistsId);
|
void refreshSimilarArtists(const std::vector<Database::ArtistId>& similarArtistsId);
|
||||||
void refreshLinks(const Database::ObjectPtr<Database::Artist>& artist);
|
void refreshLinks(const Database::ObjectPtr<Database::Artist>& artist);
|
||||||
|
|
||||||
bool addSomeReleases(InfiniteScrollingContainer& container, EnumSet<Database::TrackArtistLinkType> linkTypes, EnumSet<Database::TrackArtistLinkType> excludedLinkTypes);
|
struct ReleaseContainer;
|
||||||
|
void addSomeReleases(ReleaseContainer& releaseContainer);
|
||||||
bool addSomeNonReleaseTracks();
|
bool addSomeNonReleaseTracks();
|
||||||
static constexpr std::size_t _releasesBatchSize {6};
|
static constexpr std::size_t _releasesBatchSize {6};
|
||||||
static constexpr std::size_t _tracksBatchSize {6};
|
static constexpr std::size_t _tracksBatchSize {6};
|
||||||
@@ -58,8 +62,22 @@ namespace UserInterface
|
|||||||
|
|
||||||
Filters& _filters;
|
Filters& _filters;
|
||||||
PlayQueueController& _playQueueController;
|
PlayQueueController& _playQueueController;
|
||||||
InfiniteScrollingContainer* _releaseContainer {};
|
|
||||||
InfiniteScrollingContainer* _appearsOnReleaseContainer {};
|
struct ReleaseType
|
||||||
|
{
|
||||||
|
std::optional<Database::ReleaseTypePrimary> primaryType;
|
||||||
|
EnumSet<Database::ReleaseTypeSecondary> secondaryTypes;
|
||||||
|
|
||||||
|
bool operator<(const ReleaseType& other) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ReleaseContainer
|
||||||
|
{
|
||||||
|
InfiniteScrollingContainer* container {};
|
||||||
|
std::vector<Database::ReleaseId> releases;
|
||||||
|
};
|
||||||
|
std::map<ReleaseType, ReleaseContainer> _releaseContainers;
|
||||||
|
ReleaseContainer _appearsOnReleaseContainer {};
|
||||||
InfiniteScrollingContainer* _trackContainer {};
|
InfiniteScrollingContainer* _trackContainer {};
|
||||||
Database::ArtistId _artistId {};
|
Database::ArtistId _artistId {};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ReleaseListHelpers.hpp"
|
#include "ReleaseHelpers.hpp"
|
||||||
|
|
||||||
#include <Wt/WAnchor.h>
|
#include <Wt/WAnchor.h>
|
||||||
#include <Wt/WImage.h>
|
#include <Wt/WImage.h>
|
||||||
@@ -104,3 +104,42 @@ namespace UserInterface::ReleaseListHelpers
|
|||||||
}
|
}
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
namespace UserInterface::ReleaseHelpers
|
||||||
|
{
|
||||||
|
Wt::WString
|
||||||
|
buildReleaseTypeString(ReleaseTypePrimary primaryType, EnumSet<ReleaseTypeSecondary> secondaryTypes)
|
||||||
|
{
|
||||||
|
Wt::WString res;
|
||||||
|
|
||||||
|
switch (primaryType)
|
||||||
|
{
|
||||||
|
case ReleaseTypePrimary::Album: res = Wt::WString::tr("Lms.Explore.Release.type-primary-album"); break;
|
||||||
|
case ReleaseTypePrimary::Broadcast: res = Wt::WString::tr("Lms.Explore.Release.type-primary-broadcast"); break;
|
||||||
|
case ReleaseTypePrimary::EP: res = Wt::WString::tr("Lms.Explore.Release.type-primary-ep"); break;
|
||||||
|
case ReleaseTypePrimary::Single: res = Wt::WString::tr("Lms.Explore.Release.type-primary-single"); break;
|
||||||
|
case ReleaseTypePrimary::Other: res = Wt::WString::tr("Lms.Explore.Release.type-primary-other"); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ReleaseTypeSecondary secondaryType : secondaryTypes)
|
||||||
|
{
|
||||||
|
res += Wt::WString {" · "};
|
||||||
|
|
||||||
|
switch (secondaryType)
|
||||||
|
{
|
||||||
|
case ReleaseTypeSecondary::Compilation: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-compilation"); break;
|
||||||
|
case ReleaseTypeSecondary::Spokenword: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-spokenword"); break;
|
||||||
|
case ReleaseTypeSecondary::Soundtrack: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-soundtrack"); break;
|
||||||
|
case ReleaseTypeSecondary::Interview: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-interview"); break;
|
||||||
|
case ReleaseTypeSecondary::Audiobook: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-audiobook"); break;
|
||||||
|
case ReleaseTypeSecondary::AudioDrama: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-audiodrama"); break;
|
||||||
|
case ReleaseTypeSecondary::Live: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-live"); break;
|
||||||
|
case ReleaseTypeSecondary::Remix: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-remix"); break;
|
||||||
|
case ReleaseTypeSecondary::DJMix: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-djmix"); break;
|
||||||
|
case ReleaseTypeSecondary::Mixtape_Street: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-mixtape-street"); break;
|
||||||
|
case ReleaseTypeSecondary::Demo: res += Wt::WString::tr("Lms.Explore.Release.type-secondary-demo"); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
} // namespace UserInterface::ReleaseHelpers}
|
||||||
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include <Wt/WTemplate.h>
|
#include <Wt/WTemplate.h>
|
||||||
#include "services/database/Object.hpp"
|
#include "services/database/Object.hpp"
|
||||||
|
#include "services/database/Types.hpp"
|
||||||
|
#include "utils/EnumSet.hpp"
|
||||||
|
|
||||||
namespace Database
|
namespace Database
|
||||||
{
|
{
|
||||||
@@ -36,3 +38,7 @@ namespace UserInterface::ReleaseListHelpers
|
|||||||
std::unique_ptr<Wt::WTemplate> createEntryForArtist(const Database::ObjectPtr<Database::Release>& release, const Database::ObjectPtr<Database::Artist>& artist);
|
std::unique_ptr<Wt::WTemplate> createEntryForArtist(const Database::ObjectPtr<Database::Release>& release, const Database::ObjectPtr<Database::Artist>& artist);
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
namespace UserInterface::ReleaseHelpers
|
||||||
|
{
|
||||||
|
Wt::WString buildReleaseTypeString(Database::ReleaseTypePrimary primaryType, EnumSet<Database::ReleaseTypeSecondary> secondaryTypes);
|
||||||
|
}
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
#include "resource/DownloadResource.hpp"
|
#include "resource/DownloadResource.hpp"
|
||||||
#include "explore/Filters.hpp"
|
#include "explore/Filters.hpp"
|
||||||
#include "explore/PlayQueueController.hpp"
|
#include "explore/PlayQueueController.hpp"
|
||||||
#include "explore/ReleaseListHelpers.hpp"
|
#include "explore/ReleaseHelpers.hpp"
|
||||||
#include "explore/TrackListHelpers.hpp"
|
#include "explore/TrackListHelpers.hpp"
|
||||||
#include "LmsApplication.hpp"
|
#include "LmsApplication.hpp"
|
||||||
#include "LmsApplicationException.hpp"
|
#include "LmsApplicationException.hpp"
|
||||||
@@ -65,7 +65,12 @@ showReleaseInfoModal(Database::ReleaseId releaseId)
|
|||||||
Wt::WWidget* releaseInfoPtr {releaseInfo.get()};
|
Wt::WWidget* releaseInfoPtr {releaseInfo.get()};
|
||||||
releaseInfo->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
releaseInfo->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||||
|
|
||||||
Wt::WContainerWidget* artistTable {releaseInfo->bindNew<Wt::WContainerWidget>("artist-table")};
|
if (auto primaryReleaseType {release->getPrimaryType()})
|
||||||
|
{
|
||||||
|
releaseInfo->setCondition("if-has-release-type", true);
|
||||||
|
releaseInfo->bindString("release-type", ReleaseHelpers::buildReleaseTypeString(*primaryReleaseType, release->getSecondaryTypes()));
|
||||||
|
}
|
||||||
|
|
||||||
std::map<Wt::WString, std::set<ArtistId>> artistMap;
|
std::map<Wt::WString, std::set<ArtistId>> artistMap;
|
||||||
|
|
||||||
auto addArtists = [&](TrackArtistLinkType linkType, const char* type)
|
auto addArtists = [&](TrackArtistLinkType linkType, const char* type)
|
||||||
@@ -116,13 +121,19 @@ showReleaseInfoModal(Database::ReleaseId releaseId)
|
|||||||
artistMap.erase(itRolelessPerformers);
|
artistMap.erase(itRolelessPerformers);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& [role, artistIds] : artistMap)
|
if (!artistMap.empty())
|
||||||
{
|
{
|
||||||
std::unique_ptr<Wt::WContainerWidget> artistContainer {Utils::createArtistContainer(std::vector (std::cbegin(artistIds), std::cend(artistIds)))};
|
releaseInfo->setCondition("if-has-artist", true);
|
||||||
auto artistsEntry {std::make_unique<Template>(Wt::WString::tr("Lms.Explore.template.info.artists"))};
|
Wt::WContainerWidget* artistTable {releaseInfo->bindNew<Wt::WContainerWidget>("artist-table")};
|
||||||
artistsEntry->bindString("type", role);
|
|
||||||
artistsEntry->bindWidget("artist-container", std::move(artistContainer));
|
for (const auto& [role, artistIds] : artistMap)
|
||||||
artistTable->addWidget(std::move(artistsEntry));
|
{
|
||||||
|
std::unique_ptr<Wt::WContainerWidget> artistContainer {Utils::createArtistContainer(std::vector (std::cbegin(artistIds), std::cend(artistIds)))};
|
||||||
|
auto artistsEntry {std::make_unique<Template>(Wt::WString::tr("Lms.Explore.template.info.artists"))};
|
||||||
|
artistsEntry->bindString("type", role);
|
||||||
|
artistsEntry->bindWidget("artist-container", std::move(artistContainer));
|
||||||
|
artistTable->addWidget(std::move(artistsEntry));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: save in DB and mean all this
|
// TODO: save in DB and mean all this
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "common/Template.hpp"
|
#include "common/Template.hpp"
|
||||||
#include "explore/Filters.hpp"
|
#include "explore/Filters.hpp"
|
||||||
#include "explore/PlayQueueController.hpp"
|
#include "explore/PlayQueueController.hpp"
|
||||||
#include "explore/ReleaseListHelpers.hpp"
|
#include "explore/ReleaseHelpers.hpp"
|
||||||
#include "LmsApplication.hpp"
|
#include "LmsApplication.hpp"
|
||||||
|
|
||||||
using namespace Database;
|
using namespace Database;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "ArtistListHelpers.hpp"
|
#include "ArtistListHelpers.hpp"
|
||||||
#include "Filters.hpp"
|
#include "Filters.hpp"
|
||||||
#include "LmsApplication.hpp"
|
#include "LmsApplication.hpp"
|
||||||
#include "ReleaseListHelpers.hpp"
|
#include "ReleaseHelpers.hpp"
|
||||||
#include "TrackListHelpers.hpp"
|
#include "TrackListHelpers.hpp"
|
||||||
|
|
||||||
using namespace Database;
|
using namespace Database;
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ namespace UserInterface::TrackListHelpers
|
|||||||
Wt::WWidget* trackInfoPtr {trackInfo.get()};
|
Wt::WWidget* trackInfoPtr {trackInfo.get()};
|
||||||
trackInfo->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
trackInfo->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||||
|
|
||||||
Wt::WContainerWidget* artistTable {trackInfo->bindNew<Wt::WContainerWidget>("artist-table")};
|
|
||||||
std::map<Wt::WString, std::set<ArtistId>> artistMap;
|
std::map<Wt::WString, std::set<ArtistId>> artistMap;
|
||||||
|
|
||||||
auto addArtists = [&](TrackArtistLinkType linkType, const char* type)
|
auto addArtists = [&](TrackArtistLinkType linkType, const char* type)
|
||||||
@@ -111,13 +110,19 @@ namespace UserInterface::TrackListHelpers
|
|||||||
artistMap.erase(itRolelessPerformers);
|
artistMap.erase(itRolelessPerformers);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& [role, artistIds] : artistMap)
|
if (!artistMap.empty())
|
||||||
{
|
{
|
||||||
std::unique_ptr<Wt::WContainerWidget> artistContainer {Utils::createArtistContainer(std::vector (std::cbegin(artistIds), std::cend(artistIds)))};
|
trackInfo->setCondition("if-has-artist", true);
|
||||||
auto artistsEntry {std::make_unique<Template>(Wt::WString::tr("Lms.Explore.template.info.artists"))};
|
Wt::WContainerWidget* artistTable {trackInfo->bindNew<Wt::WContainerWidget>("artist-table")};
|
||||||
artistsEntry->bindString("type", role);
|
|
||||||
artistsEntry->bindWidget("artist-container", std::move(artistContainer));
|
for (const auto& [role, artistIds] : artistMap)
|
||||||
artistTable->addWidget(std::move(artistsEntry));
|
{
|
||||||
|
std::unique_ptr<Wt::WContainerWidget> artistContainer {Utils::createArtistContainer(std::vector (std::cbegin(artistIds), std::cend(artistIds)))};
|
||||||
|
auto artistsEntry {std::make_unique<Template>(Wt::WString::tr("Lms.Explore.template.info.artists"))};
|
||||||
|
artistsEntry->bindString("type", role);
|
||||||
|
artistsEntry->bindWidget("artist-container", std::move(artistContainer));
|
||||||
|
artistTable->addWidget(std::move(artistsEntry));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto audioFile {Av::parseAudioFile(track->getPath())})
|
if (const auto audioFile {Av::parseAudioFile(track->getPath())})
|
||||||
|
|||||||
@@ -44,6 +44,46 @@ operator<<(std::ostream& os, const MetaData::Artist& artist)
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
std::ostream&
|
||||||
|
operator<<(std::ostream& os, MetaData::Release::PrimaryType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MetaData::Release::PrimaryType::Album: os << "Album"; break;
|
||||||
|
case MetaData::Release::PrimaryType::Single: os << "Single"; break;
|
||||||
|
case MetaData::Release::PrimaryType::EP: os << "EP"; break;
|
||||||
|
case MetaData::Release::PrimaryType::Broadcast: os << "Broadcast"; break;
|
||||||
|
case MetaData::Release::PrimaryType::Other: os << "Other"; break;
|
||||||
|
default:
|
||||||
|
os << "??";
|
||||||
|
}
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
std::ostream&
|
||||||
|
operator<<(std::ostream& os, MetaData::Release::SecondaryType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MetaData::Release::SecondaryType::Compilation: os << "Compilation"; break;
|
||||||
|
case MetaData::Release::SecondaryType::Soundtrack: os << "Soundtrack"; break;
|
||||||
|
case MetaData::Release::SecondaryType::Spokenword: os << "Spokenword"; break;
|
||||||
|
case MetaData::Release::SecondaryType::Interview: os << "Interview"; break;
|
||||||
|
case MetaData::Release::SecondaryType::Audiobook: os << "Audiobook"; break;
|
||||||
|
case MetaData::Release::SecondaryType::AudioDrama: os << "Audio drama"; break;
|
||||||
|
case MetaData::Release::SecondaryType::Live: os << "Live"; break;
|
||||||
|
case MetaData::Release::SecondaryType::Remix: os << "Remix"; break;
|
||||||
|
case MetaData::Release::SecondaryType::DJMix: os << "DJ-mix"; break;
|
||||||
|
case MetaData::Release::SecondaryType::Mixtape_Street: os << "Mixtape/Street"; break;
|
||||||
|
case MetaData::Release::SecondaryType::Demo: os << "Mixtape/Demo"; break;
|
||||||
|
default:
|
||||||
|
os << "??";
|
||||||
|
}
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
std::ostream&
|
std::ostream&
|
||||||
operator<<(std::ostream& os, const MetaData::Release& release)
|
operator<<(std::ostream& os, const MetaData::Release& release)
|
||||||
@@ -59,6 +99,13 @@ operator<<(std::ostream& os, const MetaData::Release& release)
|
|||||||
for (const MetaData::Artist& artist : release.artists)
|
for (const MetaData::Artist& artist : release.artists)
|
||||||
std::cout << "\tRelease artist: " << artist << std::endl;
|
std::cout << "\tRelease artist: " << artist << std::endl;
|
||||||
|
|
||||||
|
if (release.primaryType)
|
||||||
|
{
|
||||||
|
std::cout << "\tPrimary type: " << *release.primaryType << std::endl;
|
||||||
|
for (MetaData::Release::SecondaryType type : release.secondaryTypes)
|
||||||
|
std::cout << "\tSecondary type:" << type << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user