internal TvdbSeriesFields DownloadSeriesFields(int _seriesId, TvdbLanguage _language) { String data; try { data = m_webClient.DownloadString(TvdbLinks.CreateSeriesLink(m_apiKey, _seriesId, _language, false, false)); } catch (Exception ex) { Log.Warn("Request not successfull", ex); return(null); } //extract all series the xml file contains List <TvdbSeriesFields> seriesList = m_xmlHandler.ExtractSeriesFields(data); if (seriesList != null && seriesList.Count == 1) { return(seriesList[0]); } else { return(null); } }
internal TvdbSeriesFields DownloadSeriesFields(int _seriesId, TvdbLanguage _language) { String data; try { data = m_webClient.DownloadString(TvdbLinks.CreateSeriesLink(m_apiKey, _seriesId, _language, false, false)); } catch (WebException ex) { Log.Warn("Request not successfull", ex); if (ex.Message.Equals("The remote server returned an error: (404) Not Found.")) { throw new TvdbInvalidApiKeyException("Couldn't connect to Thetvdb.com to retrieve " + _seriesId + ", it seems like you have an invalid api key (" + m_apiKey + ")"); } else { throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve " + _seriesId + ", check your internet connection and the status of http://thetvdb.com"); } } //extract all series the xml file contains List <TvdbSeriesFields> seriesList = m_xmlHandler.ExtractSeriesFields(data); if (seriesList != null && seriesList.Count == 1) { return(seriesList[0]); } else { return(null); } }
/// <summary> /// Download series from tvdb /// </summary> /// <param name="series"></param> /// <returns></returns> internal TvdbSeries DownloadSeries(int _seriesId, TvdbLanguage _language, bool _loadEpisodes, bool _loadActors, bool _loadBanners) { //download the xml data from this request String data; try { data = m_webClient.DownloadString(TvdbLinks.CreateSeriesLink(m_apiKey, _seriesId, _language, _loadEpisodes, false)); } catch (Exception ex) { Log.Warn("Request not successfull", ex); return(null); } //extract all series the xml file contains List <TvdbSeries> seriesList = m_xmlHandler.ExtractSeries(data); //if a request is made on a series id, one and only one result //should be returned, otherwise there obviously was an error if (seriesList != null && seriesList.Count == 1) { TvdbSeries series = seriesList[0]; if (_loadEpisodes) { //add episode info to series List <TvdbEpisode> epList = m_xmlHandler.ExtractEpisodes(data); foreach (TvdbEpisode e in epList) { Util.AddEpisodeToSeries(e, series); } } //also load actors if (_loadActors) { List <TvdbActor> list = DownloadActors(_seriesId); if (list != null) { series.TvdbActors = list; } } //also load banner paths if (_loadBanners) { List <TvdbBanner> banners = DownloadBanners(_seriesId); if (banners != null) { series.Banners = banners; } } return(series); } else { Log.Warn("More than one series returned when trying to retrieve series " + _seriesId); return(null); } }
/// <summary> /// Download series from tvdb /// </summary> /// <param name="_seriesId">id of series</param> /// <param name="_language">language of series</param> /// <param name="_loadEpisodes">load episodes</param> /// <param name="_loadActors">load actors</param> /// <param name="_loadBanners">load banners</param> /// <returns></returns> internal TvdbSeries DownloadSeries(int _seriesId, TvdbLanguage _language, bool _loadEpisodes, bool _loadActors, bool _loadBanners) { //download the xml data from this request String xml = ""; String link = ""; try { link = TvdbLinks.CreateSeriesLink(m_apiKey, _seriesId, _language, _loadEpisodes, false); xml = m_webClient.DownloadString(link); //extract all series the xml file contains List <TvdbSeries> seriesList = m_xmlHandler.ExtractSeries(xml); //if a request is made on a series id, one and only one result //should be returned, otherwise there obviously was an error if (seriesList != null && seriesList.Count == 1) { TvdbSeries series = seriesList[0]; if (_loadEpisodes) { //add episode info to series List <TvdbEpisode> epList = m_xmlHandler.ExtractEpisodes(xml); foreach (TvdbEpisode e in epList) { Util.AddEpisodeToSeries(e, series); } } //also load actors if (_loadActors) { List <TvdbActor> list = DownloadActors(_seriesId); if (list != null) { series.TvdbActors = list; } } //also load banner paths if (_loadBanners) { List <TvdbBanner> banners = DownloadBanners(_seriesId); if (banners != null) { series.Banners = banners; } } return(series); } else { Log.Warn("More than one series returned when trying to retrieve series " + _seriesId); return(null); } } catch (XmlException ex) { Log.Error("Error parsing the xml file " + link + "\n\n" + xml, ex); throw new TvdbInvalidXmlException("Error parsing the xml file " + link + "\n\n" + xml); } catch (WebException ex) { Log.Warn("Request not successfull", ex); if (ex.Message.Equals("The remote server returned an error: (404) Not Found.")) { throw new TvdbInvalidApiKeyException("Couldn't connect to Thetvdb.com to retrieve " + _seriesId + ", it seems like you have an invalid api key"); } else { throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve " + _seriesId + ", check your internet connection and the status of http://thetvdb.com"); } } }