mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Make scanner use new /paths route
This commit is contained in:
parent
c4b42c9961
commit
1e73998aa9
@ -94,7 +94,7 @@ public class PermissionAttribute : Attribute, IFilterFactory
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The group of this permission.
|
/// The group of this permission.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Group Group { get; }
|
public Group Group { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ask a permission to run an action.
|
/// Ask a permission to run an action.
|
||||||
|
@ -56,4 +56,5 @@ public static class Constants
|
|||||||
/// A group name for <see cref="ApiDefinitionAttribute"/>. It should be used for endpoints used by admins.
|
/// A group name for <see cref="ApiDefinitionAttribute"/>. It should be used for endpoints used by admins.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string AdminGroup = "4:Admin";
|
public const string AdminGroup = "4:Admin";
|
||||||
|
public const string OtherGroup = "5:Other";
|
||||||
}
|
}
|
||||||
|
@ -30,19 +30,8 @@ namespace Kyoo.Core.Api;
|
|||||||
[Route("health")]
|
[Route("health")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiDefinition("Health")]
|
[ApiDefinition("Health")]
|
||||||
public class Health : BaseApi
|
public class Health(HealthCheckService healthCheckService) : BaseApi
|
||||||
{
|
{
|
||||||
private readonly HealthCheckService _healthCheckService;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a new <see cref="Health"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="healthCheckService">The service to check health.</param>
|
|
||||||
public Health(HealthCheckService healthCheckService)
|
|
||||||
{
|
|
||||||
_healthCheckService = healthCheckService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the api is ready to accept requests.
|
/// Check if the api is ready to accept requests.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -57,7 +46,7 @@ public class Health : BaseApi
|
|||||||
headers.Pragma = "no-cache";
|
headers.Pragma = "no-cache";
|
||||||
headers.Expires = "Thu, 01 Jan 1970 00:00:00 GMT";
|
headers.Expires = "Thu, 01 Jan 1970 00:00:00 GMT";
|
||||||
|
|
||||||
HealthReport result = await _healthCheckService.CheckHealthAsync();
|
HealthReport result = await healthCheckService.CheckHealthAsync();
|
||||||
return result.Status switch
|
return result.Status switch
|
||||||
{
|
{
|
||||||
HealthStatus.Healthy => Ok(new HealthResult("Healthy")),
|
HealthStatus.Healthy => Ok(new HealthResult("Healthy")),
|
45
back/src/Kyoo.Core/Views/Admin/Misc.cs
Normal file
45
back/src/Kyoo.Core/Views/Admin/Misc.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Kyoo - A portable and vast media library solution.
|
||||||
|
// Copyright (c) Kyoo.
|
||||||
|
//
|
||||||
|
// See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
// Kyoo is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// Kyoo is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Kyoo.Abstractions.Models.Permissions;
|
||||||
|
using Kyoo.Core.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Kyoo.Core.Api;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Private APIs only used for other services. Can change at any time without notice.
|
||||||
|
/// </summary>
|
||||||
|
[ApiController]
|
||||||
|
[Permission(nameof(Misc), Kind.Read, Group = Group.Admin)]
|
||||||
|
public class Misc(MiscRepository repo) : BaseApi
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// List all registered paths.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The list of paths known to Kyoo.</returns>
|
||||||
|
[HttpGet("/paths")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public Task<ICollection<string>> GetAllPaths()
|
||||||
|
{
|
||||||
|
return repo.GetRegisteredPaths();
|
||||||
|
}
|
||||||
|
}
|
@ -36,25 +36,12 @@ class KyooClient:
|
|||||||
await self.client.close()
|
await self.client.close()
|
||||||
|
|
||||||
async def get_registered_paths(self) -> List[str]:
|
async def get_registered_paths(self) -> List[str]:
|
||||||
paths = None
|
|
||||||
async with self.client.get(
|
async with self.client.get(
|
||||||
f"{self._url}/episodes",
|
f"{self._url}/paths",
|
||||||
params={"limit": 0},
|
|
||||||
headers={"X-API-Key": self._api_key},
|
headers={"X-API-Key": self._api_key},
|
||||||
) as r:
|
) as r:
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
ret = await r.json()
|
return await r.json()
|
||||||
paths = list(x["path"] for x in ret["items"])
|
|
||||||
|
|
||||||
async with self.client.get(
|
|
||||||
f"{self._url}/movies",
|
|
||||||
params={"limit": 0},
|
|
||||||
headers={"X-API-Key": self._api_key},
|
|
||||||
) as r:
|
|
||||||
r.raise_for_status()
|
|
||||||
ret = await r.json()
|
|
||||||
paths += list(x["path"] for x in ret["items"])
|
|
||||||
return paths
|
|
||||||
|
|
||||||
async def create_issue(self, path: str, issue: str, extra: dict | None = None):
|
async def create_issue(self, path: str, issue: str, extra: dict | None = None):
|
||||||
async with self.client.post(
|
async with self.client.post(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user