mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-04 03:27:14 -05:00 
			
		
		
		
	Adding searchs for a specific ressource
This commit is contained in:
		
							parent
							
								
									e2cbbfcd17
								
							
						
					
					
						commit
						23f0b456ba
					
				@ -38,6 +38,9 @@ namespace Kyoo.CommonApi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			foreach ((string key, string desired) in where)
 | 
								foreach ((string key, string desired) in where)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
 | 
									if (key == null || desired == null)
 | 
				
			||||||
 | 
										throw new ArgumentException("Invalid key/value pair. Can't be null.");
 | 
				
			||||||
 | 
									
 | 
				
			||||||
				string value = desired;
 | 
									string value = desired;
 | 
				
			||||||
				string operand = "eq";
 | 
									string operand = "eq";
 | 
				
			||||||
				if (desired.Contains(':'))
 | 
									if (desired.Contains(':'))
 | 
				
			||||||
 | 
				
			|||||||
@ -174,13 +174,13 @@ namespace Kyoo
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			app.UseRouting();
 | 
								app.UseRouting();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								app.UseCookiePolicy(new CookiePolicyOptions 
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									MinimumSameSitePolicy = SameSiteMode.Strict
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
			app.UseAuthentication();
 | 
								app.UseAuthentication();
 | 
				
			||||||
			app.UseIdentityServer();
 | 
								app.UseIdentityServer();
 | 
				
			||||||
			app.UseAuthorization();
 | 
								app.UseAuthorization();
 | 
				
			||||||
			app.UseCookiePolicy(new CookiePolicyOptions 
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				MinimumSameSitePolicy = SameSiteMode.Lax
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			app.UseEndpoints(endpoints =>
 | 
								app.UseEndpoints(endpoints =>
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
 | 
				
			|||||||
@ -79,7 +79,9 @@ namespace Kyoo.Api
 | 
				
			|||||||
		private readonly IConfiguration _configuration;
 | 
							private readonly IConfiguration _configuration;
 | 
				
			||||||
		private readonly string _picturePath;
 | 
							private readonly string _picturePath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public AccountController(UserManager<User> userManager, SignInManager<User> siginInManager, IConfiguration configuration)
 | 
							public AccountController(UserManager<User> userManager, 
 | 
				
			||||||
 | 
								SignInManager<User> siginInManager, 
 | 
				
			||||||
 | 
								IConfiguration configuration)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			_userManager = userManager;
 | 
								_userManager = userManager;
 | 
				
			||||||
			_signInManager = siginInManager;
 | 
								_signInManager = siginInManager;
 | 
				
			||||||
@ -115,10 +117,11 @@ namespace Kyoo.Api
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			if (!ModelState.IsValid)
 | 
								if (!ModelState.IsValid)
 | 
				
			||||||
				return BadRequest(login);
 | 
									return BadRequest(login);
 | 
				
			||||||
			SignInResult result = await _signInManager.PasswordSignInAsync(login.Username, login.Password, login.StayLoggedIn, false);
 | 
								SignInResult result = await _signInManager
 | 
				
			||||||
			if (!result.Succeeded)
 | 
									.PasswordSignInAsync(login.Username, login.Password, login.StayLoggedIn, false);
 | 
				
			||||||
				return BadRequest(new [] { new {code = "InvalidCredentials", description = "Invalid username/password"}});
 | 
								if (result.Succeeded)
 | 
				
			||||||
				return Ok();
 | 
									return Ok();
 | 
				
			||||||
 | 
								return BadRequest(new [] { new {code = "InvalidCredentials", description = "Invalid username/password"}});
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		[HttpPost("otac-login")]
 | 
							[HttpPost("otac-login")]
 | 
				
			||||||
@ -194,11 +197,9 @@ namespace Kyoo.Api
 | 
				
			|||||||
			if (data.Picture?.Length > 0)
 | 
								if (data.Picture?.Length > 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				string path = Path.Combine(_picturePath, user.Id);
 | 
									string path = Path.Combine(_picturePath, user.Id);
 | 
				
			||||||
				await using (FileStream file = System.IO.File.Create(path))
 | 
									await using FileStream file = System.IO.File.Create(path);
 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				await data.Picture.CopyToAsync(file);
 | 
									await data.Picture.CopyToAsync(file);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			await _userManager.UpdateAsync(user);
 | 
								await _userManager.UpdateAsync(user);
 | 
				
			||||||
			return Ok();
 | 
								return Ok();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
using System.Threading.Tasks;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using Kyoo.Controllers;
 | 
					using Kyoo.Controllers;
 | 
				
			||||||
using Kyoo.Models;
 | 
					using Kyoo.Models;
 | 
				
			||||||
using Microsoft.AspNetCore.Authorization;
 | 
					using Microsoft.AspNetCore.Authorization;
 | 
				
			||||||
@ -32,5 +33,52 @@ namespace Kyoo.Api
 | 
				
			|||||||
				Studios = await _libraryManager.SearchStudios(query)
 | 
									Studios = await _libraryManager.SearchStudios(query)
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							[HttpGet("{query}/collection")]
 | 
				
			||||||
 | 
							[HttpGet("{query}/collections")]
 | 
				
			||||||
 | 
							[Authorize(Policy="Read")]
 | 
				
			||||||
 | 
							public Task<ICollection<Collection>> SearchCollections(string query)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return _libraryManager.SearchCollections(query);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							[HttpGet("{query}/show")]
 | 
				
			||||||
 | 
							[HttpGet("{query}/shows")]
 | 
				
			||||||
 | 
							[Authorize(Policy="Read")]
 | 
				
			||||||
 | 
							public Task<ICollection<Show>> SearchShows(string query)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return _libraryManager.SearchShows(query);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							[HttpGet("{query}/episode")]
 | 
				
			||||||
 | 
							[HttpGet("{query}/episodes")]
 | 
				
			||||||
 | 
							[Authorize(Policy="Read")]
 | 
				
			||||||
 | 
							public Task<ICollection<Episode>> SearchEpisodes(string query)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return _libraryManager.SearchEpisodes(query);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							[HttpGet("{query}/people")]
 | 
				
			||||||
 | 
							[Authorize(Policy="Read")]
 | 
				
			||||||
 | 
							public Task<ICollection<People>> SearchPeople(string query)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return _libraryManager.SearchPeople(query);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							[HttpGet("{query}/genre")]
 | 
				
			||||||
 | 
							[HttpGet("{query}/genres")]
 | 
				
			||||||
 | 
							[Authorize(Policy="Read")]
 | 
				
			||||||
 | 
							public Task<ICollection<Genre>> SearchGenres(string query)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return _libraryManager.SearchGenres(query);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							[HttpGet("{query}/studio")]
 | 
				
			||||||
 | 
							[HttpGet("{query}/studios")]
 | 
				
			||||||
 | 
							[Authorize(Policy="Read")]
 | 
				
			||||||
 | 
							public Task<ICollection<Studio>> SearchStudios(string query)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return _libraryManager.SearchStudios(query);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1 +1 @@
 | 
				
			|||||||
Subproject commit 7a9808719933a092e56fc26be8f5c40bf7894e7c
 | 
					Subproject commit c7f916c9c9f8094275ea5505cd2d77fe7a98c682
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user