From 6a8d2dc87d3594debb27fc3e2f94cb9bc00db1d7 Mon Sep 17 00:00:00 2001 From: Deluan Date: Mon, 3 Apr 2023 18:07:15 -0400 Subject: [PATCH] Only use valid images for artist.* artwork --- core/artwork/reader_artist.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core/artwork/reader_artist.go b/core/artwork/reader_artist.go index 71c72eda8..b25858f0c 100644 --- a/core/artwork/reader_artist.go +++ b/core/artwork/reader_artist.go @@ -110,12 +110,18 @@ func fromArtistFolder(ctx context.Context, artistFolder string, pattern string) if len(matches) == 0 { return nil, "", fmt.Errorf(`no matches for '%s' in '%s'`, pattern, artistFolder) } - filePath := filepath.Join(artistFolder, matches[0]) - f, err := os.Open(filePath) - if err != nil { - log.Warn(ctx, "Could not open cover art file", "file", filePath, err) - return nil, "", err + for _, m := range matches { + filePath := filepath.Join(artistFolder, m) + if !model.IsImageFile(m) { + continue + } + f, err := os.Open(filePath) + if err != nil { + log.Warn(ctx, "Could not open cover art file", "file", filePath, err) + return nil, "", err + } + return f, filePath, nil } - return f, filePath, err + return nil, "", nil } }