Ejemplo n.º 1
0
        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 }));
        }
Ejemplo n.º 2
0
        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 }));
        }