コード例 #1
0
ファイル: ShowRss.cs プロジェクト: TvSourcerer/TvSourcerer
        /// <summary>
        /// 
        /// </summary>
        /// <param name="series"></param>
        /// <param name="episode"></param>
        /// <param name="quality"></param>
        /// <returns></returns>
        public override SearchResult FindTorrent(Series series,
                                                 Episode episode,
                                                 Global.EpisodeQuality quality)
        {
            var rssFeed = from r in _rssShows where r.Item2.ToLower() == series.Name.ToLower() select r;
            if (rssFeed.Any() == false)
            {
                // Log
                return null;
            }

            List<RssResult> rssResults = GetShowRssResults(rssFeed.First().Item1, series.Id);

            var result = from r in rssResults
                         where
                             r.SeasonNumber == episode.SeasonNumber & r.EpisodeNumber == episode.EpisodeNumber &
                             r.Quality == quality
                         select r;

            // Need a fall back option on the quality
            if (result.Any() == false)
            {
                return null;
            }

            SearchResult searchResult = new SearchResult();
            searchResult.Url = result.First().Url;
            searchResult.Quality = result.First().Quality;

            return searchResult;
        }
コード例 #2
0
ファイル: Provider.cs プロジェクト: TvSourcerer/TvSourcerer
 /// <summary>
 /// 
 /// </summary>
 /// <param name="series"></param>
 /// <param name="episode"></param>
 /// <param name="quality"></param>
 /// <returns></returns>
 public abstract SearchResult FindTorrent(Series series, Episode episode, Global.EpisodeQuality quality);
コード例 #3
0
ファイル: FormMain.cs プロジェクト: TvSourcerer/TvSourcerer
        /// <summary>
        /// 
        /// </summary>
        /// <param name="series"></param>
        /// <param name="episode"></param>
        private void UpdateEpisodeList(Series series, Episode episode)
        {
            MethodInvoker methodInvoker = delegate
            {
                if (listSeries.SelectedObject == null)
                {
                    return;
                }

                // If we are currently displaying the series that has just updated, then update the episode list
                Series tempSeries = (Series)listSeries.SelectedObject;
                if (tempSeries.Guid != series.Guid)
                {
                    return;
                }

                List<Episode> tempEpisodes = listEpisodes.Objects.Cast<Episode>().ToList();
                var tempEpisode = (from e in tempEpisodes where e.Id == episode.Id select e).SingleOrDefault();
                if (tempEpisode == null)
                {
                    return;
                }

                tempEpisode.Path = episode.Path;
                tempEpisode.FileName = episode.FileName;
                tempEpisode.Folder = episode.Folder;
                tempEpisode.Quality = episode.Quality;
                tempEpisode.Status = episode.Status;

                listEpisodes.RefreshObject(tempEpisode);
            };

            if (listEpisodes.InvokeRequired == true)
            {
                this.BeginInvoke(methodInvoker);
            }
            else
            {
                methodInvoker.Invoke();
            }
        }
コード例 #4
0
ファイル: Manager.cs プロジェクト: TvSourcerer/TvSourcerer
        /// <summary>
        /// 
        /// </summary>
        private void StartShows()
        {
            // Series ID?, Path?
            foreach (Tuple<int, string> item in _shows.GetConsumingEnumerable())
            {
                // Need to go and download the series info and store locally? Need to wait until it has been downloaded before searching for episodes
                var temp = (from s in _configuration.Shows where s.Id == item.Item1 select s).SingleOrDefault();
                if (temp != null)
                {
                    // This in theory should never happen.
                    _logger.Info("Cannot add new show as it already exists: SeriesID:" + item.Item1 + "#Path:" + item.Item2);
                    OnError("Series already exists");
                    continue;
                }

                Series series = new Series();
                series.Id = item.Item1;
                series.Path = item.Item2;

                _retriever.DownloadSeries(item.Item1,
                                          Helper.GetSeriesCacheFolderPath(item.Item1));

                // Update the cache path
                series.CachePath = Helper.GetSeriesCacheFilePath(item.Item1);

                // Now we have the baseline data from TVDB, we populate our
                // local data store with all known seasons and episodes

                TvDbSeries seriesCache = Cache.Series(item.Item1, Helper.GetSeriesCacheFilePath(series.Id));
                series.Name = seriesCache.Name;
                series.Overview = seriesCache.Description;
                series.FirstAired = seriesCache.FirstAired;
                series.ImdbId = seriesCache.ImdbId;

                foreach (TvDbEpisode episodeCache in Cache.Episodes(item.Item1, Helper.GetSeriesCacheFilePath(series.Id)))
                {
                    Episode episode = new Episode();
                    episode.SeriesId = series.Id;
                    episode.EpisodeNumber = episodeCache.EpisodeNumber;
                    episode.SeasonNumber = episodeCache.SeasonNumber;
                    episode.Name = episodeCache.EpisodeName;
                    episode.Overview = episodeCache.Overview;
                    episode.Id = episodeCache.Id;
                    series.Episodes.Add(episode);
                }

                OnSeriesFound(series);
                EnumerateFiles(item.Item1, item.Item2);
            }
        }
