22 lines
588 B
Go
22 lines
588 B
Go
package classifier
|
|
|
|
var tvPattern = regexp.MustCompile(`(?i)(S?)(\d{1,2})(E|x)(\d{1,2})`)
|
|
|
|
func classifyTV(filename string) (bool, string, int, int) {
|
|
base := strings.TrimSuffix(filepath.Base(filename), filepath.Ext(filename))
|
|
|
|
match := tvPattern.FindStringSubmatch(base)
|
|
if len(match) < 5 {
|
|
return false, "", 0, 0
|
|
}
|
|
|
|
season := parseInt(match[2])
|
|
episode := parseInt(match[4])
|
|
|
|
// Remove S01E02 or similar from the string
|
|
cleaned := tvPattern.ReplaceAllString(base, "")
|
|
title := cleanupTitle(cleaned)
|
|
|
|
return true, title, season, episode
|
|
}
|