public virtual IList <TvRageSearchResult> SearchSeries(string title)
        {
            var searchResults = new List <TvRageSearchResult>();

            var xmlStream = _httpProvider.DownloadStream("http://services.tvrage.com/feeds/full_search.php?show=" + title, null);

            var xml   = XDocument.Load(xmlStream);
            var shows = xml.Descendants("Results").Descendants("show");

            foreach (var s in shows)
            {
                try
                {
                    var show = new TvRageSearchResult();
                    show.ShowId  = s.Element("showid").ConvertTo <Int32>();
                    show.Name    = s.Element("name").Value;
                    show.Link    = s.Element("link").Value;
                    show.Country = s.Element("country").Value;

                    show.Started = s.Element("started").ConvertTo <DateTime>();
                    show.Ended   = s.Element("ended").ConvertTo <DateTime>();

                    if (show.Ended < new DateTime(1900, 1, 1))
                    {
                        show.Ended = null;
                    }

                    show.Seasons = s.Element("seasons").ConvertTo <Int32>();
                    show.Status  = s.Element("status").Value;
                    show.RunTime = s.Element("seasons").ConvertTo <Int32>();
                    show.AirTime = s.Element("seasons").ConvertTo <DateTime>();
                    show.AirDay  = s.Element("airday").ConvertToDayOfWeek();

                    searchResults.Add(show);
                }

                catch (Exception ex)
                {
                    logger.DebugException("Failed to parse TvRage Search Result. Search Term : " + title, ex);
                }
            }

            return(searchResults);
        }
        public List <int> GetSectionKeys(string host)
        {
            logger.Trace("Getting sections from Plex host: {0}", host);
            var url            = String.Format("http://{0}/library/sections", host);
            var xmlStream      = _httpProvider.DownloadStream(url, null);
            var xDoc           = XDocument.Load(xmlStream);
            var mediaContainer = xDoc.Descendants("MediaContainer").FirstOrDefault();
            var directories    = mediaContainer.Descendants("Directory").Where(x => x.Attribute("type").Value == "show");

            return(directories.Select(d => Int32.Parse(d.Attribute("key").Value)).ToList());
        }
Beispiel #3
0
        protected virtual List <EpisodeParseResult> Fetch(IEnumerable <string> urls)
        {
            var result = new List <EpisodeParseResult>();

            if (!IsConfigured)
            {
                _logger.Warn("Indexer '{0}' isn't configured correctly. please reconfigure the indexer in settings page.", Name);
                return(result);
            }

            foreach (var url in urls)
            {
                try
                {
                    _logger.Trace("Downloading RSS " + url);

                    var reader = new SyndicationFeedXmlReader(_httpProvider.DownloadStream(url, Credentials));
                    var feed   = SyndicationFeed.Load(reader).Items;

                    foreach (var item in feed)
                    {
                        try
                        {
                            var parsedEpisode = ParseFeed(item);
                            if (parsedEpisode != null)
                            {
                                parsedEpisode.NzbUrl     = NzbDownloadUrl(item);
                                parsedEpisode.NzbInfoUrl = NzbInfoUrl(item);
                                parsedEpisode.Indexer    = String.IsNullOrWhiteSpace(parsedEpisode.Indexer) ? Name : parsedEpisode.Indexer;
                                result.Add(parsedEpisode);
                            }
                        }
                        catch (Exception itemEx)
                        {
                            itemEx.Data.Add("FeedUrl", url);
                            itemEx.Data.Add("Item", item.Title);
                            _logger.ErrorException("An error occurred while processing feed item", itemEx);
                        }
                    }
                }
                catch (WebException webException)
                {
                    if (webException.Message.Contains("503"))
                    {
                        _logger.Warn("{0} server is currently unavailable.{1} {2}", Name, url, webException.Message);
                    }
                    else
                    {
                        webException.Data.Add("FeedUrl", url);
                        _logger.ErrorException("An error occurred while processing feed. " + url, webException);
                    }
                }
                catch (Exception feedEx)
                {
                    feedEx.Data.Add("FeedUrl", url);
                    _logger.ErrorException("An error occurred while processing feed. " + url, feedEx);
                }
            }

            return(result);
        }