Reconstruct the artist display name if a custom artist delimiter in found in the artist tag
This commit is contained in:
@@ -172,15 +172,6 @@ namespace lms::metadata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t AvFormatTagReader::countTagValues(TagType tag) const
|
|
||||||
{
|
|
||||||
size_t count{};
|
|
||||||
visitTagValues(tag, [&](std::string_view) {
|
|
||||||
count++;
|
|
||||||
});
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AvFormatTagReader::visitTagValues(TagType tag, TagValueVisitor visitor) const
|
void AvFormatTagReader::visitTagValues(TagType tag, TagValueVisitor visitor) const
|
||||||
{
|
{
|
||||||
auto itTagNames{ tagMapping.find(tag) };
|
auto itTagNames{ tagMapping.find(tag) };
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ namespace lms::metadata
|
|||||||
AvFormatTagReader(const AvFormatTagReader&) = delete;
|
AvFormatTagReader(const AvFormatTagReader&) = delete;
|
||||||
AvFormatTagReader& operator=(const AvFormatTagReader&) = delete;
|
AvFormatTagReader& operator=(const AvFormatTagReader&) = delete;
|
||||||
|
|
||||||
size_t countTagValues(TagType tag) const override;
|
|
||||||
void visitTagValues(TagType tag, TagValueVisitor visitor) const override;
|
void visitTagValues(TagType tag, TagValueVisitor visitor) const override;
|
||||||
void visitTagValues(std::string_view tag, TagValueVisitor visitor) const override;
|
void visitTagValues(std::string_view tag, TagValueVisitor visitor) const override;
|
||||||
void visitPerformerTags(PerformerVisitor visitor) const override;
|
void visitPerformerTags(PerformerVisitor visitor) const override;
|
||||||
|
|||||||
@@ -148,7 +148,6 @@ namespace lms::metadata
|
|||||||
virtual ~ITagReader() = default;
|
virtual ~ITagReader() = default;
|
||||||
|
|
||||||
using TagValueVisitor = std::function<void(std::string_view value)>;
|
using TagValueVisitor = std::function<void(std::string_view value)>;
|
||||||
virtual size_t countTagValues(TagType tag) const = 0;
|
|
||||||
virtual void visitTagValues(TagType tag, TagValueVisitor visitor) const = 0;
|
virtual void visitTagValues(TagType tag, TagValueVisitor visitor) const = 0;
|
||||||
virtual void visitTagValues(std::string_view tag, TagValueVisitor visitor) const = 0;
|
virtual void visitTagValues(std::string_view tag, TagValueVisitor visitor) const = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -296,10 +296,12 @@ namespace lms::metadata
|
|||||||
|
|
||||||
track.medium = getMedium(tagReader);
|
track.medium = getMedium(tagReader);
|
||||||
track.artists = getArtists(tagReader, { TagType::Artists, TagType::Artist }, { TagType::ArtistSortOrder }, { TagType::MusicBrainzArtistID }, _artistTagDelimiters);
|
track.artists = getArtists(tagReader, { TagType::Artists, TagType::Artist }, { TagType::ArtistSortOrder }, { TagType::MusicBrainzArtistID }, _artistTagDelimiters);
|
||||||
|
|
||||||
|
// We consider the artist display name is put in the Artist tag (picard case)
|
||||||
|
// But to please most users, if we find a custom delimiter in the Artist tag, we construct the artist diplay string with a "nicer" join
|
||||||
if (!_artistTagDelimiters.empty()
|
if (!_artistTagDelimiters.empty()
|
||||||
&& track.artists.size() > 1
|
&& track.artists.size() > 1
|
||||||
&& tagReader.countTagValues(TagType::Artist) <= 1
|
&& getTagValuesAs<std::string>(tagReader, { TagType::Artist }, _artistTagDelimiters).size() > 1)
|
||||||
&& tagReader.countTagValues(TagType::Artists) <= 1)
|
|
||||||
{
|
{
|
||||||
std::vector<std::string_view> artistNames;
|
std::vector<std::string_view> artistNames;
|
||||||
std::transform(std::cbegin(track.artists), std::cend(track.artists), std::back_inserter(artistNames), [](const Artist& artist) -> std::string_view { return artist.name; });
|
std::transform(std::cbegin(track.artists), std::cend(track.artists), std::back_inserter(artistNames), [](const Artist& artist) -> std::string_view { return artist.name; });
|
||||||
|
|||||||
@@ -340,15 +340,6 @@ namespace lms::metadata
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t TagLibTagReader::countTagValues(TagType tag) const
|
|
||||||
{
|
|
||||||
size_t count{};
|
|
||||||
visitTagValues(tag, [&](std::string_view) {
|
|
||||||
count++;
|
|
||||||
});
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TagLibTagReader::visitTagValues(TagType tag, TagValueVisitor visitor) const
|
void TagLibTagReader::visitTagValues(TagType tag, TagValueVisitor visitor) const
|
||||||
{
|
{
|
||||||
auto itTagNames{ tagMapping.find(tag) };
|
auto itTagNames{ tagMapping.find(tag) };
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ namespace lms::metadata
|
|||||||
TagLibTagReader& operator=(const TagLibTagReader&) = delete;
|
TagLibTagReader& operator=(const TagLibTagReader&) = delete;
|
||||||
|
|
||||||
void computeAudioProperties();
|
void computeAudioProperties();
|
||||||
size_t countTagValues(TagType tag) const override;
|
|
||||||
void visitTagValues(TagType tag, TagValueVisitor visitor) const override;
|
void visitTagValues(TagType tag, TagValueVisitor visitor) const override;
|
||||||
void visitTagValues(std::string_view tag, TagValueVisitor visitor) const override;
|
void visitTagValues(std::string_view tag, TagValueVisitor visitor) const override;
|
||||||
void visitPerformerTags(PerformerVisitor visitor) const override;
|
void visitPerformerTags(PerformerVisitor visitor) const override;
|
||||||
|
|||||||
@@ -47,15 +47,6 @@ namespace lms::metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t countTagValues(TagType tag) const
|
|
||||||
{
|
|
||||||
auto itValues{ _tags.find(tag) };
|
|
||||||
if (itValues != std::cend(_tags))
|
|
||||||
return itValues->second.size();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void visitTagValues(TagType tag, TagValueVisitor visitor) const override
|
void visitTagValues(TagType tag, TagValueVisitor visitor) const override
|
||||||
{
|
{
|
||||||
auto itValues{ _tags.find(tag) };
|
auto itValues{ _tags.find(tag) };
|
||||||
|
|||||||
Reference in New Issue
Block a user