Only use valid images for artist.* artwork

This commit is contained in:
Deluan 2023-04-03 18:07:15 -04:00
parent de816e8e5d
commit 6a8d2dc87d
1 changed files with 12 additions and 6 deletions

View File

@ -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
}
}