Esempio n. 1
0
        public async Task <IActionResult> TestSonarrSettings([FromBody] TestSonarrSettingsModel model)
        {
            try
            {
                await SonarrClient.TestConnectionAsync(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model));

                return(Ok(new { ok = true }));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> GetSonarrLanguages([FromBody] TestSonarrSettingsModel model)
        {
            try
            {
                var profiles = await SonarrClient.GetLanguages(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model));

                return(Ok(profiles.Select(x => new SonarrLanguage
                {
                    Id = x.id,
                    Name = x.name
                })));
            }
            catch (System.Exception)
            {
                return(BadRequest($"Could not load the profiles from Sonarr, check your settings."));
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> GetSonarrRootPaths([FromBody] TestSonarrSettingsModel model)
        {
            try
            {
                var paths = await SonarrClient.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."));
            }
        }
Esempio n. 4
0
 private static RequestrrBot.DownloadClients.Sonarr.SonarrSettings ConvertToSonarrSettings(TestSonarrSettingsModel model)
 {
     return(new RequestrrBot.DownloadClients.Sonarr.SonarrSettings
     {
         ApiKey = model.ApiKey.Trim(),
         Hostname = model.Hostname.Trim(),
         BaseUrl = model.BaseUrl.Trim(),
         Port = model.Port,
         UseSSL = model.UseSSL,
         Version = model.Version
     });
 }