66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
// "log"
|
|
"strconv"
|
|
// "fmt"
|
|
// "github.com/diamondburned/gotk4/pkg/core/glib"
|
|
// "github.com/diamondburned/gotk4/pkg/gdk/v4"
|
|
// "github.com/diamondburned/gotk4/pkg/gtk/v4"
|
|
// "github.com/diamondburned/gotkit/gtkutil"
|
|
)
|
|
|
|
// var PlayNode string
|
|
// var pool *parallel = parallel.NewParallel()
|
|
|
|
func Search() {
|
|
|
|
for child := SearchListBoxResult.FirstChild(); child != nil; {
|
|
SearchListBoxResult.Remove(child)
|
|
child = SearchListBoxResult.FirstChild()
|
|
}
|
|
|
|
artistCount := 0
|
|
albumCount := 0
|
|
songCount := 0
|
|
|
|
if SearchTabSongCheckButton.Active() {
|
|
songCount = 20
|
|
}
|
|
if SearchTabAlbumCheckButton.Active() {
|
|
albumCount = 20
|
|
}
|
|
if SearchTabArtistCheckButton.Active() {
|
|
artistCount = 20
|
|
}
|
|
q := SearchTabSearchEntry.Text()
|
|
param := map[string]string{
|
|
"artistCount": strconv.Itoa(artistCount),
|
|
// "artistOffset": "0",
|
|
"albumCount": strconv.Itoa(albumCount),
|
|
// "albumOffset": "0",
|
|
"songCount": strconv.Itoa(songCount),
|
|
// "songOffset": "0",
|
|
// "musicFolderId": "",
|
|
}
|
|
if q != "" {
|
|
result, err := CurrentClient.Search3(q, param)
|
|
LogFatalOnError(err)
|
|
var j = 0
|
|
for _, item := range result.Song {
|
|
j++
|
|
CreateImagelessSongListBoxRow(SearchListBoxResult, item.Title, item.Artist, DurationToReadable(item.Duration), j, item.ID)
|
|
}
|
|
for _, item := range result.Album {
|
|
j++
|
|
album, _ := CurrentClient.GetAlbum(item.ID)
|
|
CreateImagelessAlbumListBoxRow(SearchListBoxResult, album.Name, album.Artist, DurationToReadable(album.Duration), j, album.Song)
|
|
}
|
|
for _, item := range result.Artist {
|
|
j++
|
|
artist, _ := CurrentClient.GetArtist(item.ID)
|
|
CreatelessListArtistBoxRow(SearchListBoxResult, artist.Name, j, artist.Album, item.ID)
|
|
}
|
|
}
|
|
}
|