public async Task <TVDBEpisodeResponse> EpisodeInformation(uint tvdbEpisodeID) { string apiCallURL = string.Format("{0}/api/{1}/episodes/{2}", _baseURL, _apiKey, tvdbEpisodeID); string tvdbResponse = string.Empty; TVDBEpisodeResponse tvdbEpisodeResponse = new TVDBEpisodeResponse(); try { tvdbResponse = await GetHTTPString(new Uri(apiCallURL)); } catch (HttpRequestException) { tvdbEpisodeResponse.serverUnavailable = true; return(tvdbEpisodeResponse); } // return an empty response if the the tvdb was dead if (string.IsNullOrEmpty(tvdbResponse)) { return(null); } // read the response in through a memory stream and use the xml serializer using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(tvdbResponse))) { var serializer = new XmlSerializer(typeof(TVDBEpisodeResponse)); tvdbEpisodeResponse = (serializer.Deserialize(memoryStream) as TVDBEpisodeResponse); } // we should have some info now so return it return(tvdbEpisodeResponse); }
public async Task<TVDBEpisodeResponse> EpisodeInformation(uint tvdbEpisodeID) { string apiCallURL = string.Format("{0}/api/{1}/episodes/{2}", _baseURL, _apiKey, tvdbEpisodeID); string tvdbResponse = string.Empty; TVDBEpisodeResponse tvdbEpisodeResponse = new TVDBEpisodeResponse(); try { tvdbResponse = await GetHTTPString(new Uri(apiCallURL)); } catch (HttpRequestException) { tvdbEpisodeResponse.serverUnavailable = true; return tvdbEpisodeResponse; } // return an empty response if the the tvdb was dead if (string.IsNullOrEmpty(tvdbResponse)) return null; // read the response in through a memory stream and use the xml serializer using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(tvdbResponse))) { var serializer = new XmlSerializer(typeof(TVDBEpisodeResponse)); tvdbEpisodeResponse = (serializer.Deserialize(memoryStream) as TVDBEpisodeResponse); } // we should have some info now so return it return tvdbEpisodeResponse; }