コード例 #5
0
ファイル: Manager.cs プロジェクト: TvSourcerer/TvSourcerer
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTimerTvData_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                _timerTvData.Enabled = false;

                if (_configuration.Shows.Count == 0)
                {
                    return;
                }

                foreach (Series series in _configuration.Shows)
                {
                    // Redownload the series info. Ideally we would be able to determine new episodes but the API doesn't allow that
                     _retriever.DownloadSeries(series.Id,
                                               Helper.GetSeriesCacheFolderPath(series.Id));

                    TvDbSeries seriesCache = Cache.Series(series.Id, Helper.GetSeriesCacheFilePath(series.Id));
                    series.Name = seriesCache.Name;
                    series.Overview = seriesCache.Description;
                    series.FirstAired = seriesCache.FirstAired;
                    series.ImdbId = seriesCache.ImdbId;

                    foreach (TvDbEpisode episodeCache in Cache.Episodes(series.Id, Helper.GetSeriesCacheFilePath(series.Id)))
                    {
                        var episode = (from epi in series.Episodes where epi.Id == episodeCache.Id select epi).SingleOrDefault();
                        if (episode != null)
                        {
                            // Update the episode data
                            episode.SeriesId = series.Id;
                            episode.EpisodeNumber = episodeCache.EpisodeNumber;
                            episode.SeasonNumber = episodeCache.SeasonNumber;
                            episode.Name = episodeCache.EpisodeName;
                            episode.Overview = episodeCache.Overview;
                            episode.Id = episodeCache.Id;
                        }
                        else
                        {
                            // This is a new episode so add it
                            episode = new Episode();
                            episode.SeriesId = series.Id;
                            episode.EpisodeNumber = episodeCache.EpisodeNumber;
                            episode.SeasonNumber = episodeCache.SeasonNumber;
                            episode.Name = episodeCache.EpisodeName;
                            episode.Overview = episodeCache.Overview;
                            episode.Id = episodeCache.Id;

                            series.Episodes.Add(episode);

                            bool found = false;
                            // Now look for files associated with the episode
                            FileNameParser fileNameParser = new FileNameParser();
                            foreach (string file in Misc.GetFiles(series.Path,
                                                                  Global.FILE_EXTENSIONS,
                                                                  SearchOption.AllDirectories))
                            {
                                fileNameParser.Parse(System.IO.Path.GetFileName(file));
                                if (fileNameParser.Matched() == false)
                                {
                                    continue;
                                }

                                if (episode.SeasonNumber == fileNameParser.EpisodeNumber &
                                    episode.EpisodeNumber == fileNameParser.SeasonNumber)
                                {
                                    OnEpisodeFound(series.Id,
                                                    fileNameParser.SeasonNumber,
                                                    fileNameParser.EpisodeNumber,
                                                    System.IO.Path.Combine(series.Path, file),
                                                    fileNameParser.Quality);
                                }
                            }

                            if (found == false)
                            {
                                episode.Status = _settings.NewStatus;
                                if (episode.Status == Global.EpisodeStatus.Wanted)
                                {
                                    AddTorrent(series, episode);
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                _timerTvData.Enabled = true;
            }
        }
コード例 #6
0
ファイル: Manager.cs プロジェクト: TvSourcerer/TvSourcerer
 /// <summary>
 /// 
 /// </summary>
 /// <param name="series"></param>
 /// <param name="episode"></param>
 public void AddTorrent(Series series, Episode episode)
 {
     _torrents.Add(new Tuple<Series, Episode>(series, episode));
 }