Utility Functions to Interact with the Search View

The Following Utility Functions have been added:

    1. AddAlbum : Adds Album to the Playlist
    2. AddArtist : Adds all the Track of the Artist to Playlist
    3. QueryArtistTree : Searches the Artist Tree for the track name
	and returns a map of [ artist, album, track ] -> path
This commit is contained in:
aditya-K2 2021-11-16 00:16:15 +05:30
parent 41c77722e9
commit 3c12b7905d
1 changed files with 32 additions and 0 deletions

View File

@ -137,3 +137,35 @@ func PrintArtistTree(a map[string]map[string]map[string]string) {
}
}
}
func AddAlbum(a map[string]map[string]string, alb string) {
if val, ok := a[alb]; ok {
for _, path := range val {
CONN.Add(path)
}
}
}
func AddArtist(a map[string]map[string]map[string]string, artist string) {
if val, ok := a[artist]; ok {
for _, v := range val {
for _, path := range v {
CONN.Add(path)
}
}
}
}
func QueryArtistTree(a map[string]map[string]map[string]string, track string) map[[3]string]string {
TrackMap := make(map[[3]string]string)
for artistName, albumMap := range a {
for albumNam, trackList := range albumMap {
for trackName, path := range trackList {
if trackName == track {
TrackMap[[3]string{artistName, albumNam, trackName}] = path
}
}
}
}
return TrackMap
}