public YandexAlbum GetAlbum(string albumId) { var request = GetRequest(_settings.GetAlbumURL(albumId), WebRequestMethods.Http.Get); var album = default(YandexAlbum); using (var response = (HttpWebResponse)request.GetResponse()) { var data = GetDataFromResponse(response); album = YandexAlbum.FromJson(data); _cookies.Add(response.Cookies); } return(album); }
public List <IYandexSearchable> Search(string searchText, YandexSearchType searchType, int page = 0) { var listResult = new List <IYandexSearchable>(); var request = GetRequest(_settings.GetSearchURL(searchText, searchType, page), WebRequestMethods.Http.Get); using (var response = (HttpWebResponse)request.GetResponse()) { var json = GetDataFromResponse(response); var fieldName = searchType.ToString().ToLower(); var jArray = (JArray)json[fieldName]["items"]; if (searchType == YandexSearchType.Tracks) { listResult = YandexTrack.FromJsonArray(jArray).Select(x => (IYandexSearchable)x).ToList(); } else if (searchType == YandexSearchType.Artists) { listResult = YandexArtist.FromJsonArray(jArray).Select(x => (IYandexSearchable)x).ToList(); } else if (searchType == YandexSearchType.Albums) { listResult = YandexAlbum.FromJsonArray(jArray).Select(x => (IYandexSearchable)x).ToList(); } else if (searchType == YandexSearchType.Playlists) { listResult = YandexPlaylist.FromJsonArray(jArray).Select(x => (IYandexSearchable)x).ToList(); } else if (searchType == YandexSearchType.Users) { listResult = YandexUser.FromJsonArray(jArray).Select(x => (IYandexSearchable)x).ToList(); } } return(listResult); }