From 3c12b7905dee2a92c6980022fb0056b49fa18e68 Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Tue, 16 Nov 2021 00:16:15 +0530 Subject: [PATCH] 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 --- client.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/client.go b/client.go index 9b3ef6d..35b3bf5 100644 --- a/client.go +++ b/client.go @@ -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 +}