feat: try to find year of media and add to path
This commit is contained in:
11
media.go
11
media.go
@ -3,12 +3,14 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type mediaElement struct {
|
||||
Directory string
|
||||
Name string
|
||||
Year int
|
||||
Episode string
|
||||
Title string
|
||||
Tags []string
|
||||
@ -59,7 +61,11 @@ func newMediaElement(p string) *mediaElement {
|
||||
case "UNCUT":
|
||||
element.Tags = append(element.Tags, word)
|
||||
default:
|
||||
titleWords = append(titleWords, word)
|
||||
if len(word) == 4 && word >= "1800" && word <= "2100" {
|
||||
element.Year, _ = strconv.Atoi(word)
|
||||
} else {
|
||||
titleWords = append(titleWords, word)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,5 +107,8 @@ func (element *mediaElement) Path() string {
|
||||
for i := len(element.Tags) - 1; i >= 0; i-- {
|
||||
result += " " + element.Tags[i]
|
||||
}
|
||||
if element.Year != 0 {
|
||||
result += " (" + strconv.Itoa(element.Year) + ")"
|
||||
}
|
||||
return result + element.Extension
|
||||
}
|
||||
|
Reference in New Issue
Block a user