コード例 #1
0
        public virtual List <int> SeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber)
        {
            var series = _seriesProvider.GetSeries(seriesId);

            if (series == null)
            {
                logger.Error("Unable to find an series {0} in database", seriesId);
                return(new List <int>());
            }

            if (series.IsDaily)
            {
                logger.Trace("Daily series detected, skipping season search: {0}", series.Title);
                return(new List <int>());
            }

            logger.Debug("Getting episodes from database for series: {0} and season: {1}", seriesId, seasonNumber);
            var episodes = _episodeProvider.GetEpisodesBySeason(seriesId, seasonNumber);

            if (episodes == null || episodes.Count == 0)
            {
                logger.Warn("No episodes in database found for series: {0} and season: {1}.", seriesId, seasonNumber);
                return(new List <int>());
            }

            //Todo: Support full season searching
            return(new List <int>());
        }
コード例 #2
0
        public virtual void ForceDownload(int itemId)
        {
            var item = _database.Single <SearchHistoryItem>(itemId);

            logger.Info("Starting Force Download of: {0}", item.ReportTitle);
            var searchResult = _database.Single <SearchHistory>(item.SearchHistoryId);
            var series       = _seriesProvider.GetSeries(searchResult.SeriesId);

            var parseResult = Parser.ParseTitle(item.ReportTitle);

            parseResult.NzbUrl      = item.NzbUrl;
            parseResult.Series      = series;
            parseResult.Indexer     = item.Indexer;
            parseResult.Episodes    = _episodeProvider.GetEpisodesByParseResult(parseResult);
            parseResult.SceneSource = true;

            logger.Info("Forcing Download of: {0}", item.ReportTitle);
            _downloadProvider.DownloadReport(parseResult);
        }
コード例 #3
0
        public virtual void UpdateMappings(int seriesId)
        {
            var xemIds = _xemCommunicationProvider.GetXemSeriesIds();

            if (!xemIds.Contains(seriesId))
            {
                _logger.Trace("Xem doesn't have a mapping for this series: {0}", seriesId);
                return;
            }

            var series = _seriesProvider.GetSeries(seriesId);

            if (series == null)
            {
                _logger.Trace("Series could not be found: {0}", seriesId);
                return;
            }

            PerformUpdate(series);
        }
コード例 #4
0
        public virtual EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDownload = false)
        {
            if (episodeFile == null)
            {
                throw new ArgumentNullException("episodeFile");
            }

            var    series      = _seriesProvider.GetSeries(episodeFile.SeriesId);
            var    episodes    = _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId);
            string newFileName = _mediaFileProvider.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile);
            var    newFile     = _mediaFileProvider.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));

            //Only rename if existing and new filenames don't match
            if (DiskProvider.PathEquals(episodeFile.Path, newFile.FullName))
            {
                Logger.Debug("Skipping file rename, source and destination are the same: {0}", episodeFile.Path);
                return(null);
            }

            if (!_diskProvider.FileExists(episodeFile.Path))
            {
                Logger.Error("Episode file path does not exist, {0}", episodeFile.Path);
                return(null);
            }

            _diskProvider.CreateDirectory(newFile.DirectoryName);

            Logger.Debug("Moving [{0}] > [{1}]", episodeFile.Path, newFile.FullName);
            _diskProvider.MoveFile(episodeFile.Path, newFile.FullName);

            //Wrapped in Try/Catch to prevent this from causing issues with remote NAS boxes, the move worked, which is more important.
            try
            {
                _diskProvider.InheritFolderPermissions(newFile.FullName);
            }
            catch (UnauthorizedAccessException ex)
            {
                Logger.Debug("Unable to apply folder permissions to: ", newFile.FullName);
                Logger.TraceException(ex.Message, ex);
            }

            episodeFile.Path = newFile.FullName;
            _mediaFileProvider.Update(episodeFile);

            var parseResult = Parser.ParsePath(episodeFile.Path);

            parseResult.Series  = series;
            parseResult.Quality = new QualityModel {
                Quality = episodeFile.Quality, Proper = episodeFile.Proper
            };
            parseResult.Episodes = episodes;

            var message = _downloadProvider.GetDownloadTitle(parseResult);

            if (newDownload)
            {
                _externalNotificationProvider.OnDownload(message, series);

                foreach (var episode in episodes)
                {
                    _signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Ready, parseResult.Quality);
                }
            }
            else
            {
                _externalNotificationProvider.OnRename(message, series);
            }

            return(episodeFile);
        }