mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Check if Artist is actually available
This commit is contained in:
@@ -79,6 +79,10 @@ func (c *CoverArt) RefreshState() {
|
|||||||
}()
|
}()
|
||||||
return
|
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)
|
err = state.Item.Album.Images[0].Download(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ func progressFunc() (string, string, string, float64) {
|
|||||||
if state.Item != nil {
|
if state.Item != nil {
|
||||||
barTitle = fmt.Sprintf("%s%s[-:-:-] - %s%s",
|
barTitle = fmt.Sprintf("%s%s[-:-:-] - %s%s",
|
||||||
cfg.Colors.PBarTrack.String(), state.Item.Name,
|
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))
|
barText = utils.StrTime(float64(state.Progress/1000)) + "/" + utils.StrTime(float64(state.Item.Duration/1000))
|
||||||
percentage = (float64(state.Progress) / float64(state.Item.Duration)) * 100
|
percentage = (float64(state.Progress) / float64(state.Item.Duration)) * 100
|
||||||
}
|
}
|
||||||
|
|||||||
19
ui/utils.go
19
ui/utils.go
@@ -108,3 +108,22 @@ func openCurrentAlbum() {
|
|||||||
App.SetFocus(Main)
|
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 ""
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func (a *AlbumView) Content() func() [][]Content {
|
|||||||
for _, v := range *(*a.currentFullAlbum).Tracks {
|
for _, v := range *(*a.currentFullAlbum).Tracks {
|
||||||
ca := make([]Content, 0)
|
ca := make([]Content, 0)
|
||||||
ca = append(ca, Content{v.Name, TrackStyle})
|
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})
|
ca = append(ca, Content{a.currentAlbumName, AlbumStyle})
|
||||||
c = append(c, ca)
|
c = append(c, ca)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func (a *AlbumsView) Content() func() [][]Content {
|
|||||||
for _, v := range *a.savedAlbums {
|
for _, v := range *a.savedAlbums {
|
||||||
c = append(c, []Content{
|
c = append(c, []Content{
|
||||||
{Content: v.Name, Style: AlbumStyle},
|
{Content: v.Name, Style: AlbumStyle},
|
||||||
{Content: v.Artists[0].Name, Style: ArtistStyle},
|
{Content: artistName(v.Artists), Style: ArtistStyle},
|
||||||
{Content: v.ReleaseDate, Style: TimeStyle},
|
{Content: v.ReleaseDate, Style: TimeStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func (a *ArtistView) Content() func() [][]Content {
|
|||||||
for _, v := range a.albums {
|
for _, v := range a.albums {
|
||||||
c = append(c, []Content{
|
c = append(c, []Content{
|
||||||
{Content: v.Name, Style: AlbumStyle},
|
{Content: v.Name, Style: AlbumStyle},
|
||||||
{Content: v.Artists[0].Name, Style: ArtistStyle},
|
{Content: artistName(v.Artists), Style: ArtistStyle},
|
||||||
{Content: v.ReleaseDate, Style: TimeStyle},
|
{Content: v.ReleaseDate, Style: TimeStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ func (a *ArtistView) Content() func() [][]Content {
|
|||||||
for _, v := range a.topTracks {
|
for _, v := range a.topTracks {
|
||||||
c = append(c, []Content{
|
c = append(c, []Content{
|
||||||
{Content: v.Name, Style: TrackStyle},
|
{Content: v.Name, Style: TrackStyle},
|
||||||
{Content: v.Artists[0].Name, Style: ArtistStyle},
|
{Content: artistName(v.Artists), Style: ArtistStyle},
|
||||||
{Content: v.Album.Name, Style: AlbumStyle},
|
{Content: v.Album.Name, Style: AlbumStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (p *LikedSongsView) Content() func() [][]Content {
|
|||||||
for _, v := range *p.likedSongs {
|
for _, v := range *p.likedSongs {
|
||||||
c = append(c, []Content{
|
c = append(c, []Content{
|
||||||
{Content: v.Name, Style: TrackStyle},
|
{Content: v.Name, Style: TrackStyle},
|
||||||
{Content: v.Artists[0].Name, Style: ArtistStyle},
|
{Content: artistName(v.Artists), Style: ArtistStyle},
|
||||||
{Content: v.Album.Name, Style: AlbumStyle},
|
{Content: v.Album.Name, Style: AlbumStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func (p *PlaylistView) Content() func() [][]Content {
|
|||||||
for _, v := range *(*p.currentUserFullPlaylist).Tracks {
|
for _, v := range *(*p.currentUserFullPlaylist).Tracks {
|
||||||
c = append(c, []Content{
|
c = append(c, []Content{
|
||||||
{Content: v.Track.Name, Style: TrackStyle},
|
{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},
|
{Content: v.Track.Album.Name, Style: AlbumStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (r *RecentlyPlayedView) Content() func() [][]Content {
|
|||||||
for _, v := range r.recentlyPlayed {
|
for _, v := range r.recentlyPlayed {
|
||||||
c = append(c, []Content{
|
c = append(c, []Content{
|
||||||
{Content: v.Track.Name, Style: TrackStyle},
|
{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},
|
{Content: utils.StrTime(float64(v.Track.Duration / 1000)), Style: TimeStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func (a *SearchView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
c = append(c, []Content{
|
c = append(c, []Content{
|
||||||
{Content: v.Name, Style: TrackStyle},
|
{Content: v.Name, Style: TrackStyle},
|
||||||
{Content: v.Artists[0].Name, Style: ArtistStyle},
|
{Content: artistName(v.Artists), Style: ArtistStyle},
|
||||||
{Content: v.Album.Name, Style: AlbumStyle},
|
{Content: v.Album.Name, Style: AlbumStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ func (a *SearchView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
c = append(c, []Content{
|
c = append(c, []Content{
|
||||||
{Content: v.Name, Style: AlbumStyle},
|
{Content: v.Name, Style: AlbumStyle},
|
||||||
{Content: v.Artists[0].Name, Style: ArtistStyle},
|
{Content: artistName(v.Artists), Style: ArtistStyle},
|
||||||
{Content: v.ReleaseDate, Style: TimeStyle},
|
{Content: v.ReleaseDate, Style: TimeStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,18 +35,6 @@ func (a *TopTracksView) RefreshState() {
|
|||||||
a.topArtists = artists
|
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 {
|
func (a *TopTracksView) Content() func() [][]Content {
|
||||||
return func() [][]Content {
|
return func() [][]Content {
|
||||||
c := make([][]Content, 0)
|
c := make([][]Content, 0)
|
||||||
@@ -61,7 +49,7 @@ func (a *TopTracksView) Content() func() [][]Content {
|
|||||||
for _, v := range a.topTracks {
|
for _, v := range a.topTracks {
|
||||||
c = append(c, []Content{
|
c = append(c, []Content{
|
||||||
{Content: v.Name, Style: TrackStyle},
|
{Content: v.Name, Style: TrackStyle},
|
||||||
{Content: v.Artists[0].Name, Style: ArtistStyle},
|
{Content: artistName(v.Artists), Style: ArtistStyle},
|
||||||
{Content: v.Album.Name, Style: AlbumStyle},
|
{Content: v.Album.Name, Style: AlbumStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user