示例#1
0
        public virtual void Start(ProgressNotification notification, dynamic options)
        {
            Logger.Debug("Starting banner download job");

            if (options != null)
            {
                Series series = _seriesProvider.GetSeries(options.SeriesId);

                if (series != null && !String.IsNullOrEmpty(series.BannerUrl))
                {
                    DownloadBanner(notification, series);
                }

                return;
            }

            var seriesInDb = _seriesProvider.GetAllSeries();

            foreach (var series in seriesInDb.Where(s => !String.IsNullOrEmpty(s.BannerUrl)))
            {
                DownloadBanner(notification, series);
            }

            Logger.Debug("Finished banner download job");
        }
示例#2
0
        public override async Task <GetAllResponse> GetAll(GetAllRequest request, ServerCallContext context)
        {
            var series = await _seriesProvider.GetSeries();

            return(new GetAllResponse
            {
                Series = { series }
            });
        }
示例#3
0
        public ActionResult Edit(int seriesId)
        {
            var profiles = _qualityProvider.All();

            ViewData["SelectList"] = new SelectList(profiles, "QualityProfileId", "Name");

            var backlogStatusTypes = new List <KeyValuePair <int, string> >();

            foreach (BacklogSettingType backlogStatusType in Enum.GetValues(typeof(BacklogSettingType)))
            {
                backlogStatusTypes.Add(new KeyValuePair <int, string>((int)backlogStatusType, backlogStatusType.ToString()));
            }

            ViewData["BacklogSettingSelectList"] = new SelectList(backlogStatusTypes, "Key", "Value");

            var series = GetSeriesModels(new List <Series> {
                _seriesProvider.GetSeries(seriesId)
            }).Single();

            return(View(series));
        }
示例#4
0
        public virtual void Start(ProgressNotification notification, dynamic options)
        {
            IList <Series> seriesToUpdate;

            if (options == null || options.SeriesId == 0)
            {
                if (_configProvider.IgnoreArticlesWhenSortingSeries)
                {
                    seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => o.Title.IgnoreArticles()).ToList();
                }

                else
                {
                    seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => o.Title).ToList();
                }
            }
            else
            {
                seriesToUpdate = new List <Series> {
                    _seriesProvider.GetSeries(options.SeriesId)
                };
            }

            //Update any Daily Series in the DB with the IsDaily flag
            _referenceDataProvider.UpdateDailySeries();

            foreach (var series in seriesToUpdate)
            {
                try
                {
                    notification.CurrentMessage = "Updating " + series.Title;
                    _seriesProvider.UpdateSeriesInfo(series.SeriesId);
                    _episodeProvider.RefreshEpisodeInfo(series);
                    notification.CurrentMessage = "Update completed for " + series.Title;
                }

                catch (Exception ex)
                {
                    Logger.ErrorException("Failed to update episode info for series: " + series.Title, ex);
                }
            }
        }
        public void Start(ProgressNotification notification, dynamic options)
        {
            List <Series> seriesToRefresh;

            if (options == null || options.SeriesId <= 0)
            {
                seriesToRefresh = _seriesProvider.GetAllSeries().ToList();
            }

            else
            {
                seriesToRefresh = new List <Series> {
                    _seriesProvider.GetSeries(options.SeriesId)
                }
            };

            foreach (var series in seriesToRefresh)
            {
                RefreshMetadata(notification, series);
            }
        }
示例#6
0
        private void ScanSeries(ProgressNotification notification)
        {
            var syncList = _seriesProvider.GetAllSeries().Where(s => s.LastInfoSync == null && !_attemptedSeries.Contains(s.SeriesId)).ToList();

            if (syncList.Count == 0)
            {
                return;
            }

            foreach (var currentSeries in syncList)
            {
                try
                {
                    _attemptedSeries.Add(currentSeries.SeriesId);
                    notification.CurrentMessage = String.Format("Searching for '{0}'", new DirectoryInfo(currentSeries.Path).Name);

                    _updateInfoJob.Start(notification, new { SeriesId = currentSeries.SeriesId });
                    _diskScanJob.Start(notification, new { SeriesId = currentSeries.SeriesId });

                    var updatedSeries = _seriesProvider.GetSeries(currentSeries.SeriesId);
                    AutoIgnoreSeasons(updatedSeries.SeriesId);

                    //Download the banner for the new series
                    _bannerDownloadJob.Start(notification, new { SeriesId = updatedSeries.SeriesId });

                    //Get Scene Numbering if applicable
                    _xemUpdateJob.Start(notification, new { SeriesId = updatedSeries.SeriesId });

                    notification.CurrentMessage = String.Format("{0} was successfully imported", updatedSeries.Title);
                }

                catch (Exception e)
                {
                    Logger.ErrorException(e.Message, e);
                }
            }

            //Keep scanning until there no more shows left.
            ScanSeries(notification);
        }
示例#7
0
        private void DeleteSeries(ProgressNotification notification, int seriesId, bool deleteFiles)
        {
            Logger.Trace("Deleting Series [{0}]", seriesId);

            var series = _seriesProvider.GetSeries(seriesId);
            var title  = series.Title;

            notification.CurrentMessage = String.Format("Deleting '{0}' from database", title);

            _seriesProvider.DeleteSeries(seriesId);

            notification.CurrentMessage = String.Format("Successfully deleted '{0}' from database", title);

            if (deleteFiles)
            {
                notification.CurrentMessage = String.Format("Deleting files from disk for series '{0}'", title);

                _recycleBinProvider.DeleteDirectory(series.Path);

                notification.CurrentMessage = String.Format("Successfully deleted files from disk for series '{0}'", title);
            }
        }
