feat(scanner): support more cover types

like bmp gif, and also files like folder.1.jpg like beets can create sometimes
This commit is contained in:
sentriz
2023-03-10 16:59:38 +00:00
parent 4ca9dbe320
commit 906164a5de

View File

@@ -578,20 +578,25 @@ func (s *Scanner) cleanGenres(c *Context) error {
return nil return nil
} }
func isCover(name string) bool { //nolint:gochecknoglobals
switch path := strings.ToLower(name); path { var coverNames = map[string]struct{}{}
case
"cover.png", "cover.jpg", "cover.jpeg", //nolint:gochecknoinits
"folder.png", "folder.jpg", "folder.jpeg", func init() {
"album.png", "album.jpg", "album.jpeg", for _, name := range []string{"cover", "folder", "front", "albumart", "album", "artist"} {
"albumart.png", "albumart.jpg", "albumart.jpeg", for _, ext := range []string{"jpg", "jpeg", "png", "bmp", "gif"} {
"front.png", "front.jpg", "front.jpeg", coverNames[fmt.Sprintf("%s.%s", name, ext)] = struct{}{}
"artist.png", "artist.jpg", "artist.jpeg": for i := 0; i < 3; i++ {
return true coverNames[fmt.Sprintf("%s.%d.%s", name, i, ext)] = struct{}{} // support beets extras
default:
return false
} }
} }
}
}
func isCover(name string) bool {
_, ok := coverNames[strings.ToLower(name)]
return ok
}
// decoded converts a string to it's latin equivalent. // decoded converts a string to it's latin equivalent.
// it will be used by the model's *UDec fields, and is only set if it // it will be used by the model's *UDec fields, and is only set if it