Refactors Cover's Extension cleaning in Album

This commit is contained in:
2016-01-25 15:20:19 +01:00
parent c858e99d06
commit 1c39ad27a5
3 changed files with 33 additions and 7 deletions

View File

@@ -1,8 +1,10 @@
package main
import (
"path"
"regexp"
"strconv"
"strings"
"time"
)
@@ -101,3 +103,14 @@ func (a *Album) String() string {
}
return res + a.Title
}
var rxExt = regexp.MustCompile(`\.([0-9]+)([a-zA-Z]+)\z`)
func (a *Album) CoverExt() string {
ext := path.Ext(a.CoverURL)
m := rxExt.FindStringSubmatch(ext)
if m != nil {
ext = "." + m[2]
}
return strings.ToLower(ext)
}