示例#8
0
        public virtual void Start(ProgressNotification notification, dynamic options)
        {
            IList <Series> seriesToScan;

            if (options == null || options.SeriesId == 0)
            {
                if (_configProvider.IgnoreArticlesWhenSortingSeries)
                {
                    seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => o.Title.IgnoreArticles()).ToList();
                }

                else
                {
                    seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => o.Title).ToList();
                }
            }
            else
            {
                seriesToScan = new List <Series>()
                {
                    _seriesProvider.GetSeries(options.SeriesId)
                };
            }

            foreach (var series in seriesToScan)
            {
                try
                {
                    notification.CurrentMessage = string.Format("Scanning disk for '{0}'", series.Title);
                    _diskScanProvider.Scan(series);
                    notification.CurrentMessage = string.Format("Disk Scan completed for '{0}'", series.Title);
                }
                catch (Exception e)
                {
                    Logger.ErrorException("An error has occurred while scanning " + series.Title, e);
                }
            }
        }
        public void Start(ProgressNotification notification, dynamic options)
        {
            if (options == null || options.SeriesId <= 0)
            {
                throw new ArgumentException("options");
            }

            if (options.SeasonNumber < 0)
            {
                throw new ArgumentException("options.SeasonNumber");
            }

            var series = _seriesProvider.GetSeries(options.SeriesId);

            notification.CurrentMessage = String.Format("Renaming episodes for {0} Season {1}", series.Title, options.SeasonNumber);

            logger.Debug("Getting episodes from database for series: {0} and season: {1}", options.SeriesId, options.SeasonNumber);
            IList <EpisodeFile> episodeFiles = _mediaFileProvider.GetSeasonFiles(options.SeriesId, options.SeasonNumber);

            if (episodeFiles == null || !episodeFiles.Any())
            {
                logger.Warn("No episodes in database found for series: {0} and season: {1}.", options.SeriesId, options.SeasonNumber);
                return;
            }

            var newEpisodeFiles = new List <EpisodeFile>();
            var oldEpisodeFiles = new List <EpisodeFile>();

            foreach (var episodeFile in episodeFiles)
            {
                try
                {
                    var oldFile = new EpisodeFile(episodeFile);
                    var newFile = _diskScanProvider.MoveEpisodeFile(episodeFile);

                    if (newFile != null)
                    {
                        newEpisodeFiles.Add(newFile);
                        oldEpisodeFiles.Add(oldFile);
                    }
                }

                catch (Exception e)
                {
                    logger.WarnException("An error has occurred while renaming file", e);
                }
            }

            if (!oldEpisodeFiles.Any())
            {
                logger.Trace("No episodes were renamed for: {0} Season {1}, no changes were made", series.Title,
                             options.SeasonNumber);
                notification.CurrentMessage = String.Format("Rename completed for: {0} Season {1}, no changes were made", series.Title, options.SeasonNumber);
                return;
            }

            //Remove & Create Metadata for episode files
            //Todo: Add a metadata manager to avoid this hack
            _metadataProvider.RemoveForEpisodeFiles(oldEpisodeFiles);
            _metadataProvider.CreateForEpisodeFiles(newEpisodeFiles);

            //Start AfterRename
            var message = String.Format("Renamed: Series {0}, Season: {1}", series.Title, options.SeasonNumber);

            _externalNotificationProvider.AfterRename(message, series);

            notification.CurrentMessage = String.Format("Rename completed for {0} Season {1}", series.Title, options.SeasonNumber);
        }
示例#10
0
 public async Task SyncMediaProviders()
 {
     var series = await _seriesProvider.GetSeries();
 }
示例#11
0
        public void Start(ProgressNotification notification, dynamic options)
        {
            List <Series> seriesToRename;

            if (options == null || options.SeriesId <= 0)
            {
                seriesToRename = _seriesProvider.GetAllSeries().ToList();
            }

            else
            {
                seriesToRename = new List <Series> {
                    _seriesProvider.GetSeries(options.SeriesId)
                };
            }

            foreach (var series in seriesToRename)
            {
                notification.CurrentMessage = String.Format("Renaming episodes for '{0}'", series.Title);

                Logger.Debug("Getting episodes from database for series: {0}", series.SeriesId);
                var episodeFiles = _mediaFileProvider.GetSeriesFiles(series.SeriesId);

                if (episodeFiles == null || episodeFiles.Count == 0)
                {
                    Logger.Warn("No episodes in database found for series: {0}", series.SeriesId);
                    return;
                }

                var newEpisodeFiles = new List <EpisodeFile>();
                var oldEpisodeFiles = new List <EpisodeFile>();

                foreach (var episodeFile in episodeFiles)
                {
                    try
                    {
                        var oldFile = new EpisodeFile(episodeFile);
                        var newFile = _diskScanProvider.MoveEpisodeFile(episodeFile);

                        if (newFile != null)
                        {
                            newEpisodeFiles.Add(newFile);
                            oldEpisodeFiles.Add(oldFile);
                        }
                    }

                    catch (Exception e)
                    {
                        Logger.WarnException("An error has occurred while renaming file", e);
                    }
                }

                //Remove & Create Metadata for episode files
                _metadataProvider.RemoveForEpisodeFiles(oldEpisodeFiles);
                _metadataProvider.CreateForEpisodeFiles(newEpisodeFiles);

                //Start AfterRename

                var message = String.Format("Renamed: Series {0}", series.Title);
                _externalNotificationProvider.AfterRename(message, series);

                notification.CurrentMessage = String.Format("Rename completed for {0}", series.Title);
            }
        }