예제 #1
0
        /// <summary>
        ///   Upload a track to sound cloud.
        /// </summary>
        /// <remarks>
        ///   To upload a track, you have to specify the following properties :
        ///   * Uri : the path of the file on your computer.
        ///   * Title : title of the track.
        ///   * Description : a brief description of the track.
        ///   * Sharing : public or private.
        /// </remarks>
        public void Add()
        {
            if (Uri != null && Title != null && Description != null && Sharing != null)
            {
                if (File.Exists(Path.GetFullPath(Uri)))
                {
                    var parameters = new Dictionary <string, object>
                    {
                        { "track[asset_data]", Path.GetFullPath(Uri) },
                        { "track[title]", Title },
                        { "track[description]", Description },
                        { "track[sharing]", Sharing }
                    };

                    SoundCloudApi.ApiAction <Track>(ApiCommand.Tracks, HttpMethod.Post, parameters);
                }
                else
                {
                    throw new FileNotFoundException();
                }
            }
            else
            {
                throw new ArgumentNullException();
            }
        }
예제 #2
0
        /// <summary>
        /// Returns a collection of users based on a pattern.
        /// </summary>
        ///
        /// <param name="term">a term to search for.</param>
        public static List <User> Search(string term)
        {
            var parameters = new Dictionary <string, object> {
                { "q", term }
            };

            return(SoundCloudApi.ApiAction <List <User> >(ApiCommand.Users, parameters));
        }
예제 #3
0
        /// <summary>
        /// Returns a limited collection of users.
        /// </summary>
        ///
        /// <param name="count">Users count.</param>
        public static List <User> GetUsers(int count)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add("limit", count);

            return(SoundCloudApi.ApiAction <List <User> >(ApiCommand.Users, parameters));
        }
예제 #4
0
        /// <summary>
        ///   Returns a collection of tracks after filtering.
        /// </summary>
        /// <param name="term"> </param>
        /// <param name="tags"> </param>
        /// <param name="filter"> </param>
        /// <param name="license"> </param>
        /// <param name="order"> </param>
        /// <param name="bpmFrom"> </param>
        /// <param name="bpmTo"> </param>
        /// <param name="durationFrom"> </param>
        /// <param name="durationTo"> </param>
        /// <param name="from"> </param>
        /// <param name="to"> </param>
        /// <param name="ids"> </param>
        /// <param name="genres"> </param>
        /// <param name="types"> </param>
        public static List <Track> Search(string term, string[] tags, Filter filter, string license, string order,
                                          int?bpmFrom, int?bpmTo, int?durationFrom, int?durationTo, DateTime from,
                                          DateTime to, int[] ids, string[] genres, string[] types)
        {
            var filters = new Dictionary <string, object>();

            if (term != null)
            {
                filters.Add("q", term);
            }
            if (tags != null && tags.Length > 0)
            {
                filters.Add("tags", String.Join(",", tags));
            }

            filters.Add("filter", filter.ToString().ToLower());

            if (license != null)
            {
                filters.Add("license", license);
            }
            if (order != null)
            {
                filters.Add("order", order);
            }
            if (bpmFrom != null && bpmTo != null)
            {
                filters.Add("bpm[from]", bpmFrom);
                filters.Add("bpm[to]", bpmTo);
            }
            if (durationFrom != null && durationTo != null)
            {
                filters.Add("duration[from]", durationFrom);
                filters.Add("duration[to]", durationTo);
            }
            if (from != null && to != null)
            {
                filters.Add("created_at[from]", from.ToString("yyyy/MM/dd hh:mm:ss"));
                filters.Add("created_at[to]", to.ToString("yyyy/MM/dd hh:mm:ss"));
            }
            if (ids != null && ids.Length > 0)
            {
                filters.Add("ids", String.Join(",", ids));
            }
            if (genres != null && genres.Length > 0)
            {
                filters.Add("genres", String.Join(",", genres));
            }
            if (types != null && types.Length > 0)
            {
                filters.Add("types", String.Join(",", types));
            }

            return(SoundCloudApi.ApiAction <List <Track> >(ApiCommand.Tracks, filters));
        }
        public SoundCloudAccessToken Authenticate()
        {
            SoundCloudAccessToken token = SoundCloudApi.ApiAction <SoundCloudAccessToken>(ApiCommand.UserCredentialsFlow, HttpMethod.Post, Credentials.ClientID, Credentials.ClientSecret, Credentials.UserName, Credentials.Password);

            SoundCloudAccessToken = token;

            if (token != null)
            {
                IsAuthenticated = true;
            }

            return(token);
        }
