Esempio n. 1
0
func (cui *ConsoleUserInterface) ArtistTopTracks(playlist *sconsify.Playlist) {
	gui.infoTopTracksView.Clear()

	fmt.Fprintf(gui.infoTopTracksView, "Top Tracks\n")
	for i := 0; i < playlist.Tracks(); i++ {
		track := playlist.Track(i)
		fmt.Fprintf(gui.infoTopTracksView, "%v. %v\n", (i + 1), track.Name)
	}
}
Esempio n. 2
0
func (spotify *Spotify) loadSongs(playlist *sconsify.Playlist, webApiCache *WebApiCache) {
	var partialSongs []webspotify.SavedTrack
	if spotify.client != nil {
		if savedTrackPage, err := spotify.client.CurrentUsersTracksOpt(createWebSpotifyOptions(50, playlist.Tracks())); err == nil {
			partialSongs = savedTrackPage.Tracks
			if webApiCache.Songs == nil {
				webApiCache.Songs = make([]webspotify.SavedTrack, 0)
			}
			webApiCache.Songs = append(webApiCache.Songs, partialSongs...)
		}
	}

	if webApiCache.Songs != nil {
		if partialSongs == nil {
			partialSongs = webApiCache.Songs
		}
		for i, track := range partialSongs {
			webApiCache.Songs[i] = track
			webArtist := track.Artists[0]
			artist := sconsify.InitArtist(string(webArtist.URI), webArtist.Name)
			playlist.AddTrack(sconsify.InitWebApiTrack(string(track.URI), artist, track.Name, track.TimeDuration().String()))
		}
	}
}
Esempio n. 3
0
func (spotify *Spotify) loadSongs(playlist *sconsify.Playlist) {
	savedTrackPage, err := spotify.client.CurrentUsersTracksOpt(createWebSpotifyOptions(50, playlist.Tracks()))
	if err != nil {
		return
	}
	for _, track := range savedTrackPage.Tracks {
		webArtist := track.Artists[0]
		artist := sconsify.InitArtist(string(webArtist.URI), webArtist.Name)
		playlist.AddTrack(sconsify.InitWebApiTrack(string(track.URI), artist, track.Name, track.TimeDuration().String()))
	}
}