/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void userGetUser_Click(object sender, EventArgs e) { // get my profile, returns a basic profile SpotifyWebAPI.User user = await SpotifyWebAPI.User.GetUser("tinyioda"); output.Text = VarDump.Dump(user, 0); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void userGetCurrentUserProfile_Click(object sender, EventArgs e) { // get the user you just logged in with SpotifyWebAPI.User user = await SpotifyWebAPI.User.GetCurrentUserProfile(this.AuthenticationToken); output.Text = VarDump.Dump(user, 0); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void userCreatePlaylist_Click(object sender, EventArgs e) { // get the user SpotifyWebAPI.User user = await SpotifyWebAPI.User.GetCurrentUserProfile(this.AuthenticationToken); // create the playlist, this method also returns the playlist var newPlaylist = await SpotifyWebAPI.Playlist.CreatePlaylist(user.Id, "test", true, this.AuthenticationToken); output.Text = VarDump.Dump(newPlaylist, 0); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void userGetPlaylists_Click(object sender, EventArgs e) { // get the user you just logged in with SpotifyWebAPI.User user = await SpotifyWebAPI.User.GetCurrentUserProfile(this.AuthenticationToken); // get this persons playlists SpotifyWebAPI.Page <Playlist> playlists = await user.GetPlaylists(this.AuthenticationToken); output.Text = VarDump.Dump(playlists, 0); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void userDeleteTracks_Click(object sender, EventArgs e) { // get alter bridge's blackbird album tracks var output = await SpotifyWebAPI.Album.GetAlbumTracks("0Fk4lWAADmFMmuW6jp6xyE"); // get the user SpotifyWebAPI.User user = await SpotifyWebAPI.User.GetCurrentUserProfile(this.AuthenticationToken); // send the tracks to spotify await user.DeleteTracks(output.Items.Select(i => i.Id).ToList(), this.AuthenticationToken); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void userUpdatePlaylist_Click(object sender, EventArgs e) { // get the user SpotifyWebAPI.User user = await SpotifyWebAPI.User.GetCurrentUserProfile(this.AuthenticationToken); // get all the playlist var playlists = await user.GetPlaylists(this.AuthenticationToken); // try and find the one we just created var playlist = playlists.Items.Where(i => i.Name == "test").FirstOrDefault(); await playlist.UpdatePlaylist("new name", false, this.AuthenticationToken); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void userIsTrackSaved_Click(object sender, EventArgs e) { // get alter bridge's blackbird album tracks var tracks = await SpotifyWebAPI.Album.GetAlbumTracks("0Fk4lWAADmFMmuW6jp6xyE"); // get the user SpotifyWebAPI.User user = await SpotifyWebAPI.User.GetCurrentUserProfile(this.AuthenticationToken); // check to see if the track is saved (ties that bind, alter bridge) var isSaved = await user.IsSaved(tracks.Items.FirstOrDefault().Id, this.AuthenticationToken); output.Text = isSaved.ToString(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void userAddToPlaylist_Click(object sender, EventArgs e) { // get the user you just logged in with SpotifyWebAPI.User user = await SpotifyWebAPI.User.GetCurrentUserProfile(this.AuthenticationToken); // get all the playlists SpotifyWebAPI.Page <Playlist> playlists = await user.GetPlaylists(this.AuthenticationToken); // get the first playlist in the list // yes i know this is redundant but i am testing the method GetPlaylist() SpotifyWebAPI.Playlist playlist = await SpotifyWebAPI.Playlist.GetPlaylist(user, playlists.Items.FirstOrDefault().Id, this.AuthenticationToken); // get alter bridge's blackbird album tracks var tracks = await SpotifyWebAPI.Album.GetAlbumTracks("0Fk4lWAADmFMmuW6jp6xyE"); // add the tracks to the playlist await playlist.AddTracks(tracks.Items, this.AuthenticationToken); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void userGetPlaylist_Click(object sender, EventArgs e) { // get the user you just logged in with SpotifyWebAPI.User user = await SpotifyWebAPI.User.GetCurrentUserProfile(this.AuthenticationToken); // get all the playlists SpotifyWebAPI.Page <Playlist> playlists = await user.GetPlaylists(this.AuthenticationToken); // get the first playlist in the list // yes i know this is redundant but i am testing the method GetPlaylist() SpotifyWebAPI.Playlist playlist = await SpotifyWebAPI.Playlist.GetPlaylist(user, playlists.Items.FirstOrDefault().Id, this.AuthenticationToken); output.Text += VarDump.Dump(playlist, 0); // get the tracks // not by using GetPlaylist() in the previous command you already get the tracks, i'm just doing more testing here. SpotifyWebAPI.Page <PlaylistTrack> tracks = await playlist.GetPlaylistTracks(this.AuthenticationToken); output.Text += VarDump.Dump(tracks, 0); }