예제 #6
0
        /// <summary>
        ///   Share a track to a social network.
        /// </summary>
        /// <param name="connection"> Registered social profile on sound cloud. </param>
        /// <param name="sharingNote"> String that will be used as status message. This string might be truncated by SoundCloud. </param>
        public void Share(Connection connection, string sharingNote)
        {
            var parameters = new Dictionary <string, object> {
                { "connections[][id]", connection.Id }
            };

            if (sharingNote != null)
            {
                parameters.Add("sharing_note", sharingNote);
            }

            SoundCloudApi.ApiAction <Track>(ApiCommand.TrackShare, HttpMethod.Post, parameters, Id);
        }
예제 #7
0
 /// <summary>
 /// Returns a playlist by playlist id.
 /// </summary>
 ///
 /// <param name="id">Playlist id.</param>
 public static Playlist GetPlaylist(int id)
 {
     return(SoundCloudApi.ApiAction <Playlist>(ApiCommand.Playlist, id));
 }
예제 #8
0
 /// <summary>
 /// Returns a collection of playlists.
 /// </summary>
 public static List <Playlist> GetAllPlaylists()
 {
     return(SoundCloudApi.ApiAction <List <Playlist> >(ApiCommand.Playlists));
 }
예제 #9
0
 /// <summary>
 /// Returns a comment by comment id.
 /// </summary>
 ///
 /// <param name="id">Comment id.</param>
 public static Comment GetComment(int id)
 {
     return(SoundCloudApi.ApiAction <Comment>(ApiCommand.Comment));
 }
예제 #10
0
 /// <summary>
 /// Retrieves connections for the authenticated user.
 /// </summary>
 public static List <Connection> MyConnections()
 {
     return(SoundCloudApi.ApiAction <List <Connection> >(ApiCommand.MeConnections));
 }
예제 #11
0
 /// <summary>
 /// Removes the user with the id contact_id from the givens user's list of contacts.
 /// </summary>
 ///
 /// <param name="id">User id to remove.</param>
 public void RemoveFollowing(int id)
 {
     SoundCloudApi.ApiAction <User>(ApiCommand.UserFollowingsContact, HttpMethod.Delete, Id, id);
 }
예제 #12
0
 /// <summary>
 /// Returns comments of a track by track id.
 /// </summary>
 /// <returns></returns>
 public List <Comment> GetComments()
 {
     return(SoundCloudApi.ApiAction <List <Comment> >(ApiCommand.TrackComments, Id));
 }
예제 #13
0
 /// <summary>
 /// Returns a combined collection of moderators, members and contributors of the group with group id.
 /// </summary>
 /// <returns></returns>
 public List <User> GetUsers()
 {
     return(SoundCloudApi.ApiAction <List <User> >(ApiCommand.GroupUsers, Id));
 }
예제 #14
0
 /// <summary>
 /// Returns a collection of users.
 /// </summary>
 public static List <User> GetAllUsers()
 {
     return(SoundCloudApi.ApiAction <List <User> >(ApiCommand.Users));
 }
예제 #15
0
 /// <summary>
 /// Returns a collection of playlists created by user with user id
 /// </summary>
 public List <Playlist> GetPlaylists(int id)
 {
     return(SoundCloudApi.ApiAction <List <Playlist> >(ApiCommand.UserPlaylists, Id));
 }
예제 #16
0
 /// <summary>
 /// Returns a collection of groups joined by user with user id.
 /// </summary>
 public List <Group> GetGroups()
 {
     return(SoundCloudApi.ApiAction <List <Group> >(ApiCommand.UserGroups, Id));
 }
