Fix some absurd capitalization as well as insta-crashing when config files are absent

This commit is contained in:
Sasha Koshka
2024-01-20 20:28:53 +00:00
parent 6e4c3fb452
commit cc6aad66c6
4 changed files with 34 additions and 32 deletions

View File

@@ -36,17 +36,17 @@ func TogglePlayBack() error {
func GenerateContentSlice(selectedSuggestion string) ([]interface{}, error) {
var ContentSlice []interface{}
if strings.TrimRight(selectedSuggestion, " ") == "" {
notify.Notify.Send("Empty Search!")
return nil, errors.New("empty Search String Provided")
notify.Notify.Send("Empty search!")
return nil, errors.New("Empty search string provided")
}
if _, ok := ArtistTree[selectedSuggestion]; ok {
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Artists :")
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Artists:")
ContentSlice = append(ContentSlice, selectedSuggestion)
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Artist Albums :")
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Artist albums:")
for albumName := range ArtistTree[selectedSuggestion] {
ContentSlice = append(ContentSlice, [2]string{albumName, selectedSuggestion})
}
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Artist Tracks :")
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Artist tracks:")
for albumName, trackList := range ArtistTree[selectedSuggestion] {
for track := range trackList {
ContentSlice = append(ContentSlice, [3]string{track, selectedSuggestion, albumName})
@@ -54,11 +54,11 @@ func GenerateContentSlice(selectedSuggestion string) ([]interface{}, error) {
}
}
if aMap := QueryArtistTreeForAlbums(ArtistTree, selectedSuggestion); len(aMap) != 0 {
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Albums :")
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Albums:")
for mSlice := range aMap {
ContentSlice = append(ContentSlice, mSlice)
}
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Album Tracks :")
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Album tracks:")
for a, pathSlice := range aMap {
for _, path := range pathSlice {
ContentSlice = append(ContentSlice, [3]string{path[0], a[1], a[0]})
@@ -66,7 +66,7 @@ func GenerateContentSlice(selectedSuggestion string) ([]interface{}, error) {
}
}
if tMap := QueryArtistTreeForTracks(ArtistTree, selectedSuggestion); len(tMap) != 0 {
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Tracks :")
ContentSlice = append(ContentSlice, WHITE_AND_BOLD+"Tracks:")
for mSlice := range tMap {
ContentSlice = append(ContentSlice, mSlice)
}
@@ -93,7 +93,7 @@ func GenerateArtistTree() (map[string]map[string]map[string]string, error) {
}
return ArtistTree, nil
} else {
return nil, errors.New("Could Not Generate Artist Tree")
return nil, errors.New("Could not generate artist tree")
}
}
@@ -116,9 +116,9 @@ func AddAlbum(a map[string]map[string]map[string]string, alb string, artist stri
clist.Add(v)
}
if err := clist.End(); err != nil {
notify.Notify.Send("Could Not Add Album : " + alb)
notify.Notify.Send("Could not add album : " + alb)
} else {
notify.Notify.Send("Album Added: " + alb)
notify.Notify.Send("Album added: " + alb)
}
}
@@ -132,9 +132,9 @@ func AddArtist(a map[string]map[string]map[string]string, artist string) {
}
}
if err := clist.End(); err != nil {
notify.Notify.Send("Could Not Add Artist : " + artist)
notify.Notify.Send("Could not add artist: " + artist)
} else {
notify.Notify.Send("Artist Added: " + artist)
notify.Notify.Send("Artist added: " + artist)
}
}
}
@@ -145,12 +145,12 @@ func AddTitle(a map[string]map[string]map[string]string, artist, alb, track stri
id, err := Conn.AddID(a[artist][alb][track], -1)
Conn.PlayID(id)
if err != nil {
notify.Notify.Send("Could Not Add Track : " + track)
notify.Notify.Send("Could not add track: " + track)
}
} else {
err := Conn.Add(a[artist][alb][track])
if err != nil {
notify.Notify.Send("Could Not Add Track : " + track)
notify.Notify.Send("Could not add track: " + track)
}
}
notify.Notify.Send("Track Added : " + track)