private List <ImportResult> ProcessFolder(DownloadedEpisodesScanCommand message)
        {
            if (!_diskProvider.FolderExists(message.Path))
            {
                _logger.Warn("Folder specified for import scan [{0}] doesn't exist.", message.Path);
                return(new List <ImportResult>());
            }

            if (message.DownloadClientId.IsNotNullOrWhiteSpace())
            {
                var trackedDownload = _downloadTrackingService.GetQueuedDownloads().Where(v => v.DownloadItem.DownloadClientId == message.DownloadClientId).FirstOrDefault();

                if (trackedDownload == null)
                {
                    _logger.Warn("External directory scan request for unknown download {0}, attempting normal import. [{1}]", message.DownloadClientId, message.Path);

                    return(_downloadedEpisodesImportService.ProcessFolder(new DirectoryInfo(message.Path)));
                }
                else
                {
                    return(_completedDownloadService.Import(trackedDownload, message.Path));
                }
            }
            else
            {
                return(_downloadedEpisodesImportService.ProcessFolder(new DirectoryInfo(message.Path)));
            }
        }
예제 #2
0
        public List <Queue> GetQueue()
        {
            var queueItems = _downloadTrackingService.GetQueuedDownloads()
                             .OrderBy(v => v.DownloadItem.RemainingTime)
                             .ToList();

            return(MapQueue(queueItems));
        }
예제 #3
0
        public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            var queue = _downloadTrackingService.GetQueuedDownloads()
                        .Where(v => v.State == TrackedDownloadState.Downloading)
                        .Select(q => q.RemoteEpisode).ToList();

            if (IsInQueue(subject, queue))
            {
                _logger.Debug("Already in queue, rejecting.");
                return(Decision.Reject("Already in download queue"));
            }

            return(Decision.Accept());
        }
예제 #4
0
        public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            var queue = _downloadTrackingService.GetQueuedDownloads()
                        .Where(v => v.State == TrackedDownloadState.Downloading)
                        .Select(q => q.DownloadItem.RemoteEpisode).ToList();

            if (IsInQueue(subject, queue))
            {
                _logger.Debug("Already in queue, rejecting.");
                return(false);
            }

            return(true);
        }