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