wip
This commit is contained in:
28
internal/classifier/movie.go
Normal file
28
internal/classifier/movie.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package classifier
|
||||
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var movieYear = regexp.MustCompile(`(?i)(19|20)\d{2}`)
|
||||
|
||||
func classifyMovie(filename string) (bool, string, int) {
|
||||
base := strings.TrimSuffix(filepath.Base(filename), filepath.Ext(filename))
|
||||
|
||||
// Find year
|
||||
yearMatch := movieYear.FindString(base)
|
||||
if yearMatch == "" {
|
||||
return false, "", 0
|
||||
}
|
||||
|
||||
year := parseInt(yearMatch)
|
||||
|
||||
// Extract title (everything before year)
|
||||
title := strings.TrimSpace(strings.Replace(base, yearMatch, "", 1))
|
||||
title = cleanupTitle(title)
|
||||
|
||||
return true, title, year
|
||||
}
|
||||
Reference in New Issue
Block a user