Пример #1
0
        public virtual Tuple <int, int> GetEpisodeFilesCount(int seriesId)
        {
            var allEpisodes = _episodeProvider.GetEpisodeBySeries(seriesId).ToList();

            var episodeTotal     = allEpisodes.Where(e => !e.Ignored && e.AirDate != null && e.AirDate <= DateTime.Today).ToList();
            var avilableEpisodes = episodeTotal.Where(e => e.EpisodeFileId > 0).ToList();

            return(new Tuple <int, int>(avilableEpisodes.Count, episodeTotal.Count));
        }
Пример #2
0
        public virtual void PerformUpdate(Series series)
        {
            _logger.Trace("Updating scene numbering mapping for: {0}", series.Title);
            try
            {
                var episodesToUpdate = new List <Episode>();
                var mappings         = _xemCommunicationProvider.GetSceneTvdbMappings(series.SeriesId);

                if (mappings == null)
                {
                    _logger.Trace("Mappings for: {0} are null, skipping", series.Title);
                    return;
                }

                var episodes = _episodeProvider.GetEpisodeBySeries(series.SeriesId);

                foreach (var mapping in mappings)
                {
                    _logger.Trace("Setting scene numbering mappings for {0} S{1:00}E{2:00}", series.Title, mapping.Tvdb.Season, mapping.Tvdb.Episode);

                    var episode = episodes.SingleOrDefault(e => e.SeasonNumber == mapping.Tvdb.Season && e.EpisodeNumber == mapping.Tvdb.Episode);

                    if (episode == null)
                    {
                        _logger.Trace("Information hasn't been added to TheTVDB yet, skipping.");
                        continue;
                    }

                    episode.AbsoluteEpisodeNumber = mapping.Scene.Absolute;
                    episode.SceneSeasonNumber     = mapping.Scene.Season;
                    episode.SceneEpisodeNumber    = mapping.Scene.Episode;
                    episodesToUpdate.Add(episode);
                }

                _logger.Trace("Committing scene numbering mappings to database for: {0}", series.Title);
                _episodeProvider.UpdateEpisodes(episodesToUpdate);

                _logger.Trace("Setting UseSceneMapping for {0}", series.Title);
                series.UseSceneNumbering = true;
                _seriesProvider.UpdateSeries(series);
            }

            catch (Exception ex)
            {
                _logger.WarnException("Error updating scene numbering mappings for: " + series, ex);
            }
        }
Пример #3
0
        /// <summary>
        ///   Scans the specified series folder for media files
        /// </summary>
        /// <param name = "series">The series to be scanned</param>
        /// <param name="path">Path to scan</param>
        public virtual List <EpisodeFile> Scan(Series series, string path)
        {
            _mediaFileProvider.CleanUpDatabase();

            if (!_diskProvider.FolderExists(path))
            {
                Logger.Warn("Series folder doesn't exist: {0}", path);
                return(new List <EpisodeFile>());
            }

            if (_episodeProvider.GetEpisodeBySeries(series.SeriesId).Count == 0)
            {
                Logger.Debug("Series {0} has no episodes. skipping", series.Title);
                return(new List <EpisodeFile>());
            }

            var seriesFile = _mediaFileProvider.GetSeriesFiles(series.SeriesId);

            CleanUp(seriesFile);

            var mediaFileList = GetVideoFiles(path);
            var importedFiles = new List <EpisodeFile>();

            foreach (var filePath in mediaFileList)
            {
                var file = ImportFile(series, filePath);
                if (file != null)
                {
                    importedFiles.Add(file);
                }
            }

            //Todo: Find the "best" episode file for all found episodes and import that one
            //Todo: Move the episode linking to here, instead of import (or rename import)

            series.LastDiskSync = DateTime.Now;
            _seriesProvider.UpdateSeries(series);

            return(importedFiles);
        }