Skip to content

Commit

Permalink
feat(scanner): support more cover types
Browse files Browse the repository at this point in the history
like bmp gif, and also files like folder.1.jpg like beets can create sometimes
  • Loading branch information
sentriz committed Mar 10, 2023
1 parent 4ca9dbe commit 906164a
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions scanner/scanner.go
Expand Up @@ -578,21 +578,26 @@ func (s *Scanner) cleanGenres(c *Context) error {
return nil
}

func isCover(name string) bool {
switch path := strings.ToLower(name); path {
case
"cover.png", "cover.jpg", "cover.jpeg",
"folder.png", "folder.jpg", "folder.jpeg",
"album.png", "album.jpg", "album.jpeg",
"albumart.png", "albumart.jpg", "albumart.jpeg",
"front.png", "front.jpg", "front.jpeg",
"artist.png", "artist.jpg", "artist.jpeg":
return true
default:
return false
//nolint:gochecknoglobals
var coverNames = map[string]struct{}{}

//nolint:gochecknoinits
func init() {
for _, name := range []string{"cover", "folder", "front", "albumart", "album", "artist"} {
for _, ext := range []string{"jpg", "jpeg", "png", "bmp", "gif"} {
coverNames[fmt.Sprintf("%s.%s", name, ext)] = struct{}{}
for i := 0; i < 3; i++ {
coverNames[fmt.Sprintf("%s.%d.%s", name, i, ext)] = struct{}{} // support beets extras
}
}
}
}

func isCover(name string) bool {
_, ok := coverNames[strings.ToLower(name)]
return ok
}

// 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
// differs from the original. the fields are used for searching.
Expand Down

0 comments on commit 906164a

Please sign in to comment.