Check if Artist is actually available

This commit is contained in:
aditya-K2
2023-05-13 00:17:17 +05:30
parent 0ce8f06bd1
commit ac7fd68e4f
11 changed files with 34 additions and 23 deletions

View File

@@ -79,6 +79,10 @@ func (c *CoverArt) RefreshState() {
}()
return
}
if len(state.Item.Album.Images) == 0 {
SendNotification("No Cover Art found for album: %s!", state.Item.Album.Name)
return
}
err = state.Item.Album.Images[0].Download(f)
if err != nil {
go func() {

View File

@@ -156,7 +156,7 @@ func progressFunc() (string, string, string, float64) {
if state.Item != nil {
barTitle = fmt.Sprintf("%s%s[-:-:-] - %s%s",
cfg.Colors.PBarTrack.String(), state.Item.Name,
cfg.Colors.PBarArtist.String(), state.Item.Artists[0].Name)
cfg.Colors.PBarArtist.String(), artistName(state.Item.Artists))
barText = utils.StrTime(float64(state.Progress/1000)) + "/" + utils.StrTime(float64(state.Item.Duration/1000))
percentage = (float64(state.Progress) / float64(state.Item.Duration)) * 100
}

View File

@@ -108,3 +108,22 @@ func openCurrentAlbum() {
App.SetFocus(Main)
}
}
func mergeGenres(g []string) string {
s := ""
for k, v := range g {
sep := ","
if k == 0 {
sep = ""
}
s += sep + v
}
return s
}
func artistName(s []spotify.SimpleArtist) string {
if len(s) != 0 {
return s[0].Name
}
return ""
}

View File

@@ -48,7 +48,7 @@ func (a *AlbumView) Content() func() [][]Content {
for _, v := range *(*a.currentFullAlbum).Tracks {
ca := make([]Content, 0)
ca = append(ca, Content{v.Name, TrackStyle})
ca = append(ca, Content{v.Artists[0].Name, ArtistStyle})
ca = append(ca, Content{artistName(v.Artists), ArtistStyle})
ca = append(ca, Content{a.currentAlbumName, AlbumStyle})
c = append(c, ca)
}

View File

@@ -37,7 +37,7 @@ func (a *AlbumsView) Content() func() [][]Content {
for _, v := range *a.savedAlbums {
c = append(c, []Content{
{Content: v.Name, Style: AlbumStyle},
{Content: v.Artists[0].Name, Style: ArtistStyle},
{Content: artistName(v.Artists), Style: ArtistStyle},
{Content: v.ReleaseDate, Style: TimeStyle},
})
}

View File

@@ -55,7 +55,7 @@ func (a *ArtistView) Content() func() [][]Content {
for _, v := range a.albums {
c = append(c, []Content{
{Content: v.Name, Style: AlbumStyle},
{Content: v.Artists[0].Name, Style: ArtistStyle},
{Content: artistName(v.Artists), Style: ArtistStyle},
{Content: v.ReleaseDate, Style: TimeStyle},
})
}
@@ -63,7 +63,7 @@ func (a *ArtistView) Content() func() [][]Content {
for _, v := range a.topTracks {
c = append(c, []Content{
{Content: v.Name, Style: TrackStyle},
{Content: v.Artists[0].Name, Style: ArtistStyle},
{Content: artistName(v.Artists), Style: ArtistStyle},
{Content: v.Album.Name, Style: AlbumStyle},
})
}

View File

@@ -36,7 +36,7 @@ func (p *LikedSongsView) Content() func() [][]Content {
for _, v := range *p.likedSongs {
c = append(c, []Content{
{Content: v.Name, Style: TrackStyle},
{Content: v.Artists[0].Name, Style: ArtistStyle},
{Content: artistName(v.Artists), Style: ArtistStyle},
{Content: v.Album.Name, Style: AlbumStyle},
})
}

View File

@@ -47,7 +47,7 @@ func (p *PlaylistView) Content() func() [][]Content {
for _, v := range *(*p.currentUserFullPlaylist).Tracks {
c = append(c, []Content{
{Content: v.Track.Name, Style: TrackStyle},
{Content: v.Track.Artists[0].Name, Style: ArtistStyle},
{Content: artistName(v.Track.Artists), Style: ArtistStyle},
{Content: v.Track.Album.Name, Style: AlbumStyle},
})
}

View File

@@ -26,7 +26,7 @@ func (r *RecentlyPlayedView) Content() func() [][]Content {
for _, v := range r.recentlyPlayed {
c = append(c, []Content{
{Content: v.Track.Name, Style: TrackStyle},
{Content: v.Track.Artists[0].Name, Style: ArtistStyle},
{Content: artistName(v.Track.Artists), Style: ArtistStyle},
{Content: utils.StrTime(float64(v.Track.Duration / 1000)), Style: TimeStyle},
})
}

View File

@@ -46,7 +46,7 @@ func (a *SearchView) Content() func() [][]Content {
}
c = append(c, []Content{
{Content: v.Name, Style: TrackStyle},
{Content: v.Artists[0].Name, Style: ArtistStyle},
{Content: artistName(v.Artists), Style: ArtistStyle},
{Content: v.Album.Name, Style: AlbumStyle},
})
}
@@ -62,7 +62,7 @@ func (a *SearchView) Content() func() [][]Content {
}
c = append(c, []Content{
{Content: v.Name, Style: AlbumStyle},
{Content: v.Artists[0].Name, Style: ArtistStyle},
{Content: artistName(v.Artists), Style: ArtistStyle},
{Content: v.ReleaseDate, Style: TimeStyle},
})
}

View File

@@ -35,18 +35,6 @@ func (a *TopTracksView) RefreshState() {
a.topArtists = artists
}
func mergeGenres(g []string) string {
s := ""
for k, v := range g {
sep := ","
if k == 0 {
sep = ""
}
s += sep + v
}
return s
}
func (a *TopTracksView) Content() func() [][]Content {
return func() [][]Content {
c := make([][]Content, 0)
@@ -61,7 +49,7 @@ func (a *TopTracksView) Content() func() [][]Content {
for _, v := range a.topTracks {
c = append(c, []Content{
{Content: v.Name, Style: TrackStyle},
{Content: v.Artists[0].Name, Style: ArtistStyle},
{Content: artistName(v.Artists), Style: ArtistStyle},
{Content: v.Album.Name, Style: AlbumStyle},
})
}