117 lines
3.2 KiB
Go
117 lines
3.2 KiB
Go
package main
|
|
|
|
import (
|
|
// "github.com/delucks/go-subsonic"
|
|
// "fmt"
|
|
"github.com/diamondburned/gotk4/pkg/core/glib"
|
|
)
|
|
|
|
func DownloadPlaylist() {
|
|
for child := PlayListListBox.FirstChild(); child != nil; {
|
|
PlayListListBox.Remove(child)
|
|
child = PlayListListBox.FirstChild()
|
|
}
|
|
param := map[string]string{}
|
|
playlists, err := CurrentClient.GetPlaylists(param)
|
|
LogOnError(err)
|
|
|
|
for i, item := range playlists {
|
|
playlist, _ := CurrentClient.GetPlaylist(item.ID)
|
|
PlaylistCached = append(PlaylistCached, item.ID)
|
|
|
|
pat := GetRunDir() + MainDir + InfDir + "/" + item.ID
|
|
SerializePlaylist(*playlist, pat)
|
|
|
|
var upstream = func() {
|
|
CreateImagelessPlaylistListBoxRow(PlayListListBox, playlist.Name, DurationToReadable(playlist.Duration), i, playlist.Entry)
|
|
}
|
|
glib.IdleAdd(upstream)
|
|
}
|
|
}
|
|
|
|
func GetPlaylist() {
|
|
|
|
for child := PlayListListBox.FirstChild(); child != nil; {
|
|
PlayListListBox.Remove(child)
|
|
child = PlayListListBox.FirstChild()
|
|
}
|
|
|
|
for i, id := range PlaylistCached {
|
|
// fmt.Printf("{}",item)
|
|
|
|
item := DeSerializePlaylist(GetRunDir() + MainDir + InfDir + "/" + id)
|
|
|
|
var upstream = func() {
|
|
CreateImagelessPlaylistListBoxRow(PlayListListBox, item.Name, DurationToReadable(item.Duration), i, item.Entry)
|
|
}
|
|
glib.IdleAdd(upstream)
|
|
}
|
|
}
|
|
|
|
// func RefreshPlaylist() {
|
|
// for child := PlayListListBox.FirstChild(); child != nil; {
|
|
// PlayListListBox.Remove(child)
|
|
// child = PlayListListBox.FirstChild()
|
|
// }
|
|
// param := map[string]string{}
|
|
// playlists, err := CurrentClient.GetPlaylists(param)
|
|
// LogOnError(err)
|
|
// for i, item := range playlists {
|
|
// playlist, _ := CurrentClient.GetPlaylist(item.ID)
|
|
// CreateImagelessPlaylistListBoxRow(PlayListListBox, playlist.Name, DurationToReadable(playlist.Duration), i, playlist.Entry)
|
|
// }
|
|
// }
|
|
|
|
func DownloadLib() {
|
|
param := map[string]string{}
|
|
artistID3, err := CurrentClient.GetArtists(param)
|
|
LogFatalOnError(err)
|
|
|
|
for _, indx := range artistID3.Index {
|
|
for j, artist := range indx.Artist {
|
|
art, _ := CurrentClient.GetArtist(artist.ID)
|
|
ArtistsCached = append(ArtistsCached, artist.ID)
|
|
|
|
SerializeArtist(*art, GetRunDir()+MainDir+InfDir+"/"+artist.ID)
|
|
|
|
var upstream = func() {
|
|
CreatelessListArtistBoxRow(QueueListBoxLibrary, art.Name, j, art.Album, art.ID)
|
|
}
|
|
glib.IdleAdd(upstream)
|
|
}
|
|
}
|
|
}
|
|
|
|
func GetLib() {
|
|
|
|
for child := QueueListBoxLibrary.FirstChild(); child != nil; {
|
|
QueueListBoxLibrary.Remove(child)
|
|
child = QueueListBoxLibrary.FirstChild()
|
|
}
|
|
|
|
for j, id := range ArtistsCached {
|
|
art := DeSerializeArtist(GetRunDir() + MainDir + InfDir + "/" + id)
|
|
var upstream = func() {
|
|
CreatelessListArtistBoxRow(QueueListBoxLibrary, art.Name, j, art.Album, art.ID)
|
|
}
|
|
glib.IdleAdd(upstream)
|
|
}
|
|
}
|
|
|
|
// func RefreshLib() {
|
|
// for child := QueueListBoxLibrary.FirstChild(); child != nil; {
|
|
// QueueListBoxLibrary.Remove(child)
|
|
// child = QueueListBoxLibrary.FirstChild()
|
|
// }
|
|
// param := map[string]string{}
|
|
// artistID3, err := CurrentClient.GetArtists(param)
|
|
// LogFatalOnError(err)
|
|
|
|
// for _, indx := range artistID3.Index {
|
|
// for j, artist := range indx.Artist {
|
|
// art, _ := CurrentClient.GetArtist(artist.ID)
|
|
// CreatelessListArtistBoxRow(QueueListBoxLibrary, art.Name, j, art.Album)
|
|
// }
|
|
// }
|
|
// }
|