mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-05 01:43:11 +03:00
Fix multiple id3v2.4 genres appearing as one big concatenated genre
This commit is contained in:
parent
69f71be98a
commit
2742977c63
@ -27,7 +27,7 @@ func NewGenreRepository(ctx context.Context, o orm.Ormer) model.GenreRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *genreRepository) GetAll() (model.Genres, error) {
|
func (r *genreRepository) GetAll() (model.Genres, error) {
|
||||||
sq := Select("*",
|
sq := Select("genre.*",
|
||||||
"count(distinct a.album_id) as album_count",
|
"count(distinct a.album_id) as album_count",
|
||||||
"count(distinct f.media_file_id) as song_count").
|
"count(distinct f.media_file_id) as song_count").
|
||||||
From(r.tableName).
|
From(r.tableName).
|
||||||
|
@ -11,12 +11,7 @@ func (r sqlRepository) withGenres(sql SelectBuilder) SelectBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *sqlRepository) updateGenres(id string, tableName string, genres model.Genres) error {
|
func (r *sqlRepository) updateGenres(id string, tableName string, genres model.Genres) error {
|
||||||
var ids []string
|
del := Delete(tableName + "_genres").Where(Eq{tableName + "_id": id})
|
||||||
for _, g := range genres {
|
|
||||||
ids = append(ids, g.ID)
|
|
||||||
}
|
|
||||||
del := Delete(tableName + "_genres").Where(
|
|
||||||
And{Eq{tableName + "_id": id}, Eq{"genre_id": ids}})
|
|
||||||
_, err := r.executeSQL(del)
|
_, err := r.executeSQL(del)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -32,13 +32,11 @@ func (e *taglibExtractor) extractMetadata(filePath string) (*Tags, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tags := NewTags(filePath, parsedTags, map[string][]string{
|
tags := NewTags(filePath, parsedTags, map[string][]string{
|
||||||
"title": {"_track", "titlesort"},
|
"title": {"_track", "titlesort"},
|
||||||
"album": {"_album", "albumsort"},
|
"album": {"_album", "albumsort"},
|
||||||
"artist": {"_artist", "artistsort"},
|
"artist": {"_artist", "artistsort"},
|
||||||
"genre": {"_genre"},
|
"date": {"_year"},
|
||||||
"date": {"_year"},
|
"track": {"_track"},
|
||||||
"track": {"_track"},
|
|
||||||
"duration": {"length"},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return tags, nil
|
return tags, nil
|
||||||
|
@ -23,7 +23,7 @@ int taglib_read(const char *filename, unsigned long id) {
|
|||||||
|
|
||||||
// Add audio properties to the tags
|
// Add audio properties to the tags
|
||||||
const TagLib::AudioProperties *props(f.audioProperties());
|
const TagLib::AudioProperties *props(f.audioProperties());
|
||||||
go_map_put_int(id, (char *)"length", props->length());
|
go_map_put_int(id, (char *)"duration", props->length());
|
||||||
go_map_put_int(id, (char *)"bitrate", props->bitrate());
|
go_map_put_int(id, (char *)"bitrate", props->bitrate());
|
||||||
|
|
||||||
TagLib::PropertyMap tags = f.file()->properties();
|
TagLib::PropertyMap tags = f.file()->properties();
|
||||||
@ -40,9 +40,6 @@ int taglib_read(const char *filename, unsigned long id) {
|
|||||||
if (!basic->album().isEmpty()) {
|
if (!basic->album().isEmpty()) {
|
||||||
tags.insert("_album", basic->album());
|
tags.insert("_album", basic->album());
|
||||||
}
|
}
|
||||||
if (!basic->genre().isEmpty()) {
|
|
||||||
tags.insert("_genre", basic->genre());
|
|
||||||
}
|
|
||||||
if (basic->year() > 0) {
|
if (basic->year() > 0) {
|
||||||
tags.insert("_year", TagLib::String::number(basic->year()));
|
tags.insert("_year", TagLib::String::number(basic->year()));
|
||||||
}
|
}
|
||||||
@ -64,7 +61,6 @@ int taglib_read(const char *filename, unsigned long id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get only the first occurrence of each tag (for now)
|
|
||||||
for (TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end();
|
for (TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end();
|
||||||
++i) {
|
++i) {
|
||||||
for (TagLib::StringList::ConstIterator j = i->second.begin();
|
for (TagLib::StringList::ConstIterator j = i->second.begin();
|
||||||
|
@ -19,7 +19,7 @@ var _ = Describe("taglibExtractor", func() {
|
|||||||
Expect(m.Artist()).To(Equal("Artist"))
|
Expect(m.Artist()).To(Equal("Artist"))
|
||||||
Expect(m.AlbumArtist()).To(Equal("Album Artist"))
|
Expect(m.AlbumArtist()).To(Equal("Album Artist"))
|
||||||
Expect(m.Compilation()).To(BeTrue())
|
Expect(m.Compilation()).To(BeTrue())
|
||||||
Expect(m.Genres()).To(ConsistOf("Rock", "Rock"))
|
Expect(m.Genres()).To(ConsistOf("Rock"))
|
||||||
Expect(m.Year()).To(Equal(2014))
|
Expect(m.Year()).To(Equal(2014))
|
||||||
n, t := m.TrackNumber()
|
n, t := m.TrackNumber()
|
||||||
Expect(n).To(Equal(2))
|
Expect(n).To(Equal(2))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user