Fix multiple id3v2.4 genres appearing as one big concatenated genre

This commit is contained in:
Deluan 2021-07-19 10:15:52 -04:00 committed by Deluan Quintão
parent 69f71be98a
commit 2742977c63
5 changed files with 9 additions and 20 deletions

View File

@ -27,7 +27,7 @@ func NewGenreRepository(ctx context.Context, o orm.Ormer) model.GenreRepository
}
func (r *genreRepository) GetAll() (model.Genres, error) {
sq := Select("*",
sq := Select("genre.*",
"count(distinct a.album_id) as album_count",
"count(distinct f.media_file_id) as song_count").
From(r.tableName).

View File

@ -11,12 +11,7 @@ func (r sqlRepository) withGenres(sql SelectBuilder) SelectBuilder {
}
func (r *sqlRepository) updateGenres(id string, tableName string, genres model.Genres) error {
var ids []string
for _, g := range genres {
ids = append(ids, g.ID)
}
del := Delete(tableName + "_genres").Where(
And{Eq{tableName + "_id": id}, Eq{"genre_id": ids}})
del := Delete(tableName + "_genres").Where(Eq{tableName + "_id": id})
_, err := r.executeSQL(del)
if err != nil {
return err

View File

@ -32,13 +32,11 @@ func (e *taglibExtractor) extractMetadata(filePath string) (*Tags, error) {
}
tags := NewTags(filePath, parsedTags, map[string][]string{
"title": {"_track", "titlesort"},
"album": {"_album", "albumsort"},
"artist": {"_artist", "artistsort"},
"genre": {"_genre"},
"date": {"_year"},
"track": {"_track"},
"duration": {"length"},
"title": {"_track", "titlesort"},
"album": {"_album", "albumsort"},
"artist": {"_artist", "artistsort"},
"date": {"_year"},
"track": {"_track"},
})
return tags, nil

View File

@ -23,7 +23,7 @@ int taglib_read(const char *filename, unsigned long id) {
// Add audio properties to the tags
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());
TagLib::PropertyMap tags = f.file()->properties();
@ -40,9 +40,6 @@ int taglib_read(const char *filename, unsigned long id) {
if (!basic->album().isEmpty()) {
tags.insert("_album", basic->album());
}
if (!basic->genre().isEmpty()) {
tags.insert("_genre", basic->genre());
}
if (basic->year() > 0) {
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();
++i) {
for (TagLib::StringList::ConstIterator j = i->second.begin();

View File

@ -19,7 +19,7 @@ var _ = Describe("taglibExtractor", func() {
Expect(m.Artist()).To(Equal("Artist"))
Expect(m.AlbumArtist()).To(Equal("Album Artist"))
Expect(m.Compilation()).To(BeTrue())
Expect(m.Genres()).To(ConsistOf("Rock", "Rock"))
Expect(m.Genres()).To(ConsistOf("Rock"))
Expect(m.Year()).To(Equal(2014))
n, t := m.TrackNumber()
Expect(n).To(Equal(2))