public async Task <IActionResult> SaveAsync([FromBody] SaveSonarrSettingsModel model) { var tvShowsSettings = new TvShowsSettings { Client = DownloadClient.Sonarr, Command = model.Command.Trim(), Restrictions = model.Restrictions }; var sonarrSetting = new SonarrSettingsModel { Hostname = model.Hostname.Trim(), Port = model.Port, ApiKey = model.ApiKey.Trim(), BaseUrl = model.BaseUrl.Trim(), TvPath = model.TvPath, TvProfile = model.TvProfile, TvTags = model.TvTags ?? Array.Empty <int>(), TvLanguage = model.TvLanguage, TvUseSeasonFolders = model.TvUseSeasonFolders, AnimePath = model.AnimePath, AnimeProfile = model.AnimeProfile, AnimeTags = model.AnimeTags ?? Array.Empty <int>(), AnimeLanguage = model.AnimeLanguage, AnimeUseSeasonFolders = model.AnimeUseSeasonFolders, SearchNewRequests = model.SearchNewRequests, MonitorNewRequests = model.MonitorNewRequests, UseSSL = model.UseSSL, Version = model.Version }; DownloadClientsSettingsRepository.SetSonarr(tvShowsSettings, sonarrSetting); return(Ok(new { ok = true })); }
public async Task <IActionResult> SaveAsync([FromBody] RadarrSettingsModel model) { var movieSettings = new MoviesSettings { Client = DownloadClient.Radarr, Command = model.Command.Trim() }; var radarrSetting = new RadarrSettingsModel { Hostname = model.Hostname.Trim(), ApiKey = model.ApiKey.Trim(), BaseUrl = model.BaseUrl.Trim(), Port = model.Port, MoviePath = model.MoviePath, MovieProfile = model.MovieProfile, MovieMinAvailability = model.MovieMinAvailability, MovieTags = model.MovieTags ?? Array.Empty <int>(), AnimePath = model.AnimePath, AnimeProfile = model.AnimeProfile, AnimeMinAvailability = model.AnimeMinAvailability, AnimeTags = model.AnimeTags ?? Array.Empty <int>(), SearchNewRequests = model.SearchNewRequests, MonitorNewRequests = model.MonitorNewRequests, UseSSL = model.UseSSL, Version = model.Version }; DownloadClientsSettingsRepository.SetRadarr(movieSettings, radarrSetting); return(Ok(new { ok = true })); }
public async Task <IActionResult> SaveAsync([FromBody] SaveSonarrSettingsModel model) { var tvShowsSettings = new TvShowsSettings { Client = DownloadClient.Sonarr, Restrictions = model.Restrictions }; if (!model.Categories.Any()) { return(BadRequest($"At least one category is required.")); } if (model.Categories.Any(x => string.IsNullOrWhiteSpace(x.Name))) { return(BadRequest($"A category name is required.")); } foreach (var category in model.Categories) { category.Name = category.Name.Trim(); category.Tags = category.Tags; } if (new HashSet <string>(model.Categories.Select(x => x.Name.ToLower())).Count != model.Categories.Length) { return(BadRequest($"All categories must have different names.")); } if (new HashSet <int>(model.Categories.Select(x => x.Id)).Count != model.Categories.Length) { return(BadRequest($"All categories must have different ids.")); } if (model.Categories.Any(x => !Regex.IsMatch(x.Name, @"^[\w-]{1,32}$"))) { return(BadRequest($"Invalid categorie names, make sure they only contain alphanumeric characters, dashes and underscores. (No spaces, etc)")); } var sonarrSetting = new SonarrSettingsModel { Hostname = model.Hostname.Trim(), Port = model.Port, ApiKey = model.ApiKey.Trim(), BaseUrl = model.BaseUrl.Trim(), Categories = model.Categories, SearchNewRequests = model.SearchNewRequests, MonitorNewRequests = model.MonitorNewRequests, UseSSL = model.UseSSL, Version = model.Version }; DownloadClientsSettingsRepository.SetSonarr(tvShowsSettings, sonarrSetting); return(Ok(new { ok = true })); }
public async Task <IActionResult> SaveMoviesAsync([FromBody] SaveOmbiMoviesSettingsModel model) { var movieSettings = new MoviesSettings { Client = DownloadClient.Ombi }; var ombiSettings = Sanitize(model); DownloadClientsSettingsRepository.SetOmbi(movieSettings, ombiSettings); return(Ok(new { ok = true })); }
public async Task <IActionResult> SaveMoviesAsync([FromBody] SaveOverseerrMoviesSettingsModel model) { var movieSettings = new MoviesSettings { Client = DownloadClient.Overseerr, Command = model.Command.Trim(), }; var overseerrSettings = Sanitize(model); DownloadClientsSettingsRepository.SetOverseerr(movieSettings, overseerrSettings); return(Ok(new { ok = true })); }
public async Task <IActionResult> SaveTvShowsAsync([FromBody] SaveOmbiTvShowsSettingsModel model) { var tvShowsSettings = new TvShowsSettings { Client = DownloadClient.Ombi, Restrictions = model.Restrictions }; var ombiSettings = Sanitize(model); DownloadClientsSettingsRepository.SetOmbi(tvShowsSettings, ombiSettings); return(Ok(new { ok = true })); }
public async Task <IActionResult> SaveTvShowsAsync([FromBody] SaveOverseerrTvShowsSettingsModel model) { var tvShowsSettings = new TvShowsSettings { Client = DownloadClient.Overseerr, Command = model.Command.Trim(), Restrictions = model.Restrictions }; var overseerrSettings = Sanitize(model); DownloadClientsSettingsRepository.SetOverseerr(tvShowsSettings, overseerrSettings); return(Ok(new { ok = true })); }
public async Task <IActionResult> SaveTvShowsAsync([FromBody] SaveOverseerrTvShowsSettingsModel model) { var tvShowsSettings = new TvShowsSettings { Client = DownloadClient.Overseerr, Restrictions = model.Restrictions }; Sanitize(model); if (model.TvShows.Categories.Any(x => string.IsNullOrWhiteSpace(x.Name))) { return(BadRequest($"A category name is required.")); } foreach (var category in model.TvShows.Categories) { category.Name = category.Name.Trim(); category.Tags = category.Tags; } if (new HashSet <string>(model.TvShows.Categories.Select(x => x.Name.ToLower())).Count != model.TvShows.Categories.Length) { return(BadRequest($"All categories must have different names.")); } if (new HashSet <int>(model.TvShows.Categories.Select(x => x.Id)).Count != model.TvShows.Categories.Length) { return(BadRequest($"All categories must have different ids.")); } if (model.TvShows.Categories.Any(x => !Regex.IsMatch(x.Name, @"^[\w-]{1,32}$"))) { return(BadRequest($"Invalid categorie names, make sure they only contain alphanumeric characters, dashes and underscores. (No spaces, etc)")); } DownloadClientsSettingsRepository.SetOverseerr(tvShowsSettings, model); return(Ok(new { ok = true })); }