Beispiel #1
0
        public void UpdateShow(ShowControl sc)
        {
            Console.WriteLine("Updating RSS for " + sc.Title);
            if (sc.LocalFiles)
            {
                lock (_shows)
                {
                    sc.ScanLocalFilesOnly();
                }
            }
            else
            {
                XmlReader RSSFeed = sc.UpdateRSSFile();
                if (RSSFeed == null)
                {
                    Console.WriteLine("Failed to download rss feed");
                    sc.FailedCount++;
                    return;
                }

                try
                {
                    List <EpisodeControl> episodes = RSSHelper.ReadEpisodes(RSSFeed);
                    lock (_shows)
                    {
                        sc.UpdateEpisode(episodes);
                    }
                }
                catch { }
            }
        }
Beispiel #2
0
        public void RemoveShow(ShowControl itemToRemove)
        {
            lock (_shows)
            {
                _shows.Remove(itemToRemove);

                PersistenceHelper <ShowControl> ph = new PersistenceHelper <ShowControl>(_outputFolder);
                ph.DeleteFile(itemToRemove);
            }
        }
Beispiel #3
0
 public bool Add(ShowControl show)
 {
     lock (_shows)
     {
         show.Modifyed = true;
         if (Contains(show))
         {
             return(false);
         }
         _shows.Add(show);
     }
     return(true);
 }
Beispiel #4
0
        public bool UpdateNextRSSFeeds()
        {
            ShowControl nextShow = _shows.FirstOrDefault(x => x != null &&
                                                         !x.UpdatedRssTurn &&
                                                         (x.ShowOption.CheckforUpdates || x.ShowOption.ShowStorage == ShowStorageType.LocalStorage));

            if (nextShow != null)
            {
                lock (_shows)
                {
                    nextShow.UpdatedRssTurn = true;
                }

                UpdateShow(nextShow);
                return(false);
            }

            var nextShowDownload = _shows.FirstOrDefault(x => x != null && !x.AutoDownloadTurn && x.ShowOption.AudoDownloadEpisodes);

            if (nextShowDownload != null)
            {
                lock (_shows)
                {
                    nextShowDownload.AutoDownloadTurn = true;
                    Console.WriteLine($"Download all shows for {nextShowDownload.Title}");
                    ServiceLocator.Instance.GetService <LoggerService>().AddError($"Auto download {nextShowDownload.Title}");

                    nextShowDownload.Download();
                    return(false);
                }
            }

            Console.WriteLine("re set all shows to check for download");
            lock (_shows)
            {
                foreach (ShowControl show in _shows)
                {
                    if (show == null)
                    {
                        continue;
                    }

                    if (show.FailedCount < 2)
                    {
                        show.UpdatedRssTurn   = false;
                        show.AutoDownloadTurn = false;
                    }
                }
                return(true);
            }
        }
Beispiel #5
0
        public bool Contains(ShowControl show)
        {
            if (_shows.Any((x) => x != null && x.RssFeed == show.RssFeed))
            {
                return(true);
            }

            if (_shows.Any((x) => x != null && x.Title == show.Title))
            {
                return(true);
            }

            return(false);
        }