コード例 #1
0
        public async Task <IActionResult> TestSonarrSettings([FromBody] TestSonarrSettingsModel model)
        {
            try
            {
                await Sonarr.TestConnectionAsync(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model));

                return(Ok(new { ok = true }));
            }
            catch (System.Exception)
            {
                return(BadRequest($"The specified settings are invalid"));
            }
        }
コード例 #2
0
        public async Task <IActionResult> GetSonarrTags([FromBody] TestSonarrSettingsModel model)
        {
            try
            {
                var tags = await Sonarr.GetTags(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model));

                return(Ok(tags.Select(x => new SonarrTag
                {
                    Id = x.id,
                    Name = x.label
                })));
            }
            catch (System.Exception)
            {
                return(BadRequest($"Could not load the tags from Sonarr, check your settings."));
            }
        }
コード例 #3
0
        public async Task <IActionResult> GetSonarrRootPaths([FromBody] TestSonarrSettingsModel model)
        {
            try
            {
                var paths = await Sonarr.GetRootPaths(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model));

                return(Ok(paths.Select(x => new SonarrPath
                {
                    Id = x.id,
                    Path = x.path
                })));
            }
            catch (System.Exception)
            {
                return(BadRequest($"Could not load the paths from Sonarr, check your settings."));
            }
        }
コード例 #4
0
 private static Requestrr.DownloadClients.Sonarr.SonarrSettings ConvertToSonarrSettings(TestSonarrSettingsModel model)
 {
     return(new Requestrr.DownloadClients.Sonarr.SonarrSettings
     {
         ApiKey = model.ApiKey.Trim(),
         Hostname = model.Hostname.Trim(),
         Port = model.Port,
         UseSSL = model.UseSSL,
         Version = model.Version
     });
 }