예제 #1
0
파일: Deluge.cs 프로젝트: rsunde/Readarr
        private ValidationFailure TestCategory()
        {
            if (Settings.MusicCategory.IsNullOrWhiteSpace() && Settings.MusicImportedCategory.IsNullOrWhiteSpace())
            {
                return(null);
            }

            var enabledPlugins = _proxy.GetEnabledPlugins(Settings);

            if (!enabledPlugins.Contains("Label"))
            {
                return(new NzbDroneValidationFailure("MusicCategory", "Label plugin not activated")
                {
                    DetailedDescription = "You must have the Label plugin enabled in Deluge to use categories."
                });
            }

            var labels = _proxy.GetAvailableLabels(Settings);

            if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && !labels.Contains(Settings.MusicCategory))
            {
                _proxy.AddLabel(Settings.MusicCategory, Settings);
                labels = _proxy.GetAvailableLabels(Settings);

                if (!labels.Contains(Settings.MusicCategory))
                {
                    return(new NzbDroneValidationFailure("MusicCategory", "Configuration of label failed")
                    {
                        DetailedDescription = "Readarr was unable to add the label to Deluge."
                    });
                }
            }

            if (Settings.MusicImportedCategory.IsNotNullOrWhiteSpace() && !labels.Contains(Settings.MusicImportedCategory))
            {
                _proxy.AddLabel(Settings.MusicImportedCategory, Settings);
                labels = _proxy.GetAvailableLabels(Settings);

                if (!labels.Contains(Settings.MusicImportedCategory))
                {
                    return(new NzbDroneValidationFailure("MusicImportedCategory", "Configuration of label failed")
                    {
                        DetailedDescription = "Readarr was unable to add the label to Deluge."
                    });
                }
            }

            return(null);
        }