示例#1
0
        public SCTrack[] GetTracks(SCExploreCategory category, int offset = 0, int limit = 10)
        {
            paginationValidator.Validate(offset, limit);

            var parameters = new Dictionary <string, object>();

            var tracks = soundCloudRawClient.Request <ExploreTrackList>(prefix, category.Name, HttpMethod.Get, parameters: parameters.SetPagination(offset, limit), domain: Internal.Client.Helpers.Domain.ApiV2, responseType: string.Empty);

            return(tracks.Tracks.Select(trackConverter.Convert).ToArray());
        }
示例#2
0
        public SCTrack[] GetTracks(SCExploreCategory category, int offset = 0, int limit = 10)
        {
            paginationValidator.Validate(offset, limit);

            var parameters = new Dictionary <string, object>();

            parameters.Add("kind", "top");

            //Build genre paramter
            var processed = (category == null || category.Name == "Popular+Music") ? "all-music" : new String(System.Uri.UnescapeDataString(category.Name).Where(ch => Char.IsLetterOrDigit(ch)).ToArray()).ToLower();
            var g         = string.Format("soundcloud%3Agenres%3A{0}", processed);

            parameters.Add("genre", g);
            parameters.Add("linked_partitioning", 1);

            var tracks = soundCloudRawClient.Request <ChartTrackList>(prefix, command, HttpMethod.Get, parameters: parameters.SetPagination(offset, limit), domain: Internal.Client.Helpers.Domain.ApiV2, responseType: string.Empty);

            return(tracks.Tracks.Select(ct => trackConverter.Convert(ct.Track)).ToArray());
        }
        public SCTrack[] GetTracks(SCExploreCategory category, int offset = 0, int limit = 10)
        {
            paginationValidator.Validate(offset, limit);

            var parameters = new Dictionary <string, object> {
                { "kind", "top" }
            };

            var categoryName = category.GetName();

            var processed = categoryName == null || categoryName == "Popular+Music"
                ? "all-music"
                : new string(Uri.UnescapeDataString(categoryName).Where(char.IsLetterOrDigit).ToArray()).ToLower();
            var genreFormatQuery = $"soundcloud%3Agenres%3A{processed}";

            parameters.Add("genre", genreFormatQuery);
            parameters.Add("linked_partitioning", 1);

            var tracks = soundCloudRawClient.Request <ChartTrackCollection>(prefix, command, HttpMethod.Get, parameters: parameters.SetPagination(offset, limit), domain: Internal.Client.Helpers.Domain.ApiV2, responseType: string.Empty);

            return(tracks.Collection.Select(ct => trackConverter.Convert(ct.Track)).ToArray());
        }
示例#4
0
        public void TestDubstepCategory()
        {
            var tracks = chartApi.GetTracks(SCExploreCategory.Create(SCExploreCategoryType.Dubstep));

            Assert.IsTrue(tracks.Any());
        }
示例#5
0
        public void TestGetChartPopularMusicCategory()
        {
            var tracks = chartApi.GetTracks(SCExploreCategory.Create(SCExploreCategoryType.PopularMusic));

            Assert.IsTrue(tracks.Any());
        }
示例#6
0
        public void TestGetChartSpecificCategory()
        {
            var tracks = chartApi.GetTracks(SCExploreCategory.Create(SCExploreCategoryType.Classical));

            Assert.IsTrue(tracks.Any());
        }
示例#7
0
        public void TestGetTracks()
        {
            var tracks = exploreApi.GetTracks(SCExploreCategory.Create(SCExploreCategoryType.Ambient));

            Assert.IsTrue(tracks.Any());
        }
 public static string GetName(this SCExploreCategory category)
 {
     return(category?.Type?.GetValue() ?? category?.Name);
 }