feat: try to find year of media and add to path

This commit is contained in:
Jan Bader
2025-01-28 00:03:47 +01:00
parent 9a37a3b215
commit 4a60af345b

View File

@ -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
}