Ejemplo n.º 1
0
        /// <summary>
        /// Download the preferred language of the user
        /// </summary>
        /// <param name="_userId"></param>
        /// <returns></returns>
        internal TvdbLanguage DownloadUserPreferredLanguage(String _userId)
        {
            String xml;

            try
            {
                xml = m_webClient.DownloadString(TvdbLinks.CreateUserLanguageLink(_userId));
            }
            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 preferred languae for user " + _userId +
                                                         ", it seems like you use an invalid api key (" + m_apiKey + ")");
                }
                else
                {
                    throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve preferred languae for user " + _userId +
                                                        ", check your internet connection and the status of http://thetvdb.com");
                }
            }
            List <TvdbLanguage> langList = m_xmlHandler.ExtractLanguages(xml);

            if (langList != null && langList.Count == 1)
            {
                return(langList[0]);
            }
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Download the preferred language of the user
        /// </summary>
        /// <param name="_userId"></param>
        /// <returns></returns>
        internal TvdbLanguage DownloadUserPreferredLanguage(String _userId)
        {
            String xml = m_webClient.DownloadString(TvdbLinks.CreateUserLanguageLink(_userId));
            List <TvdbLanguage> langList = m_xmlHandler.ExtractLanguages(xml);

            if (langList != null && langList.Count == 1)
            {
                return(langList[0]);
            }
            return(null);
        }