Added Artist, Album fields to FileNode
This commit is contained in:
parent
b53e051694
commit
fb2e2a831e
@ -13,6 +13,8 @@ type FileNode struct {
|
|||||||
Parent *FileNode
|
Parent *FileNode
|
||||||
AbsolutePath string
|
AbsolutePath string
|
||||||
Title string
|
Title string
|
||||||
|
Artist string
|
||||||
|
Album string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source Interface For Fuzzy Searching.
|
// Source Interface For Fuzzy Searching.
|
||||||
@ -29,11 +31,11 @@ func (f FileNodes) Len() int {
|
|||||||
return len(f)
|
return len(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FileNode) AddChildren(path string, title string) {
|
func (f *FileNode) AddChildren(path string, title string, artist string, album string) {
|
||||||
if f.Path != "" {
|
if f.Path != "" {
|
||||||
f.Children = append(f.Children, FileNode{Children: make([]FileNode, 0), Path: path, Parent: f, AbsolutePath: f.AbsolutePath + "/" + path, Title: title})
|
f.Children = append(f.Children, FileNode{Children: make([]FileNode, 0), Path: path, Parent: f, AbsolutePath: f.AbsolutePath + "/" + path, Title: title, Artist: artist, Album: album})
|
||||||
} else {
|
} else {
|
||||||
f.Children = append(f.Children, FileNode{Children: make([]FileNode, 0), Path: path, Parent: f, AbsolutePath: f.AbsolutePath + path, Title: title})
|
f.Children = append(f.Children, FileNode{Children: make([]FileNode, 0), Path: path, Parent: f, AbsolutePath: f.AbsolutePath + path})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ func GenerateDirectoryTree(path []mpd.Attrs) *FileNode {
|
|||||||
sepPaths := strings.Split(path[i]["file"], "/")
|
sepPaths := strings.Split(path[i]["file"], "/")
|
||||||
for j := range sepPaths {
|
for j := range sepPaths {
|
||||||
if len(head.Children) == 0 {
|
if len(head.Children) == 0 {
|
||||||
head.AddChildren(sepPaths[j], path[i]["Title"])
|
head.AddChildren(sepPaths[j], path[i]["Title"], path[i]["Artist"], path[i]["Album"])
|
||||||
head = &(head.Children[len(head.Children)-1])
|
head = &(head.Children[len(head.Children)-1])
|
||||||
} else {
|
} else {
|
||||||
var headIsChanged = false
|
var headIsChanged = false
|
||||||
@ -61,7 +63,7 @@ func GenerateDirectoryTree(path []mpd.Attrs) *FileNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !headIsChanged {
|
if !headIsChanged {
|
||||||
head.AddChildren(sepPaths[j], path[i]["Title"])
|
head.AddChildren(sepPaths[j], path[i]["Title"], path[i]["Artist"], path[i]["Album"])
|
||||||
head = &(head.Children[len(head.Children)-1])
|
head = &(head.Children[len(head.Children)-1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
main.go
3
main.go
@ -338,9 +338,8 @@ func main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
drawFunc := func() {}
|
|
||||||
for {
|
for {
|
||||||
ui.Ui.App.QueueUpdateDraw(drawFunc)
|
ui.Ui.App.Draw()
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -74,20 +74,17 @@ func (f FileView) Update(inputTable *tview.Table) {
|
|||||||
inputTable.Clear()
|
inputTable.Clear()
|
||||||
for i, j := range client.DirTree.Children {
|
for i, j := range client.DirTree.Children {
|
||||||
if len(j.Children) == 0 {
|
if len(j.Children) == 0 {
|
||||||
_songAttributes, err := client.Conn.ListAllInfo(j.AbsolutePath)
|
if j.Title != "" {
|
||||||
if err == nil && _songAttributes[0]["Title"] != "" {
|
|
||||||
_, _, w, _ := inputTable.GetInnerRect()
|
_, _, w, _ := inputTable.GetInnerRect()
|
||||||
inputTable.SetCell(i, 0,
|
inputTable.SetCell(i, 0,
|
||||||
GetCell(
|
GetCell(
|
||||||
utils.GetFormattedString(_songAttributes[0]["Title"], w/3), tcell.ColorGreen, false))
|
utils.GetFormattedString(j.Title, w/3), tcell.ColorGreen, false))
|
||||||
|
|
||||||
inputTable.SetCell(i, 1,
|
inputTable.SetCell(i, 1,
|
||||||
GetCell(
|
GetCell(
|
||||||
utils.GetFormattedString(_songAttributes[0]["Artist"], w/3), tcell.ColorPurple, false))
|
utils.GetFormattedString(j.Artist, w/3), tcell.ColorPurple, false))
|
||||||
inputTable.SetCell(i, 2,
|
inputTable.SetCell(i, 2,
|
||||||
GetCell(_songAttributes[0]["Album"], tcell.ColorYellow, false))
|
GetCell(j.Album, tcell.ColorYellow, false))
|
||||||
|
} else if j.Title == "" {
|
||||||
} else if _songAttributes[0]["Title"] == "" {
|
|
||||||
inputTable.SetCell(i, 0,
|
inputTable.SetCell(i, 0,
|
||||||
GetCell(j.Path, tcell.ColorBlue, true))
|
GetCell(j.Path, tcell.ColorBlue, true))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user