feat: handle name/title as equivalent if only one is specified
This commit is contained in:
parent
4a60af345b
commit
224a6bc9af
15
media.go
15
media.go
@ -45,6 +45,10 @@ func newMediaElement(p string) *mediaElement {
|
|||||||
Episode: episode,
|
Episode: episode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if episode == "" {
|
||||||
|
title = name
|
||||||
|
element.Name = ""
|
||||||
|
}
|
||||||
words := strings.Split(title, " ")
|
words := strings.Split(title, " ")
|
||||||
titleWords := []string{}
|
titleWords := []string{}
|
||||||
for i := len(words) - 1; i >= 0; i-- {
|
for i := len(words) - 1; i >= 0; i-- {
|
||||||
@ -97,12 +101,15 @@ func (element *mediaElement) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (element *mediaElement) Path() string {
|
func (element *mediaElement) Path() string {
|
||||||
result := filepath.Join(element.Directory, element.Name)
|
result := element.Name
|
||||||
if element.Episode != "" {
|
if element.Episode != "" {
|
||||||
result += " - " + element.Episode
|
result += " - " + element.Episode
|
||||||
}
|
}
|
||||||
if element.Title != "" {
|
if element.Title != "" {
|
||||||
result += " - " + element.Title
|
if result != "" {
|
||||||
|
result += " - "
|
||||||
|
}
|
||||||
|
result += element.Title
|
||||||
}
|
}
|
||||||
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]
|
||||||
@ -110,5 +117,7 @@ func (element *mediaElement) Path() string {
|
|||||||
if element.Year != 0 {
|
if element.Year != 0 {
|
||||||
result += " (" + strconv.Itoa(element.Year) + ")"
|
result += " (" + strconv.Itoa(element.Year) + ")"
|
||||||
}
|
}
|
||||||
return result + element.Extension
|
result += element.Extension
|
||||||
|
return filepath.Join(element.Directory, result)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user