예제 #1
0
        internal List <TvdbMirror> DownloadMirrorList()
        {
            String xml  = "";
            String link = "";

            try
            {
                link = TvdbLinks.CreateMirrorsLink(m_apiKey);
                xml  = m_webClient.DownloadString(link);
                List <TvdbMirror> list = m_xmlHandler.ExtractMirrors(xml);
                return(list);
            }
            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("Couldn't download mirror list from thetvdb.com", 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 mirror list" +
                                                         ", it seems like you use an invalid api key");
                }
                else
                {
                    throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve mirror list" +
                                                        ", check your internet connection and the status of http://thetvdb.com");
                }
            }
        }