public static async Task <string> GetGenre() //get first recommended genre { var genreGetter = new SpotifyWebAPI(); string GenreToReturn = ""; //implict grant auth WebAPIFactory webAPIFactory = new WebAPIFactory( "http://localhost", 8000, "e81fba25bb5742d0a872e6813c55eb49", Scope.UserReadPrivate, TimeSpan.FromSeconds(20)); try { genreGetter = await webAPIFactory.GetWebApi(); } catch (Exception ex) { } if (genreGetter == null) { throw new NullReferenceException("Something went wrong... Sorry! Make sure you are authorized correctly."); } Task <RecommendationSeedGenres> asyncronousGenre = genreGetter.GetRecommendationSeedsGenresAsync(); genreGetter.UseAuth = true; string AccessTest = genreGetter.AccessToken; RecommendationSeedGenres ReccoGenres = asyncronousGenre.Result; string[] arrayOfGenres = new string[145]; arrayOfGenres = ReccoGenres.Genres.ToArray(); Random rand = new Random(); GenreToReturn = arrayOfGenres[rand.Next(146)]; return(GenreToReturn); }
public ActionResult GetGenres() { List <string> model = null; CustomToken token = ViewBag.Token; if (!token.IsTokenEmpty()) { RecommendationSeedGenres recommendationSeedGenres = _paradifyService.GetGenres(token); if (recommendationSeedGenres != null && recommendationSeedGenres.Genres != null && recommendationSeedGenres.Genres.Count > 0) { model = recommendationSeedGenres.Genres; } } return(PartialView("~/Views/Shared/Genres/_Genres.cshtml", model)); }