예제 #17
0
 /// <summary>
 /// Returns a collection of tracks favorited by the user with user id.
 /// </summary>
 public List <Track> GetFavorites()
 {
     return(SoundCloudApi.ApiAction <List <Track> >(ApiCommand.UserFavorites, Id));
 }
예제 #18
0
 /// <summary>
 /// Returns a collection of tracks uploaded by user id.
 /// </summary>
 public List <Track> GetTracks()
 {
     return(SoundCloudApi.ApiAction <List <Track> >(ApiCommand.UserTracks, Id));
 }
예제 #19
0
 /// <summary>
 /// Returns a collection of users who follow the user with user id
 /// </summary>
 public List <User> GetFollowers()
 {
     return(SoundCloudApi.ApiAction <List <User> >(ApiCommand.UserFollowers, Id));
 }
예제 #20
0
 /// <summary>
 ///   Returns a collection of tracks.
 /// </summary>
 public static List <Track> GetTracks()
 {
     return(SoundCloudApi.ApiAction <List <Track> >(ApiCommand.Tracks));
 }
예제 #21
0
 /// <summary>
 ///   Returns a track by track id.
 /// </summary>
 /// <param name="id"> Track id. </param>
 public static Track GetTrack(int id)
 {
     return(SoundCloudApi.ApiAction <Track>(ApiCommand.Track, id));
 }
예제 #22
0
 /// <summary>
 /// Adds the given track to the logged-in user's list of favorites.
 /// </summary>
 public void AddToFavorites()
 {
     SoundCloudApi.ApiAction <Track>(ApiCommand.MeFavoritesTrack, HttpMethod.Put, Id);
 }
예제 #23
0
 /// <summary>
 ///   Deletes a given track.
 /// </summary>
 /// <remarks>
 ///   To delete a track, you have to be the owner or you have permission to delete it.
 /// </remarks>
 public void Delete()
 {
     SoundCloudApi.ApiAction <Track>(ApiCommand.Track, HttpMethod.Delete, Id);
 }
예제 #24
0
 /// <summary>
 /// Returns a group by group id.
 /// </summary>
 /// <param name="id">Group id.</param>
 public static Group GetGroup(int id)
 {
     return(SoundCloudApi.ApiAction <Group>(ApiCommand.Group, id));
 }
예제 #25
0
 /// <summary>
 /// Returns all users with permission for a track by track id.
 /// </summary>
 /// <returns></returns>
 public List <User> GetPermissions()
 {
     return(SoundCloudApi.ApiAction <List <User> >(ApiCommand.TrackPermissions, Id));
 }
예제 #26
0
 /// <summary>
 /// Adds the user with the id contact_id to the givens user's list of contacts.
 /// </summary>
 ///
 /// <param name="id">User id to follow.</param>
 public void AddFollowing(int id)
 {
     SoundCloudApi.ApiAction <User>(ApiCommand.UserFollowingsContact, HttpMethod.Put, Id, id);
 }
예제 #27
0
 /// <summary>
 ///   Deletes the given track from the logged-in user's list of favorites.
 /// </summary>
 public void RemoveFromFavorites()
 {
     SoundCloudApi.ApiAction <Track>(ApiCommand.MeFavoritesTrack, HttpMethod.Delete, Id);
 }
예제 #28
0
 /// <summary>
 /// Returns a user by user id.
 /// </summary>
 ///
 /// <param name="id">User id.</param>
 public static User GetUser(int id)
 {
     return(SoundCloudApi.ApiAction <User>(ApiCommand.User, id));
 }
예제 #29
0
 /// <summary>
 /// Returns the logged-in user.
 /// </summary>
 public static User Me()
 {
     return(SoundCloudApi.ApiAction <User>(ApiCommand.Me));
 }
예제 #30
0
 /// <summary>
 /// Returns a collection of groups.
 /// </summary>
 public static List <Group> GetAllGroups()
 {
     return(SoundCloudApi.ApiAction <List <Group> >(ApiCommand.Groups));
 }