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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type mediaElement struct {
|
type mediaElement struct {
|
||||||
Directory string
|
Directory string
|
||||||
Name string
|
Name string
|
||||||
|
Year int
|
||||||
Episode string
|
Episode string
|
||||||
Title string
|
Title string
|
||||||
Tags []string
|
Tags []string
|
||||||
@ -59,7 +61,11 @@ func newMediaElement(p string) *mediaElement {
|
|||||||
case "UNCUT":
|
case "UNCUT":
|
||||||
element.Tags = append(element.Tags, word)
|
element.Tags = append(element.Tags, word)
|
||||||
default:
|
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-- {
|
for i := len(element.Tags) - 1; i >= 0; i-- {
|
||||||
result += " " + element.Tags[i]
|
result += " " + element.Tags[i]
|
||||||
}
|
}
|
||||||
|
if element.Year != 0 {
|
||||||
|
result += " (" + strconv.Itoa(element.Year) + ")"
|
||||||
|
}
|
||||||
return result + element.Extension
|
return result + element.Extension
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user