Beispiel #1
0
 /// <summary>
 /// Download the episode specified from http://thetvdb.com
 /// </summary>
 /// <param name="_seriesId">series id</param>
 /// <param name="_seasonNr">season nr</param>
 /// <param name="_episodeNr">episode nr</param>
 /// <param name="_language">language</param>
 /// <param name="_order">order</param>
 /// <returns></returns>
 internal TvdbEpisode DownloadEpisode(int _seriesId, int _seasonNr, int _episodeNr, String _order, TvdbLanguage _language)
 {
     try
     {
         String             xml    = m_webClient.DownloadString(TvdbLinks.CreateEpisodeLink(m_apiKey, _seriesId, _seasonNr, _episodeNr, _order, _language));
         List <TvdbEpisode> epList = m_xmlHandler.ExtractEpisodes(xml);
         if (epList.Count == 1)
         {
             return(epList[0]);
         }
         else
         {
             return(null);
         }
     }
     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 + "/" +
                                                  _order + "/" + _seasonNr + "/" + _episodeNr + "/" + _language.Abbriviation +
                                                  ", it seems like you have an invalid api key (" + m_apiKey + ")");
         }
         else
         {
             throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve " + _seriesId + "/" +
                                                 _order + "/" + _seasonNr + "/" + _episodeNr + "/" + _language.Abbriviation +
                                                 ", check your internet connection and the status of http://thetvdb.com");
         }
     }
 }
        /// <summary>
        /// Download the episode specified from http://thetvdb.com
        /// </summary>
        /// <param name="_seriesId">series id</param>
        /// <param name="_airDate">when did the episode air</param>
        /// <param name="_language">language</param>
        /// <returns>Episode</returns>
        internal TvdbEpisode DownloadEpisode(int _seriesId, DateTime _airDate, TvdbLanguage _language)
        {
            String xml  = "";
            String link = "";

            try
            {
                link = TvdbLinks.CreateEpisodeLink(m_apiKey, _seriesId, _airDate, _language);
                xml  = m_webClient.DownloadString(link);
                if (!xml.Contains("No Results from SP"))
                {
                    List <TvdbEpisode> epList = m_xmlHandler.ExtractEpisodes(xml);
                    if (epList.Count == 1)
                    {
                        return(epList[0]);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    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 TvdbContentNotFoundException("Couldn't download episode  for series " + _seriesId + " from " +
                                                           _airDate.ToShortDateString() + "(" + _language.Abbriviation +
                                                           "), maybe the episode doesn't exist");
                }
                else
                {
                    throw new TvdbNotAvailableException("Couldn't download episode  for series " + _seriesId + " from " +
                                                        _airDate.ToShortDateString() + "(" + _language.Abbriviation +
                                                        "), maybe the episode doesn't exist");
                }
            }
        }
        /// <summary>
        /// Download the episode specified from http://thetvdb.com
        /// </summary>
        /// <param name="_seriesId">series id</param>
        /// <param name="_seasonNr">season nr</param>
        /// <param name="_episodeNr">episode nr</param>
        /// <param name="_language">language</param>
        /// <param name="_order">order</param>
        /// <returns></returns>
        internal TvdbEpisode DownloadEpisode(int _seriesId, int _seasonNr, int _episodeNr, String _order, TvdbLanguage _language)
        {
            String xml  = "";
            String link = "";

            try
            {
                link = TvdbLinks.CreateEpisodeLink(m_apiKey, _seriesId, _seasonNr, _episodeNr, _order, _language);
                xml  = m_webClient.DownloadString(link);
                List <TvdbEpisode> epList = m_xmlHandler.ExtractEpisodes(xml);
                if (epList.Count == 1)
                {
                    return(epList[0]);
                }
                else
                {
                    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 TvdbContentNotFoundException("Couldn't download episode " + _seriesId + "/" +
                                                           _order + "/" + _seasonNr + "/" + _episodeNr + "/" + _language.Abbriviation +
                                                           ", maybe the episode doesn't exist");
                }
                else
                {
                    throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve " + _seriesId + "/" +
                                                        _order + "/" + _seasonNr + "/" + _episodeNr + "/" + _language.Abbriviation +
                                                        ", check your internet connection and the status of http://thetvdb.com");
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Download the given episode from tvdb
        /// </summary>
        /// <param name="_episodeId"></param>
        /// <param name="_language"></param>
        /// <returns></returns>
        internal TvdbEpisode DownloadEpisode(int _episodeId, TvdbLanguage _language)
        {
            String data;

            try
            {
                data = m_webClient.DownloadString(TvdbLinks.CreateEpisodeLink(m_apiKey, _episodeId, _language, false));
            }
            catch (Exception ex)
            {
                Log.Warn("Request not successfull", ex);
                return(null);
            }
            List <TvdbEpisode> epList = m_xmlHandler.ExtractEpisodes(data);

            if (epList.Count == 1)
            {
                return(epList[0]);
            }
            else
            {
                return(null);
            }
        }