Example #1
0
 /// <summary>
 /// Get a list of featured playlists
 /// </summary>
 /// <param name="token"></param>
 /// <param name="locale"></param>
 /// <param name="country"></param>
 /// <param name="timestamp">A timestamp in ISO 8601 format: yyyy-MM-ddTHH:mm:ss.</param>
 /// <param name="limit"></param>
 /// <param name="offset"></param>
 /// <returns></returns>
 public async static Task <Page <Playlist> > GetFeaturedPlaylists(AuthenticationToken token, string locale = "", string country = "", string timestamp = "", int limit = 20, int offset = 0)
 {
     return(await Browse.GetFeaturedPlaylists(token, locale, country, timestamp, limit, offset));
 }
Example #2
0
 /// <summary>
 /// Change a playlist’s name and public/private state. (The user must, of course, own the playlist.)
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="name"></param>
 /// <param name="isPublic"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public async Task UpdatePlaylist(string name, bool isPublic, AuthenticationToken token)
 {
     await UpdateUsersPlaylist(this.Owner.Id, this.Id, name, isPublic, token);
 }
Example #3
0
 /// <summary>
 /// Replace all the tracks in a playlist, overwriting its existing tracks. This powerful request can be useful for replacing tracks, re-ordering existing tracks, or clearing the playlist.
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="playlistId"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public async Task ReplacePlaylistTracks(string userId, string playlistId, AuthenticationToken token, List <Track> tracks)
 {
     throw new NotImplementedException();
 }
Example #4
0
        /// <summary>
        /// Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.)
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="name"></param>
        /// <param name="isPublic"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static async Task <Playlist> CreatePlaylist(string userId, string name, bool isPublic, AuthenticationToken token)
        {
            dynamic newObject = new System.Dynamic.ExpandoObject();

            newObject.name    = name;
            newObject.@public = isPublic;

            string jsonInput = JsonConvert.SerializeObject(newObject);
            var    json      = await HttpHelper.Post("https://api.spotify.com/v1/users/" + userId + "/playlists", token, jsonInput);

            var obj = JsonConvert.DeserializeObject <playlist>(json, new JsonSerializerSettings
            {
                TypeNameHandling       = TypeNameHandling.All,
                TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple
            });

            return(obj.ToPOCO());
        }
Example #5
0
        /// <summary>
        /// Change a playlist’s name and public/private state. (The user must, of course, own the playlist.)
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="name"></param>
        /// <param name="isPublic"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static async Task UpdateUsersPlaylist(string userId, string playlistId, string name, bool isPublic, AuthenticationToken token)
        {
            dynamic newObject = new System.Dynamic.ExpandoObject();

            newObject.name    = name;
            newObject.@public = isPublic;

            string jsonInput = JsonConvert.SerializeObject(newObject);
            var    json      = await HttpHelper.Put("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId, token, jsonInput);
        }
Example #6
0
 /// <summary>
 /// Add a track to a user’s playlist.
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public async Task AddTrack(Track track, AuthenticationToken token)
 {
     await HttpHelper.Post("https://api.spotify.com/v1/users/" + this.Owner.Id + "/playlists/" + this.Id + "/tracks?uris=" + track.Uri, token);
 }
Example #7
0
 /// <summary>
 /// Add one or more tracks to a user’s playlist.
 /// </summary>
 /// <param name="tracks"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public async Task AddTracks(List <Track> trackUris, AuthenticationToken token)
 {
     string tracksUri = CreateCommaSeperatedList(trackUris.Select(t => t.Uri).ToList());
     var    json      = await HttpHelper.Post("https://api.spotify.com/v1/users/" + this.Owner.Id + "/playlists/" + this.Id + "/tracks?uris=" + tracksUri, token);
 }
Example #8
0
 /// <summary>
 /// Get full details of the tracks of this playlist
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public async Task <Page <PlaylistTrack> > GetPlaylistTracks(AuthenticationToken token)
 {
     return(await GetPlaylistTracks(this.Owner.Id, this.Id, token));
 }
Example #9
0
        /// <summary>
        /// Get full details of the tracks of a playlist owned by a Spotify user.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static async Task <Page <PlaylistTrack> > GetPlaylistTracks(string userId, string playlistId, AuthenticationToken token)
        {
            var json = await HttpHelper.Get("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks", token);

            var obj = JsonConvert.DeserializeObject <page <playlisttrack> >(json, new JsonSerializerSettings
            {
                TypeNameHandling       = TypeNameHandling.All,
                TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple
            });

            return(obj.ToPOCO <PlaylistTrack>());
        }
Example #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="user"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public static async Task <Playlist> GetPlaylist(User user, string playlistId, AuthenticationToken token)
 {
     return(await GetPlaylist(user.Id, playlistId, token));
 }
Example #11
0
 /// <summary>
 /// Get a list of the playlists owned by a Spotify user.
 /// </summary>
 /// <param name="user"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public static async Task <Page <Playlist> > GetUsersPlaylists(User user, AuthenticationToken token)
 {
     return(await GetUsersPlaylists(user.Id, token));
 }
Example #12
0
 /// <summary>
 /// Get a list of new releases
 /// </summary>
 /// <returns></returns>
 public async Task <Page <Album> > GetNewReleases(AuthenticationToken token, string country = "", int limit = 20, int offset = 0)
 {
     return(await Browse.GetNewReleases(token, country, limit, offset));
 }