mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Merge pull request #119 from AnonymusRaccoon/fix/url
This commit is contained in:
commit
54caa2956d
@ -49,7 +49,6 @@ services:
|
|||||||
restart: on-failure
|
restart: on-failure
|
||||||
environment:
|
environment:
|
||||||
- KYOO_DATADIR=/var/lib/kyoo
|
- KYOO_DATADIR=/var/lib/kyoo
|
||||||
- BASICS__PUBLICURL=https://demo.kyoo.moe
|
|
||||||
- DATABASE__ENABLED=postgres
|
- DATABASE__ENABLED=postgres
|
||||||
- DATABASE__CONFIGURATIONS__POSTGRES__SERVER=postgres
|
- DATABASE__CONFIGURATIONS__POSTGRES__SERVER=postgres
|
||||||
- DATABASE__CONFIGURATIONS__POSTGRES__USER ID=kyoo
|
- DATABASE__CONFIGURATIONS__POSTGRES__USER ID=kyoo
|
||||||
|
@ -6,7 +6,6 @@ services:
|
|||||||
restart: on-failure
|
restart: on-failure
|
||||||
environment:
|
environment:
|
||||||
- KYOO_DATADIR=/var/lib/kyoo
|
- KYOO_DATADIR=/var/lib/kyoo
|
||||||
- BASICS__PUBLICURL=http://localhost:5000
|
|
||||||
- DATABASE__ENABLED=postgres
|
- DATABASE__ENABLED=postgres
|
||||||
- DATABASE__CONFIGURATIONS__POSTGRES__SERVER=postgres
|
- DATABASE__CONFIGURATIONS__POSTGRES__SERVER=postgres
|
||||||
- DATABASE__CONFIGURATIONS__POSTGRES__USER=kyoo
|
- DATABASE__CONFIGURATIONS__POSTGRES__USER=kyoo
|
||||||
|
@ -22,7 +22,6 @@ We are going to take a look at the fields you might want to change to tailor Kyo
|
|||||||
|
|
||||||
- ```basics```
|
- ```basics```
|
||||||
- ```url```: The port on which Kyoo will be exposed
|
- ```url```: The port on which Kyoo will be exposed
|
||||||
- ```publicUrl```: The full URL for Kyoo.
|
|
||||||
For the 3 following fields, the path are relative to the directory ```settings.json``` is in
|
For the 3 following fields, the path are relative to the directory ```settings.json``` is in
|
||||||
- ```pluginsPath```: The directory where the plugins are stored
|
- ```pluginsPath```: The directory where the plugins are stored
|
||||||
- ```transmuxPath```: The directory where the transmux-ed video are stored (used as a cache)
|
- ```transmuxPath```: The directory where the transmux-ed video are stored (used as a cache)
|
||||||
@ -34,7 +33,7 @@ We are going to take a look at the fields you might want to change to tailor Kyo
|
|||||||
- ```tasks```
|
- ```tasks```
|
||||||
- ```parallels```: The number of tasks that can be run at the same time. If the values is not ```1```, the behavior is not implemented.
|
- ```parallels```: The number of tasks that can be run at the same time. If the values is not ```1```, the behavior is not implemented.
|
||||||
- ```scheduled```: An object with keys being the name of an automation task, with a value being the interval between each task of the same type.
|
- ```scheduled```: An object with keys being the name of an automation task, with a value being the interval between each task of the same type.
|
||||||
- The available keys can be found at ```publicUrl/api/tasks``` (as 'slug')
|
- The available keys can be found at ```/api/tasks``` (as 'slug')
|
||||||
- The values must be formatted like ```HH:MM:SS``
|
- The values must be formatted like ```HH:MM:SS``
|
||||||
**For Example** in the default configuration, a file scan task will be executed every 24 hours
|
**For Example** in the default configuration, a file scan task will be executed every 24 hours
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ If everything looks normal, no error message will appear, just log messages.
|
|||||||
Then, we are going to interact with Kyoo's API. To create a library, you must do the following request for each library you want to make:
|
Then, we are going to interact with Kyoo's API. To create a library, you must do the following request for each library you want to make:
|
||||||
|
|
||||||
- POST Request
|
- POST Request
|
||||||
- At ```publicUrl/api/libraries``` (```publicUrl``` is in ```settings.json```)
|
- At ```/api/libraries```
|
||||||
- Content-Type: ```application/json```
|
- Content-Type: ```application/json```
|
||||||
- Body:
|
- Body:
|
||||||
|
|
||||||
@ -97,6 +96,6 @@ Then, we are going to interact with Kyoo's API. To create a library, you must do
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Now that you created your libraries, you can do a simple GET request to ```publicUrl/api/task/scan``` to scan for videos in all the libraries.
|
Now that you created your libraries, you can do a simple GET request to ```/api/task/scan``` to scan for videos in all the libraries.
|
||||||
|
|
||||||
Once the scan is over, ```Task finished: Scan Libraries``` will be displayed! You are now ready to use Kyoo!
|
Once the scan is over, ```Task finished: Scan Libraries``` will be displayed! You are now ready to use Kyoo!
|
||||||
|
@ -91,15 +91,5 @@ namespace Kyoo.Abstractions
|
|||||||
{
|
{
|
||||||
return builder.RegisterRepository<T2>().As<T>();
|
return builder.RegisterRepository<T2>().As<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the public URL of kyoo using the given configuration instance.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="configuration">The configuration instance</param>
|
|
||||||
/// <returns>The public URl of kyoo (without a slash at the end)</returns>
|
|
||||||
public static Uri GetPublicUrl(this IConfiguration configuration)
|
|
||||||
{
|
|
||||||
return new Uri(configuration["basics:publicUrl"] ?? "http://localhost:5000");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Kyoo.Abstractions;
|
|
||||||
using Kyoo.Abstractions.Controllers;
|
using Kyoo.Abstractions.Controllers;
|
||||||
using Kyoo.Authentication.Models;
|
using Kyoo.Authentication.Models;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
@ -76,7 +75,6 @@ namespace Kyoo.Authentication
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Configure(IServiceCollection services)
|
public void Configure(IServiceCollection services)
|
||||||
{
|
{
|
||||||
Uri publicUrl = _configuration.GetPublicUrl();
|
|
||||||
AuthenticationOption jwt = ConfigurationBinder.Get<AuthenticationOption>(
|
AuthenticationOption jwt = ConfigurationBinder.Get<AuthenticationOption>(
|
||||||
_configuration.GetSection(AuthenticationOption.Path)
|
_configuration.GetSection(AuthenticationOption.Path)
|
||||||
);
|
);
|
||||||
@ -87,12 +85,10 @@ namespace Kyoo.Authentication
|
|||||||
{
|
{
|
||||||
options.TokenValidationParameters = new TokenValidationParameters
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
{
|
{
|
||||||
ValidateIssuer = true,
|
ValidateIssuer = false,
|
||||||
ValidateAudience = true,
|
ValidateAudience = false,
|
||||||
ValidateLifetime = true,
|
ValidateLifetime = true,
|
||||||
ValidateIssuerSigningKey = true,
|
ValidateIssuerSigningKey = true,
|
||||||
ValidIssuer = publicUrl.ToString(),
|
|
||||||
ValidAudience = publicUrl.ToString(),
|
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwt.Secret))
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwt.Secret))
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -24,10 +24,8 @@ using System.Linq;
|
|||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Kyoo.Abstractions;
|
|
||||||
using Kyoo.Abstractions.Models;
|
using Kyoo.Abstractions.Models;
|
||||||
using Kyoo.Authentication.Models;
|
using Kyoo.Authentication.Models;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
@ -43,20 +41,13 @@ namespace Kyoo.Authentication
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IOptions<AuthenticationOption> _options;
|
private readonly IOptions<AuthenticationOption> _options;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The configuration used to retrieve the public URL of kyoo.
|
|
||||||
/// </summary>
|
|
||||||
private readonly IConfiguration _configuration;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="TokenController"/>.
|
/// Create a new <see cref="TokenController"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="options">The options that this controller will use.</param>
|
/// <param name="options">The options that this controller will use.</param>
|
||||||
/// <param name="configuration">The configuration used to retrieve the public URL of kyoo.</param>
|
public TokenController(IOptions<AuthenticationOption> options)
|
||||||
public TokenController(IOptions<AuthenticationOption> options, IConfiguration configuration)
|
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
_configuration = configuration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -80,8 +71,6 @@ namespace Kyoo.Authentication
|
|||||||
claims.Add(new Claim(Claims.Email, user.Email));
|
claims.Add(new Claim(Claims.Email, user.Email));
|
||||||
JwtSecurityToken token = new(
|
JwtSecurityToken token = new(
|
||||||
signingCredentials: credential,
|
signingCredentials: credential,
|
||||||
issuer: _configuration.GetPublicUrl().ToString(),
|
|
||||||
audience: _configuration.GetPublicUrl().ToString(),
|
|
||||||
claims: claims,
|
claims: claims,
|
||||||
expires: DateTime.UtcNow.Add(expireIn)
|
expires: DateTime.UtcNow.Add(expireIn)
|
||||||
);
|
);
|
||||||
@ -95,8 +84,6 @@ namespace Kyoo.Authentication
|
|||||||
SigningCredentials credential = new(key, SecurityAlgorithms.HmacSha256Signature);
|
SigningCredentials credential = new(key, SecurityAlgorithms.HmacSha256Signature);
|
||||||
JwtSecurityToken token = new(
|
JwtSecurityToken token = new(
|
||||||
signingCredentials: credential,
|
signingCredentials: credential,
|
||||||
issuer: _configuration.GetPublicUrl().ToString(),
|
|
||||||
audience: _configuration.GetPublicUrl().ToString(),
|
|
||||||
claims: new[]
|
claims: new[]
|
||||||
{
|
{
|
||||||
new Claim(Claims.Id, user.ID.ToString(CultureInfo.InvariantCulture)),
|
new Claim(Claims.Id, user.ID.ToString(CultureInfo.InvariantCulture)),
|
||||||
@ -119,12 +106,10 @@ namespace Kyoo.Authentication
|
|||||||
{
|
{
|
||||||
principal = tokenHandler.ValidateToken(refreshToken, new TokenValidationParameters
|
principal = tokenHandler.ValidateToken(refreshToken, new TokenValidationParameters
|
||||||
{
|
{
|
||||||
ValidateIssuer = true,
|
ValidateIssuer = false,
|
||||||
ValidateAudience = true,
|
ValidateAudience = false,
|
||||||
ValidateIssuerSigningKey = true,
|
ValidateIssuerSigningKey = true,
|
||||||
ValidateLifetime = true,
|
ValidateLifetime = true,
|
||||||
ValidIssuer = _configuration.GetPublicUrl().ToString(),
|
|
||||||
ValidAudience = _configuration.GetPublicUrl().ToString(),
|
|
||||||
IssuerSigningKey = key
|
IssuerSigningKey = key
|
||||||
}, out SecurityToken _);
|
}, out SecurityToken _);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ namespace Kyoo.Authentication.Views
|
|||||||
/// Sign in, Sign up or refresh tokens.
|
/// Sign in, Sign up or refresh tokens.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/auth")]
|
[Route("auth")]
|
||||||
[ApiDefinition("Authentication", Group = UsersGroup)]
|
[ApiDefinition("Authentication", Group = UsersGroup)]
|
||||||
public class AuthApi : ControllerBase
|
public class AuthApi : ControllerBase
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Kyoo.Core.Models.Options
|
namespace Kyoo.Core.Models.Options
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -35,11 +33,6 @@ namespace Kyoo.Core.Models.Options
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Url { get; set; } = "http://*:5000";
|
public string Url { get; set; } = "http://*:5000";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The public url that will be used in items response and in authentication server host.
|
|
||||||
/// </summary>
|
|
||||||
public Uri PublicUrl { get; set; } = new("http://localhost:5000");
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The path of the plugin directory.
|
/// The path of the plugin directory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -31,8 +31,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An API to retrieve or edit configuration settings
|
/// An API to retrieve or edit configuration settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/configuration")]
|
[Route("configuration")]
|
||||||
[Route("api/config", Order = AlternativeRoute)]
|
[Route("config", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[PartialPermission("Configuration", Group = Group.Admin)]
|
[PartialPermission("Configuration", Group = Group.Admin)]
|
||||||
[ApiDefinition("Configuration", Group = AdminGroup)]
|
[ApiDefinition("Configuration", Group = AdminGroup)]
|
||||||
|
@ -32,8 +32,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An endpoint to list and run tasks in the background.
|
/// An endpoint to list and run tasks in the background.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/tasks")]
|
[Route("tasks")]
|
||||||
[Route("api/task", Order = AlternativeRoute)]
|
[Route("task", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ResourceView]
|
[ResourceView]
|
||||||
[PartialPermission("Task", Group = Group.Admin)]
|
[PartialPermission("Task", Group = Group.Admin)]
|
||||||
|
@ -19,11 +19,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Kyoo.Abstractions;
|
|
||||||
using Kyoo.Abstractions.Models;
|
using Kyoo.Abstractions.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace Kyoo.Core.Api
|
namespace Kyoo.Core.Api
|
||||||
{
|
{
|
||||||
@ -45,12 +42,9 @@ namespace Kyoo.Core.Api
|
|||||||
protected Page<TResult> Page<TResult>(ICollection<TResult> resources, int limit)
|
protected Page<TResult> Page<TResult>(ICollection<TResult> resources, int limit)
|
||||||
where TResult : IResource
|
where TResult : IResource
|
||||||
{
|
{
|
||||||
Uri publicUrl = HttpContext.RequestServices
|
|
||||||
.GetRequiredService<IConfiguration>()
|
|
||||||
.GetPublicUrl();
|
|
||||||
return new Page<TResult>(
|
return new Page<TResult>(
|
||||||
resources,
|
resources,
|
||||||
new Uri(publicUrl, Request.Path),
|
new Uri(Request.Path),
|
||||||
Request.Query.ToDictionary(
|
Request.Query.ToDictionary(
|
||||||
x => x.Key,
|
x => x.Key,
|
||||||
x => x.Value.ToString(),
|
x => x.Value.ToString(),
|
||||||
|
@ -34,30 +34,21 @@ namespace Kyoo.Core.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The options containing the public URL of kyoo, given to <see cref="JsonSerializerContract"/>.
|
|
||||||
/// </summary>
|
|
||||||
private readonly IOptions<BasicOptions> _options;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="JsonOptions"/>.
|
/// Create a new <see cref="JsonOptions"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="httpContextAccessor">
|
/// <param name="httpContextAccessor">
|
||||||
/// The http context accessor given to the <see cref="JsonSerializerContract"/>.
|
/// The http context accessor given to the <see cref="JsonSerializerContract"/>.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="options">
|
public JsonOptions(IHttpContextAccessor httpContextAccessor)
|
||||||
/// The options containing the public URL of kyoo, given to <see cref="JsonSerializerContract"/>.
|
|
||||||
/// </param>
|
|
||||||
public JsonOptions(IHttpContextAccessor httpContextAccessor, IOptions<BasicOptions> options)
|
|
||||||
{
|
{
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
_options = options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Configure(MvcNewtonsoftJsonOptions options)
|
public void Configure(MvcNewtonsoftJsonOptions options)
|
||||||
{
|
{
|
||||||
options.SerializerSettings.ContractResolver = new JsonSerializerContract(_httpContextAccessor, _options);
|
options.SerializerSettings.ContractResolver = new JsonSerializerContract(_httpContextAccessor);
|
||||||
options.SerializerSettings.Converters.Add(new PeopleRoleConverter());
|
options.SerializerSettings.Converters.Add(new PeopleRoleConverter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,7 @@ using System.ComponentModel;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Kyoo.Abstractions.Models;
|
using Kyoo.Abstractions.Models;
|
||||||
using Kyoo.Abstractions.Models.Attributes;
|
using Kyoo.Abstractions.Models.Attributes;
|
||||||
using Kyoo.Core.Models.Options;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
|
|
||||||
@ -43,20 +41,13 @@ namespace Kyoo.Core.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The options containing the public URL of kyoo.
|
|
||||||
/// </summary>
|
|
||||||
private readonly IOptions<BasicOptions> _options;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="JsonSerializerContract"/>.
|
/// Create a new <see cref="JsonSerializerContract"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="httpContextAccessor">The http context accessor to use.</param>
|
/// <param name="httpContextAccessor">The http context accessor to use.</param>
|
||||||
/// <param name="options">The options containing the public URL of kyoo.</param>
|
public JsonSerializerContract(IHttpContextAccessor httpContextAccessor)
|
||||||
public JsonSerializerContract(IHttpContextAccessor httpContextAccessor, IOptions<BasicOptions> options)
|
|
||||||
{
|
{
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
_options = options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -107,7 +98,7 @@ namespace Kyoo.Core.Api
|
|||||||
IThumbnails thumb = (IThumbnails)x;
|
IThumbnails thumb = (IThumbnails)x;
|
||||||
return thumb?.Images?.ContainsKey(id) == true;
|
return thumb?.Images?.ContainsKey(id) == true;
|
||||||
},
|
},
|
||||||
ValueProvider = new ThumbnailProvider(_options.Value.PublicUrl, id)
|
ValueProvider = new ThumbnailProvider(id)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,11 +111,6 @@ namespace Kyoo.Core.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private class ThumbnailProvider : IValueProvider
|
private class ThumbnailProvider : IValueProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The public address of kyoo.
|
|
||||||
/// </summary>
|
|
||||||
private readonly Uri _host;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The index/ID of the image to retrieve/set.
|
/// The index/ID of the image to retrieve/set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -133,11 +119,9 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="ThumbnailProvider"/>.
|
/// Create a new <see cref="ThumbnailProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="host">The public address of kyoo.</param>
|
|
||||||
/// <param name="imageIndex">The index/ID of the image to retrieve/set.</param>
|
/// <param name="imageIndex">The index/ID of the image to retrieve/set.</param>
|
||||||
public ThumbnailProvider(Uri host, int imageIndex)
|
public ThumbnailProvider(int imageIndex)
|
||||||
{
|
{
|
||||||
_host = host;
|
|
||||||
_imageIndex = imageIndex;
|
_imageIndex = imageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +144,7 @@ namespace Kyoo.Core.Api
|
|||||||
string type = target is ICustomTypeDescriptor descriptor
|
string type = target is ICustomTypeDescriptor descriptor
|
||||||
? descriptor.GetClassName()
|
? descriptor.GetClassName()
|
||||||
: target.GetType().Name;
|
: target.GetType().Name;
|
||||||
return new Uri(_host, $"/api/{type}/{slug}/{Images.ImageName[_imageIndex]}".ToLower())
|
return new Uri($"/{type}/{slug}/{Images.ImageName[_imageIndex]}".ToLowerInvariant())
|
||||||
.ToString();
|
.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information about one or multiple <see cref="Genre"/>.
|
/// Information about one or multiple <see cref="Genre"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/genres")]
|
[Route("genres")]
|
||||||
[Route("api/genre", Order = AlternativeRoute)]
|
[Route("genre", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[PartialPermission(nameof(Genre))]
|
[PartialPermission(nameof(Genre))]
|
||||||
[ApiDefinition("Genres", Group = MetadataGroup)]
|
[ApiDefinition("Genres", Group = MetadataGroup)]
|
||||||
|
@ -30,8 +30,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// Providers are links to external websites or database.
|
/// Providers are links to external websites or database.
|
||||||
/// They are mostly linked to plugins that provide metadata from those websites.
|
/// They are mostly linked to plugins that provide metadata from those websites.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/providers")]
|
[Route("providers")]
|
||||||
[Route("api/provider", Order = AlternativeRoute)]
|
[Route("provider", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ResourceView]
|
[ResourceView]
|
||||||
[PartialPermission(nameof(Provider))]
|
[PartialPermission(nameof(Provider))]
|
||||||
|
@ -35,8 +35,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information about one or multiple staff member.
|
/// Information about one or multiple staff member.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/staff")]
|
[Route("staff")]
|
||||||
[Route("api/people", Order = AlternativeRoute)]
|
[Route("people", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ResourceView]
|
[ResourceView]
|
||||||
[PartialPermission(nameof(People))]
|
[PartialPermission(nameof(People))]
|
||||||
|
@ -34,8 +34,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information about one or multiple <see cref="Studio"/>.
|
/// Information about one or multiple <see cref="Studio"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/studios")]
|
[Route("studios")]
|
||||||
[Route("api/studio", Order = AlternativeRoute)]
|
[Route("studio", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[PartialPermission(nameof(Show))]
|
[PartialPermission(nameof(Show))]
|
||||||
[ApiDefinition("Studios", Group = MetadataGroup)]
|
[ApiDefinition("Studios", Group = MetadataGroup)]
|
||||||
|
@ -34,8 +34,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information about one or multiple <see cref="Collection"/>.
|
/// Information about one or multiple <see cref="Collection"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/collections")]
|
[Route("collections")]
|
||||||
[Route("api/collection", Order = AlternativeRoute)]
|
[Route("collection", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[PartialPermission(nameof(Collection))]
|
[PartialPermission(nameof(Collection))]
|
||||||
[ApiDefinition("Collections", Group = ResourcesGroup)]
|
[ApiDefinition("Collections", Group = ResourcesGroup)]
|
||||||
|
@ -34,8 +34,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information about one or multiple <see cref="Episode"/>.
|
/// Information about one or multiple <see cref="Episode"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/episodes")]
|
[Route("episodes")]
|
||||||
[Route("api/episode", Order = AlternativeRoute)]
|
[Route("episode", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ResourceView]
|
[ResourceView]
|
||||||
[PartialPermission(nameof(Episode))]
|
[PartialPermission(nameof(Episode))]
|
||||||
|
@ -36,8 +36,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information about one or multiple <see cref="Library"/>.
|
/// Information about one or multiple <see cref="Library"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/libraries")]
|
[Route("libraries")]
|
||||||
[Route("api/library", Order = AlternativeRoute)]
|
[Route("library", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ResourceView]
|
[ResourceView]
|
||||||
[PartialPermission(nameof(Library), Group = Group.Admin)]
|
[PartialPermission(nameof(Library), Group = Group.Admin)]
|
||||||
|
@ -34,8 +34,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// Endpoint for items that are not part of a specific library.
|
/// Endpoint for items that are not part of a specific library.
|
||||||
/// An item can ether represent a collection or a show.
|
/// An item can ether represent a collection or a show.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/items")]
|
[Route("items")]
|
||||||
[Route("api/item", Order = AlternativeRoute)]
|
[Route("item", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ResourceView]
|
[ResourceView]
|
||||||
[PartialPermission(nameof(LibraryItem))]
|
[PartialPermission(nameof(LibraryItem))]
|
||||||
|
@ -32,7 +32,7 @@ namespace Kyoo.Core.Api
|
|||||||
/// An endpoint to search for every resources of kyoo. Searching for only a specific type of resource
|
/// An endpoint to search for every resources of kyoo. Searching for only a specific type of resource
|
||||||
/// is available on the said endpoint.
|
/// is available on the said endpoint.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/search/{query}")]
|
[Route("search/{query}")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ResourceView]
|
[ResourceView]
|
||||||
[ApiDefinition("Search", Group = ResourcesGroup)]
|
[ApiDefinition("Search", Group = ResourcesGroup)]
|
||||||
|
@ -34,8 +34,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information about one or multiple <see cref="Season"/>.
|
/// Information about one or multiple <see cref="Season"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/seasons")]
|
[Route("seasons")]
|
||||||
[Route("api/season", Order = AlternativeRoute)]
|
[Route("season", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[PartialPermission(nameof(Season))]
|
[PartialPermission(nameof(Season))]
|
||||||
[ApiDefinition("Seasons", Group = ResourcesGroup)]
|
[ApiDefinition("Seasons", Group = ResourcesGroup)]
|
||||||
|
@ -36,10 +36,10 @@ namespace Kyoo.Core.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information about one or multiple <see cref="Show"/>.
|
/// Information about one or multiple <see cref="Show"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/shows")]
|
[Route("shows")]
|
||||||
[Route("api/show", Order = AlternativeRoute)]
|
[Route("show", Order = AlternativeRoute)]
|
||||||
[Route("api/movie", Order = AlternativeRoute)]
|
[Route("movie", Order = AlternativeRoute)]
|
||||||
[Route("api/movies", Order = AlternativeRoute)]
|
[Route("movies", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[PartialPermission(nameof(Show))]
|
[PartialPermission(nameof(Show))]
|
||||||
[ApiDefinition("Shows", Group = ResourcesGroup)]
|
[ApiDefinition("Shows", Group = ResourcesGroup)]
|
||||||
|
@ -32,8 +32,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// Information about one or multiple <see cref="Track"/>.
|
/// Information about one or multiple <see cref="Track"/>.
|
||||||
/// A track contain metadata about a video, an audio or a subtitles.
|
/// A track contain metadata about a video, an audio or a subtitles.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/tracks")]
|
[Route("tracks")]
|
||||||
[Route("api/track", Order = AlternativeRoute)]
|
[Route("track", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ResourceView]
|
[ResourceView]
|
||||||
[PartialPermission(nameof(Track))]
|
[PartialPermission(nameof(Track))]
|
||||||
|
@ -34,8 +34,8 @@ namespace Kyoo.Core.Api
|
|||||||
/// It contains streams (video, audio, subtitles) information, chapters, next and previous episodes and a bit of
|
/// It contains streams (video, audio, subtitles) information, chapters, next and previous episodes and a bit of
|
||||||
/// information of the show.
|
/// information of the show.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/watch")]
|
[Route("watch")]
|
||||||
[Route("api/watchitem", Order = AlternativeRoute)]
|
[Route("watchitem", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiDefinition("Watch Items", Group = WatchGroup)]
|
[ApiDefinition("Watch Items", Group = WatchGroup)]
|
||||||
public class WatchApi : ControllerBase
|
public class WatchApi : ControllerBase
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"basics": {
|
"basics": {
|
||||||
"url": "http://*:5000",
|
"url": "http://*:5000",
|
||||||
"publicUrl": "http://localhost:5000/",
|
|
||||||
"pluginsPath": "plugins/",
|
"pluginsPath": "plugins/",
|
||||||
"transmuxPath": "cached/transmux",
|
"transmuxPath": "cached/transmux",
|
||||||
"transcodePath": "cached/transcode",
|
"transcodePath": "cached/transcode",
|
||||||
|
@ -40,7 +40,7 @@ namespace Kyoo.Host.WindowsTrait
|
|||||||
private readonly IApplication _application;
|
private readonly IApplication _application;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The options containing the <see cref="BasicOptions.PublicUrl"/>.
|
/// The options containing the <see cref="BasicOptions.Url"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IOptions<BasicOptions> _options;
|
private readonly IOptions<BasicOptions> _options;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ namespace Kyoo.Host.WindowsTrait
|
|||||||
private readonly IApplication _application;
|
private readonly IApplication _application;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The options containing the <see cref="BasicOptions.PublicUrl"/>.
|
/// The options containing the <see cref="BasicOptions.Url"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IOptions<BasicOptions> _options;
|
private readonly IOptions<BasicOptions> _options;
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ namespace Kyoo.Host.WindowsTrait
|
|||||||
{
|
{
|
||||||
Process browser = new()
|
Process browser = new()
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo(_options.Value.PublicUrl.ToString())
|
StartInfo = new ProcessStartInfo(_options.Value.Url.ToString().Replace("//*:", "//localhost:"))
|
||||||
{
|
{
|
||||||
UseShellExecute = true
|
UseShellExecute = true
|
||||||
}
|
}
|
||||||
|
@ -91,11 +91,6 @@ namespace Kyoo.Swagger
|
|||||||
Name = "GPL-3.0-or-later",
|
Name = "GPL-3.0-or-later",
|
||||||
Url = "https://github.com/AnonymusRaccoon/Kyoo/blob/master/LICENSE"
|
Url = "https://github.com/AnonymusRaccoon/Kyoo/blob/master/LICENSE"
|
||||||
};
|
};
|
||||||
options.Servers.Add(new OpenApiServer
|
|
||||||
{
|
|
||||||
Url = _configuration.GetPublicUrl().ToString(),
|
|
||||||
Description = "The currently running kyoo's instance."
|
|
||||||
});
|
|
||||||
|
|
||||||
options.Info.ExtensionData ??= new Dictionary<string, object>();
|
options.Info.ExtensionData ??= new Dictionary<string, object>();
|
||||||
options.Info.ExtensionData["x-logo"] = new
|
options.Info.ExtensionData["x-logo"] = new
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*** Settings ***
|
*** Settings ***
|
||||||
Documentation Common things to handle rest requests
|
Documentation Common things to handle rest requests
|
||||||
|
|
||||||
Library REST http://localhost:5000/api
|
Library REST http://localhost:5000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user