private async Task <ResponseInfo> GetYoutubeSongs(JToken parameters) { var searchTerm = parameters["searchTerm"].ToObject <string>(); try { var requestCache = Locator.Current.GetService <IBlobCache>(BlobCacheKeys.RequestCacheContract); var songFinder = new YoutubeSongFinder(requestCache); IReadOnlyList <YoutubeSong> songs = await songFinder.GetSongsAsync(searchTerm); // Cache the latest YouTube search request, so we can find the songs by GUID when we // add one to the playlist later this.lastYoutubeRequest = songs; JObject content = MobileHelper.SerializeSongs(songs); return(CreateResponse(ResponseStatus.Success, content)); } catch (NetworkSongFinderException) { return(CreateResponse(ResponseStatus.Failed, "Couldn't retrieve any YouTube songs")); }; }
private async Task <ResponseInfo> GetLibraryContent(JToken dontCare) { JObject content = await Task.Run(() => MobileHelper.SerializeSongs(this.library.Songs)); return(CreateResponse(ResponseStatus.Success, null, content)); }