コード例 #1
0
        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 }));
        }
コード例 #2
0
        public async Task <IActionResult> SaveMoviesAsync([FromBody] SaveOverseerrMoviesSettingsModel model)
        {
            var movieSettings = new MoviesSettings
            {
                Client = DownloadClient.Overseerr
            };

            Sanitize(model);

            if (model.Movies.Categories.Any(x => string.IsNullOrWhiteSpace(x.Name)))
            {
                return(BadRequest($"A category name is required."));
            }

            foreach (var category in model.Movies.Categories)
            {
                category.Name = category.Name.Trim();
                category.Tags = category.Tags;
            }

            if (new HashSet <string>(model.Movies.Categories.Select(x => x.Name.ToLower())).Count != model.Movies.Categories.Length)
            {
                return(BadRequest($"All categories must have different names."));
            }

            if (new HashSet <int>(model.Movies.Categories.Select(x => x.Id)).Count != model.Movies.Categories.Length)
            {
                return(BadRequest($"All categories must have different ids."));
            }

            if (model.Movies.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(movieSettings, model);

            return(Ok(new { ok = true }));
        }