示例#1
0
        /// <summary>
        /// Download the series rating without doing a rating
        /// </summary>
        /// <param name="_userId"></param>
        /// <param name="_seriesId"></param>
        /// <returns></returns>
        internal double DownloadSeriesRating(String _userId, int _seriesId)
        {
            String xml  = "";
            String link = "";

            try
            {
                link = TvdbLinks.CreateUserSeriesRating(_userId, _seriesId);
                xml  = m_webClient.DownloadString(link);
                return(m_xmlHandler.ExtractRating(xml));
            }
            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 rating of series " + _seriesId +
                                                         ", it seems like you use an invalid api key");
                }
                else
                {
                    throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve rating of series " + _seriesId +
                                                        ", check your internet connection and the status of http://thetvdb.com");
                }
            }
        }
示例#2
0
        /// <summary>
        /// Make the request for rating a series
        /// </summary>
        /// <param name="_userId"></param>
        /// <param name="_seriesId"></param>
        /// <param name="_rating"></param>
        /// <returns></returns>
        internal double RateSeries(String _userId, int _seriesId, int _rating)
        {
            String xml;

            try
            {
                xml = m_webClient.DownloadString(TvdbLinks.CreateUserSeriesRating(_userId, _seriesId, _rating));
            }
            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 rate series " + _seriesId +
                                                         ", it seems like you use an invalid api key (" + m_apiKey + ")");
                }
                else
                {
                    throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to rate series " + _seriesId +
                                                        ", check your internet connection and the status of http://thetvdb.com");
                }
            }
            return(m_xmlHandler.ExtractRating(xml));
        }
示例#3
0
        /// <summary>
        /// Download the series rating without doing a rating
        /// </summary>
        /// <param name="_userId"></param>
        /// <param name="_seriesId"></param>
        /// <returns></returns>
        internal double DownloadSeriesRating(String _userId, int _seriesId)
        {
            String xml = m_webClient.DownloadString(TvdbLinks.CreateUserSeriesRating(_userId, _seriesId));

            return(m_xmlHandler.ExtractRating(xml));
        }