Example #1
0
        private ValidationFailure TestConnection()
        {
            try
            {
                var version = _proxy.GetVersion(Settings);
                if (version < 5)
                {
                    // API version 5 introduced the "save_path" property in /query/torrents
                    return(new NzbDroneValidationFailure("Host", "Unsupported client version")
                    {
                        DetailedDescription = "Please upgrade to qBittorrent version 3.2.4 or higher."
                    });
                }
                else if (version < 6)
                {
                    // API version 6 introduced support for labels
                    if (Settings.TvCategory.IsNotNullOrWhiteSpace())
                    {
                        return(new NzbDroneValidationFailure("Category", "Category is not supported")
                        {
                            DetailedDescription = "Labels are not supported until qBittorrent version 3.3.0. Please upgrade or try again with an empty Category."
                        });
                    }
                }
                else if (Settings.TvCategory.IsNullOrWhiteSpace())
                {
                    // warn if labels are supported, but category is not provided
                    return(new NzbDroneValidationFailure("TvCategory", "Category is recommended")
                    {
                        IsWarning = true,
                        DetailedDescription = "Sonarr will not attempt to import completed downloads without a category."
                    });
                }

                // Complain if qBittorrent is configured to remove torrents on max ratio
                var config = _proxy.GetConfig(Settings);
                if (config.MaxRatioEnabled && config.RemoveOnMaxRatio)
                {
                    return(new NzbDroneValidationFailure(String.Empty, "QBittorrent is configured to remove torrents when they reach their Share Ratio Limit")
                    {
                        DetailedDescription = "Sonarr will be unable to perform Completed Download Handling as configured. You can fix this in qBittorrent ('Tools -> Options...' in the menu) by changing 'Options -> BitTorrent -> Share Ratio Limiting' from 'Remove them' to 'Pause them'."
                    });
                }
            }
            catch (DownloadClientAuthenticationException ex)
            {
                _logger.Error(ex, ex.Message);
                return(new NzbDroneValidationFailure("Username", "Authentication failure")
                {
                    DetailedDescription = "Please verify your username and password."
                });
            }
            catch (WebException ex)
            {
                _logger.Error(ex, ex.Message);
                if (ex.Status == WebExceptionStatus.ConnectFailure)
                {
                    return(new NzbDroneValidationFailure("Host", "Unable to connect")
                    {
                        DetailedDescription = "Please verify the hostname and port."
                    });
                }
                return(new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message));
            }
            catch (Exception ex)
            {
                _logger.Error(ex, ex.Message);
                return(new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message));
            }

            return(null);
        }
Example #2
0
        private ValidationFailure TestConnection()
        {
            try
            {
                var version = _proxy.GetVersion(Settings);
                if (version < 5)
                {
                    // API version 5 introduced the "save_path" property in /query/torrents
                    return(new NzbDroneValidationFailure("Host", "Unsupported client version")
                    {
                        DetailedDescription = "Please upgrade to qBittorrent version 3.2.4 or higher."
                    });
                }
                else if (version < 6)
                {
                    // API version 6 introduced support for labels
                    if (Settings.TvCategory.IsNotNullOrWhiteSpace())
                    {
                        return(new NzbDroneValidationFailure("Category", "Category is not supported")
                        {
                            DetailedDescription = "Labels are not supported until qBittorrent version 3.3.0. Please upgrade or try again with an empty Category."
                        });
                    }
                }
                else if (Settings.TvCategory.IsNullOrWhiteSpace())
                {
                    // warn if labels are supported, but category is not provided
                    return(new NzbDroneValidationFailure("TvCategory", "Category is recommended")
                    {
                        IsWarning = true,
                        DetailedDescription = "Sonarr will not attempt to import completed downloads without a category."
                    });
                }
            }
            catch (DownloadClientAuthenticationException ex)
            {
                _logger.ErrorException(ex.Message, ex);
                return(new NzbDroneValidationFailure("Username", "Authentication failure")
                {
                    DetailedDescription = "Please verify your username and password."
                });
            }
            catch (WebException ex)
            {
                _logger.ErrorException(ex.Message, ex);
                if (ex.Status == WebExceptionStatus.ConnectFailure)
                {
                    return(new NzbDroneValidationFailure("Host", "Unable to connect")
                    {
                        DetailedDescription = "Please verify the hostname and port."
                    });
                }
                return(new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message));
            }
            catch (Exception ex)
            {
                _logger.ErrorException(ex.Message, ex);
                return(new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message));
            }

            return(null);
        }