/// <summary> /// /// </summary> /// <param name="configuration"></param> /// <param name="seriesName"></param> /// <returns></returns> public static Series GetSeries(Configuration configuration, string seriesName) { var series = (from s in configuration.Shows where s.Name.ToLower() == seriesName.ToLower() select s).SingleOrDefault(); if (series == null) { return null; } return series; }
/// <summary> /// /// </summary> /// <param name="configuration"></param> /// <param name="seriesId"></param> /// <returns></returns> public static Series GetSeries(Configuration configuration, int seriesId) { var series = (from s in configuration.Shows where s.Id == seriesId select s).SingleOrDefault(); if (series == null) { return null; } return series; }
//private List<string> _filters; /// <summary> /// /// </summary> /// <param name="apiKey"></param> /// <param name="settings"></param> /// <param name="configuration"></param> /// <param name="providers"></param> /// <param name="outputDir"></param> public Manager(string apiKey, Settings settings, Configuration configuration, List<Provider> providers) { _settings = settings; _configuration = configuration; _providers = providers; _retriever = new Retriever(apiKey); _shows = new BlockingCollection<Tuple<int, string>>(); // SeriesID, Path _downloads = new BlockingCollection<Tuple<int, int, int, string>>(); _torrents = new BlockingCollection<Tuple<Series, Episode>>(); Thread thread = new Thread(new ThreadStart(StartDownloads)); thread.IsBackground = true; thread.Start(); thread = new Thread(new ThreadStart(StartShows)); thread.IsBackground = true; thread.Start(); thread = new Thread(new ThreadStart(StartTorrentFinder)); thread.IsBackground = true; thread.Start(); _timerTvData = new System.Timers.Timer(); _timerTvData.Interval = 6000; // 1 min //_timer.Interval = INTERVAL_DAILY; // 24 Hours _timerTvData.Elapsed += OnTimerTvData_Elapsed; _timerTvData.Enabled = true; _timerTorrents = new System.Timers.Timer(); //_timer.Interval = INTERVAL_DAILY; // 24 Hours _timerTorrents.Interval = INTERVAL_DAILY; //6000; // 1 min _timerTorrents.Elapsed += OnTimerTorrents_Elapsed; _timerTorrents.Enabled = true; }
/// <summary> /// /// </summary> /// <param name="configuration"></param> /// <param name="seriesId"></param> /// <param name="seasonNumber"></param> /// <param name="episodeNumber"></param> /// <returns></returns> public static Episode GetEpisode(Configuration configuration, int seriesId, int seasonNumber, int episodeNumber) { var series = GetSeries(configuration, seriesId); if (series == null) { return null; } var episode = (from e in series.Episodes where e.SeasonNumber == seasonNumber & e.EpisodeNumber == episodeNumber select e).SingleOrDefault(); if (episode == null) { return null; } return episode; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FormMain_Load(object sender, EventArgs e) { using (new HourGlass(this)) { this.Show(); _settings = new Settings(); string ret = _settings.Load(); if (ret.Length > 0) { Misc.DisplayErrorMessageBox("An error occurred whilst loading the settings: " + ret); return; } if (_settings.TorrentFileDirectory.Length == 0) { Misc.DisplayMessageBox("The torrent file directory has not been set. It must be set before the application can continue", MessageBoxIcon.Exclamation); } if (_settings.TorrentDirectory.Length == 0) { Misc.DisplayMessageBox("The torrent directory has not been set. It must be set before the application can continue", MessageBoxIcon.Exclamation); return; } _providers = new List<Provider>(); //_providers.Add(new DailyTvTorrent(1)); _providers.Add(new ShowRss(1)); _retriever = new Retriever(API_KEY); _configuration = new Configuration(); _manager = new Manager(API_KEY, _settings, _configuration, _providers); _manager.EpisodeFound += OnManager_EpisodeFound; _manager.SeriesFound += OnManager_SeriesFound; _manager.TorrentFound += OnManager_TorrentFound; _manager.Error += OnManager_Error; _manager.DownloadUpdate += OnManager_DownloadUpdate; _manager.Message += OnManager_Message; _fileSystemWatcher = new FileSystemWatcher(_settings.TorrentDirectory); _fileSystemWatcher.Created += OnFileSystemWatcher_Created; _fileSystemWatcher.EnableRaisingEvents = true; ret = _configuration.Load(); if (ret.Length > 0) { Misc.DisplayErrorMessageBox(this, "An error occurred whilst loading the configuration"); return; } // Ensure we have a base line server timestamp, used for updating with TVDB if (_configuration.LastUpdated == DateTime.MinValue) { _configuration.LastUpdated = _retriever.ServerTime(); } //listEpisodes.ShowGroups = true; LoadSeries(); } }