diff --git a/.editorconfig b/.editorconfig
index 01763e5f..7b812979 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -89,3 +89,5 @@ resharper_xmldoc_attribute_indent = align_by_first_attribute
resharper_xmldoc_indent_child_elements = RemoveIndent
resharper_xmldoc_indent_text = RemoveIndent
+# Waiting for https://github.com/dotnet/roslyn/issues/44596 to get fixed.
+# file_header_template = Kyoo - A portable and vast media library solution.\nCopyright (c) Kyoo.\n\nSee AUTHORS.md and LICENSE file in the project root for full license information.\n\nKyoo is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\nany later version.\n\nKyoo is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Kyoo. If not, see .
diff --git a/src/Kyoo.Abstractions/Models/Utils/Constants.cs b/src/Kyoo.Abstractions/Models/Utils/Constants.cs
index 5267347b..521dc2d2 100644
--- a/src/Kyoo.Abstractions/Models/Utils/Constants.cs
+++ b/src/Kyoo.Abstractions/Models/Utils/Constants.cs
@@ -32,8 +32,13 @@ namespace Kyoo.Abstractions.Models.Utils
public const int AlternativeRoute = 1;
///
- /// A group name for . It should be used for every .
+ /// A group name for . It should be used for main resources of kyoo.
///
public const string ResourcesGroup = "Resources";
+
+ ///
+ /// A group name for . It should be used for endpoints useful for playback.
+ ///
+ public const string WatchGroup = "Watch";
}
}
diff --git a/src/Kyoo.Abstractions/Module.cs b/src/Kyoo.Abstractions/Module.cs
index 102b9e2e..e0f8c53f 100644
--- a/src/Kyoo.Abstractions/Module.cs
+++ b/src/Kyoo.Abstractions/Module.cs
@@ -16,6 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see .
+using System;
using Autofac;
using Autofac.Builder;
using Kyoo.Abstractions.Controllers;
@@ -96,9 +97,10 @@ namespace Kyoo.Abstractions
///
/// The configuration instance
/// The public URl of kyoo (without a slash at the end)
- public static string GetPublicUrl(this IConfiguration configuration)
+ public static Uri GetPublicUrl(this IConfiguration configuration)
{
- return configuration["basics:publicUrl"]?.TrimEnd('/') ?? "http://localhost:5000";
+ string uri = configuration["basics:publicUrl"]?.TrimEnd('/') ?? "http://localhost:5000";
+ return new Uri(uri);
}
}
}
diff --git a/src/Kyoo.Authentication/AuthenticationModule.cs b/src/Kyoo.Authentication/AuthenticationModule.cs
index 82a224fa..d5e73eb9 100644
--- a/src/Kyoo.Authentication/AuthenticationModule.cs
+++ b/src/Kyoo.Authentication/AuthenticationModule.cs
@@ -104,7 +104,7 @@ namespace Kyoo.Authentication
DefaultCorsPolicyService cors = new(_logger)
{
- AllowedOrigins = { new Uri(_configuration.GetPublicUrl()).GetLeftPart(UriPartial.Authority) }
+ AllowedOrigins = { _configuration.GetPublicUrl().GetLeftPart(UriPartial.Authority) }
};
builder.RegisterInstance(cors).As().SingleInstance();
}
@@ -112,7 +112,7 @@ namespace Kyoo.Authentication
///
public void Configure(IServiceCollection services)
{
- string publicUrl = _configuration.GetPublicUrl();
+ Uri publicUrl = _configuration.GetPublicUrl();
if (_environment.IsDevelopment())
IdentityModelEventSource.ShowPII = true;
@@ -136,7 +136,7 @@ namespace Kyoo.Authentication
services.AddIdentityServer(options =>
{
- options.IssuerUri = publicUrl;
+ options.IssuerUri = publicUrl.ToString();
options.UserInteraction.LoginUrl = $"{publicUrl}/login";
options.UserInteraction.ErrorUrl = $"{publicUrl}/error";
options.UserInteraction.LogoutUrl = $"{publicUrl}/logout";
@@ -151,7 +151,7 @@ namespace Kyoo.Authentication
services.AddAuthentication()
.AddJwtBearer(options =>
{
- options.Authority = publicUrl;
+ options.Authority = publicUrl.ToString();
options.Audience = "kyoo";
options.RequireHttpsMetadata = false;
});
@@ -189,7 +189,7 @@ namespace Kyoo.Authentication
{
app.Use((ctx, next) =>
{
- ctx.SetIdentityServerOrigin(_configuration.GetPublicUrl());
+ ctx.SetIdentityServerOrigin(_configuration.GetPublicUrl().ToString());
return next();
});
app.UseIdentityServer();
diff --git a/src/Kyoo.Core/CoreModule.cs b/src/Kyoo.Core/CoreModule.cs
index 5b0fe2cc..f601ad25 100644
--- a/src/Kyoo.Core/CoreModule.cs
+++ b/src/Kyoo.Core/CoreModule.cs
@@ -140,7 +140,7 @@ namespace Kyoo.Core
///
public void Configure(IServiceCollection services)
{
- string publicUrl = _configuration.GetPublicUrl();
+ Uri publicUrl = _configuration.GetPublicUrl();
services.AddMvcCore()
.AddDataAnnotations()
diff --git a/src/Kyoo.Core/Views/CollectionApi.cs b/src/Kyoo.Core/Views/CollectionApi.cs
index 705fe745..89091a7d 100644
--- a/src/Kyoo.Core/Views/CollectionApi.cs
+++ b/src/Kyoo.Core/Views/CollectionApi.cs
@@ -25,10 +25,8 @@ using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Abstractions.Models.Permissions;
using Kyoo.Abstractions.Models.Utils;
-using Kyoo.Core.Models.Options;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
@@ -56,14 +54,10 @@ namespace Kyoo.Core.Api
///
/// The file manager used to send images.
/// The thumbnail manager used to retrieve images paths.
- ///
- /// Options used to retrieve the base URL of Kyoo.
- ///
public CollectionApi(ILibraryManager libraryManager,
IFileSystem files,
- IThumbnailsManager thumbs,
- IOptions options)
- : base(libraryManager.CollectionRepository, files, thumbs, options.Value.PublicUrl)
+ IThumbnailsManager thumbs)
+ : base(libraryManager.CollectionRepository, files, thumbs)
{
_libraryManager = libraryManager;
}
diff --git a/src/Kyoo.Core/Views/EpisodeApi.cs b/src/Kyoo.Core/Views/EpisodeApi.cs
index bdba37a2..d716dbe7 100644
--- a/src/Kyoo.Core/Views/EpisodeApi.cs
+++ b/src/Kyoo.Core/Views/EpisodeApi.cs
@@ -25,10 +25,8 @@ using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Abstractions.Models.Permissions;
using Kyoo.Abstractions.Models.Utils;
-using Kyoo.Core.Models.Options;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
@@ -39,6 +37,7 @@ namespace Kyoo.Core.Api
[Route("api/episodes")]
[Route("api/episode", Order = AlternativeRoute)]
[ApiController]
+ [ResourceView]
[PartialPermission(nameof(EpisodeApi))]
[ApiDefinition("Episodes", Group = ResourcesGroup)]
public class EpisodeApi : CrudThumbsApi
@@ -56,14 +55,10 @@ namespace Kyoo.Core.Api
///
/// The file manager used to send images.
/// The thumbnail manager used to retrieve images paths.
- ///
- /// Options used to retrieve the base URL of Kyoo.
- ///
public EpisodeApi(ILibraryManager libraryManager,
IFileSystem files,
- IThumbnailsManager thumbnails,
- IOptions options)
- : base(libraryManager.EpisodeRepository, files, thumbnails, options.Value.PublicUrl)
+ IThumbnailsManager thumbnails)
+ : base(libraryManager.EpisodeRepository, files, thumbnails)
{
_libraryManager = libraryManager;
}
diff --git a/src/Kyoo.Core/Views/GenreApi.cs b/src/Kyoo.Core/Views/GenreApi.cs
index 3ec1c7ed..28bc3067 100644
--- a/src/Kyoo.Core/Views/GenreApi.cs
+++ b/src/Kyoo.Core/Views/GenreApi.cs
@@ -23,9 +23,7 @@ using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Permissions;
-using Kyoo.Core.Models.Options;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
namespace Kyoo.Core.Api
{
@@ -37,8 +35,8 @@ namespace Kyoo.Core.Api
{
private readonly ILibraryManager _libraryManager;
- public GenreApi(ILibraryManager libraryManager, IOptions options)
- : base(libraryManager.GenreRepository, options.Value.PublicUrl)
+ public GenreApi(ILibraryManager libraryManager)
+ : base(libraryManager.GenreRepository)
{
_libraryManager = libraryManager;
}
diff --git a/src/Kyoo.Core/Views/Helper/ApiHelper.cs b/src/Kyoo.Core/Views/Helper/ApiHelper.cs
index 7365c5a7..d2e926fa 100644
--- a/src/Kyoo.Core/Views/Helper/ApiHelper.cs
+++ b/src/Kyoo.Core/Views/Helper/ApiHelper.cs
@@ -23,6 +23,10 @@ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Kyoo.Abstractions.Models;
+using Kyoo.Core.Models.Options;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
namespace Kyoo.Core.Api
{
diff --git a/src/Kyoo.Core/Views/Helper/BaseApi.cs b/src/Kyoo.Core/Views/Helper/BaseApi.cs
new file mode 100644
index 00000000..315e92fd
--- /dev/null
+++ b/src/Kyoo.Core/Views/Helper/BaseApi.cs
@@ -0,0 +1,60 @@
+// 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 .
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Kyoo.Abstractions;
+using Kyoo.Abstractions.Models;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Kyoo.Core.Api
+{
+ public class BaseApi : ControllerBase
+ {
+ ///
+ /// Construct and return a page from an api.
+ ///
+ /// The list of resources that should be included in the current page.
+ ///
+ /// The max number of items that should be present per page. This should be the same as in the request,
+ /// it is used to calculate if this is the last page and so on.
+ ///
+ /// The type of items on the page.
+ /// A Page representing the response.
+ protected Page Page(ICollection resources, int limit)
+ where TResult : IResource
+ {
+ Uri publicUrl = HttpContext.RequestServices
+ .GetRequiredService()
+ .GetPublicUrl();
+ return new Page(
+ resources,
+ new Uri(publicUrl, Request.Path),
+ Request.Query.ToDictionary(
+ x => x.Key,
+ x => x.Value.ToString(),
+ StringComparer.InvariantCultureIgnoreCase
+ ),
+ limit
+ );
+ }
+ }
+}
diff --git a/src/Kyoo.Core/Views/Helper/CrudApi.cs b/src/Kyoo.Core/Views/Helper/CrudApi.cs
index 1b16b2b0..16e8beb1 100644
--- a/src/Kyoo.Core/Views/Helper/CrudApi.cs
+++ b/src/Kyoo.Core/Views/Helper/CrudApi.cs
@@ -18,7 +18,6 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
@@ -36,7 +35,7 @@ namespace Kyoo.Core.Api
/// The type of resource to make CRUD apis for.
[ApiController]
[ResourceView]
- public class CrudApi : ControllerBase
+ public class CrudApi : BaseApi
where T : class, IResource
{
///
@@ -44,44 +43,15 @@ namespace Kyoo.Core.Api
///
protected IRepository Repository { get; }
- ///
- /// The base URL of Kyoo. This will be used to create links for images and
- /// .
- ///
- protected Uri BaseURL { get; }
-
///
/// Create a new using the given repository and base url.
///
///
/// The repository to use as a baking store for the type .
///
- ///
- /// The base URL of Kyoo to use to create links.
- ///
- public CrudApi(IRepository repository, Uri baseURL)
+ public CrudApi(IRepository repository)
{
Repository = repository;
- BaseURL = baseURL;
- }
-
- ///
- /// Construct and return a page from an api.
- ///
- /// The list of resources that should be included in the current page.
- ///
- /// The max number of items that should be present per page. This should be the same as in the request,
- /// it is used to calculate if this is the last page and so on.
- ///
- /// The type of items on the page.
- /// A Page representing the response.
- protected Page Page(ICollection resources, int limit)
- where TResult : IResource
- {
- return new Page(resources,
- new Uri(BaseURL, Request.Path),
- Request.Query.ToDictionary(x => x.Key, x => x.Value.ToString(), StringComparer.InvariantCultureIgnoreCase),
- limit);
}
///
diff --git a/src/Kyoo.Core/Views/Helper/CrudThumbsApi.cs b/src/Kyoo.Core/Views/Helper/CrudThumbsApi.cs
index 68acd112..89e2e8c0 100644
--- a/src/Kyoo.Core/Views/Helper/CrudThumbsApi.cs
+++ b/src/Kyoo.Core/Views/Helper/CrudThumbsApi.cs
@@ -16,7 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see .
-using System;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
@@ -56,14 +55,10 @@ namespace Kyoo.Core.Api
///
/// The file manager used to send images.
/// The thumbnail manager used to retrieve images paths.
- ///
- /// The base URL of Kyoo to use to create links.
- ///
public CrudThumbsApi(IRepository repository,
IFileSystem files,
- IThumbnailsManager thumbs,
- Uri baseURL)
- : base(repository, baseURL)
+ IThumbnailsManager thumbs)
+ : base(repository)
{
_files = files;
_thumbs = thumbs;
diff --git a/src/Kyoo.Core/Views/Helper/Serializers/JsonPropertyIgnorer.cs b/src/Kyoo.Core/Views/Helper/Serializers/JsonPropertyIgnorer.cs
index d5f23fce..65c00f7f 100644
--- a/src/Kyoo.Core/Views/Helper/Serializers/JsonPropertyIgnorer.cs
+++ b/src/Kyoo.Core/Views/Helper/Serializers/JsonPropertyIgnorer.cs
@@ -30,9 +30,9 @@ namespace Kyoo.Core.Api
public class JsonPropertyIgnorer : CamelCasePropertyNamesContractResolver
{
private int _depth = -1;
- private string _host;
+ private readonly Uri _host;
- public JsonPropertyIgnorer(string host)
+ public JsonPropertyIgnorer(Uri host)
{
_host = host;
}
diff --git a/src/Kyoo.Core/Views/Helper/Serializers/SerializeAsProvider.cs b/src/Kyoo.Core/Views/Helper/Serializers/SerializeAsProvider.cs
index b16e63ac..ff104fa7 100644
--- a/src/Kyoo.Core/Views/Helper/Serializers/SerializeAsProvider.cs
+++ b/src/Kyoo.Core/Views/Helper/Serializers/SerializeAsProvider.cs
@@ -26,13 +26,13 @@ namespace Kyoo.Core.Api
{
public class SerializeAsProvider : IValueProvider
{
- private string _format;
- private string _host;
+ private readonly string _format;
+ private readonly Uri _host;
- public SerializeAsProvider(string format, string host)
+ public SerializeAsProvider(string format, Uri host)
{
_format = format;
- _host = host.TrimEnd('/');
+ _host = host;
}
public object GetValue(object target)
@@ -43,7 +43,7 @@ namespace Kyoo.Core.Api
string modifier = x.Groups[3].Value;
if (value == "HOST")
- return _host;
+ return _host.ToString().TrimEnd('/');
PropertyInfo properties = target.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
diff --git a/src/Kyoo.Core/Views/LibraryApi.cs b/src/Kyoo.Core/Views/LibraryApi.cs
index 26ebebde..045b7b70 100644
--- a/src/Kyoo.Core/Views/LibraryApi.cs
+++ b/src/Kyoo.Core/Views/LibraryApi.cs
@@ -26,10 +26,8 @@ using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Abstractions.Models.Permissions;
using Kyoo.Abstractions.Models.Utils;
-using Kyoo.Core.Models.Options;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
@@ -40,6 +38,7 @@ namespace Kyoo.Core.Api
[Route("api/libraries")]
[Route("api/library", Order = AlternativeRoute)]
[ApiController]
+ [ResourceView]
[PartialPermission(nameof(LibraryApi), Group = Group.Admin)]
[ApiDefinition("Library", Group = ResourcesGroup)]
public class LibraryApi : CrudApi
@@ -55,11 +54,8 @@ namespace Kyoo.Core.Api
///
/// The library manager used to modify or retrieve information in the data store.
///
- ///
- /// Options used to retrieve the base URL of Kyoo.
- ///
- public LibraryApi(ILibraryManager libraryManager, IOptions options)
- : base(libraryManager.LibraryRepository, options.Value.PublicUrl)
+ public LibraryApi(ILibraryManager libraryManager)
+ : base(libraryManager.LibraryRepository)
{
_libraryManager = libraryManager;
}
@@ -159,7 +155,7 @@ namespace Kyoo.Core.Api
/// List all items of this library.
/// An item can ether represent a collection or a show.
/// This endpoint allow one to retrieve all collections and shows that are not contained in a collection.
- /// This is what is displayed on the /browse page of the webapp.
+ /// This is what is displayed on the /browse/library page of the webapp.
///
/// The ID or slug of the .
/// A key to sort items by.
diff --git a/src/Kyoo.Core/Views/LibraryItemApi.cs b/src/Kyoo.Core/Views/LibraryItemApi.cs
index 1b1137fb..030c60e0 100644
--- a/src/Kyoo.Core/Views/LibraryItemApi.cs
+++ b/src/Kyoo.Core/Views/LibraryItemApi.cs
@@ -18,59 +18,85 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
-using Kyoo.Abstractions.Models.Exceptions;
+using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Abstractions.Models.Permissions;
-using Kyoo.Core.Models.Options;
+using Kyoo.Abstractions.Models.Utils;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
+using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
- [Route("api/item")]
+ ///
+ /// Endpoint for items that are not part of a specific library.
+ /// An item can ether represent a collection or a show.
+ ///
[Route("api/items")]
+ [Route("api/item", Order = AlternativeRoute)]
[ApiController]
[ResourceView]
- public class LibraryItemApi : ControllerBase
+ [ApiDefinition("Items", Group = ResourcesGroup)]
+ public class LibraryItemApi : BaseApi
{
+ ///
+ /// The library item repository used to modify or retrieve information in the data store.
+ ///
private readonly ILibraryItemRepository _libraryItems;
- private readonly Uri _baseURL;
- public LibraryItemApi(ILibraryItemRepository libraryItems, IOptions options)
+ ///
+ /// Create a new .
+ ///
+ ///
+ /// The library item repository used to modify or retrieve information in the data store.
+ ///
+ public LibraryItemApi(ILibraryItemRepository libraryItems)
{
_libraryItems = libraryItems;
- _baseURL = options.Value.PublicUrl;
}
+ ///
+ /// Get items
+ ///
+ ///
+ /// List all items of kyoo.
+ /// An item can ether represent a collection or a show.
+ /// This endpoint allow one to retrieve all collections and shows that are not contained in a collection.
+ /// This is what is displayed on the /browse page of the webapp.
+ ///
+ /// A key to sort items by.
+ /// An optional list of filters.
+ /// The number of items to return.
+ /// An optional item's ID to start the query from this specific item.
+ /// A page of items.
+ /// The filters or the sort parameters are invalid.
+ /// No library with the given ID or slug could be found.
[HttpGet]
[Permission(nameof(LibraryItemApi), Kind.Read)]
- public async Task>> GetAll([FromQuery] string sortBy,
- [FromQuery] int afterID,
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(RequestError))]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
+ public async Task>> GetAll(
+ [FromQuery] string sortBy,
[FromQuery] Dictionary where,
- [FromQuery] int limit = 50)
+ [FromQuery] int limit = 50,
+ [FromQuery] int? afterID = null)
{
try
{
ICollection resources = await _libraryItems.GetAll(
ApiHelper.ParseWhere(where),
new Sort(sortBy),
- new Pagination(limit, afterID));
+ new Pagination(limit, afterID)
+ );
- return new Page(resources,
- new Uri(_baseURL, Request.Path),
- Request.Query.ToDictionary(x => x.Key, x => x.Value.ToString(), StringComparer.InvariantCultureIgnoreCase),
- limit);
- }
- catch (ItemNotFoundException)
- {
- return NotFound();
+ return Page(resources, limit);
}
catch (ArgumentException ex)
{
- return BadRequest(new { Error = ex.Message });
+ return BadRequest(new RequestError(ex.Message));
}
}
}
diff --git a/src/Kyoo.Core/Views/PeopleApi.cs b/src/Kyoo.Core/Views/PeopleApi.cs
index 2d810927..2246d2ad 100644
--- a/src/Kyoo.Core/Views/PeopleApi.cs
+++ b/src/Kyoo.Core/Views/PeopleApi.cs
@@ -23,9 +23,7 @@ using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Exceptions;
using Kyoo.Abstractions.Models.Permissions;
-using Kyoo.Core.Models.Options;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
namespace Kyoo.Core.Api
{
@@ -39,10 +37,9 @@ namespace Kyoo.Core.Api
private readonly IThumbnailsManager _thumbs;
public PeopleApi(ILibraryManager libraryManager,
- IOptions options,
IFileSystem files,
IThumbnailsManager thumbs)
- : base(libraryManager.PeopleRepository, options.Value.PublicUrl)
+ : base(libraryManager.PeopleRepository)
{
_libraryManager = libraryManager;
_files = files;
diff --git a/src/Kyoo.Core/Views/ProviderApi.cs b/src/Kyoo.Core/Views/ProviderApi.cs
index 582c4d3d..0ba3244a 100644
--- a/src/Kyoo.Core/Views/ProviderApi.cs
+++ b/src/Kyoo.Core/Views/ProviderApi.cs
@@ -20,9 +20,7 @@ using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Permissions;
-using Kyoo.Core.Models.Options;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
namespace Kyoo.Core.Api
{
@@ -37,10 +35,9 @@ namespace Kyoo.Core.Api
private readonly IFileSystem _files;
public ProviderApi(ILibraryManager libraryManager,
- IOptions options,
IFileSystem files,
IThumbnailsManager thumbnails)
- : base(libraryManager.ProviderRepository, options.Value.PublicUrl)
+ : base(libraryManager.ProviderRepository)
{
_libraryManager = libraryManager;
_files = files;
diff --git a/src/Kyoo.Core/Views/SeasonApi.cs b/src/Kyoo.Core/Views/SeasonApi.cs
index 75da206d..a92cc256 100644
--- a/src/Kyoo.Core/Views/SeasonApi.cs
+++ b/src/Kyoo.Core/Views/SeasonApi.cs
@@ -25,10 +25,8 @@ using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Abstractions.Models.Permissions;
using Kyoo.Abstractions.Models.Utils;
-using Kyoo.Core.Models.Options;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
@@ -56,14 +54,10 @@ namespace Kyoo.Core.Api
///
/// The file manager used to send images.
/// The thumbnail manager used to retrieve images paths.
- ///
- /// Options used to retrieve the base URL of Kyoo.
- ///
public SeasonApi(ILibraryManager libraryManager,
IFileSystem files,
- IThumbnailsManager thumbs,
- IOptions options)
- : base(libraryManager.SeasonRepository, files, thumbs, options.Value.PublicUrl)
+ IThumbnailsManager thumbs)
+ : base(libraryManager.SeasonRepository, files, thumbs)
{
_libraryManager = libraryManager;
}
diff --git a/src/Kyoo.Core/Views/ShowApi.cs b/src/Kyoo.Core/Views/ShowApi.cs
index 42bde2ae..ec179df0 100644
--- a/src/Kyoo.Core/Views/ShowApi.cs
+++ b/src/Kyoo.Core/Views/ShowApi.cs
@@ -57,6 +57,12 @@ namespace Kyoo.Core.Api
///
private readonly IFileSystem _files;
+ ///
+ /// The base URL of Kyoo. This will be used to create links for images and
+ /// .
+ ///
+ private readonly Uri _baseURL;
+
///
/// Create a new .
///
@@ -72,10 +78,11 @@ namespace Kyoo.Core.Api
IFileSystem files,
IThumbnailsManager thumbs,
IOptions options)
- : base(libraryManager.ShowRepository, files, thumbs, options.Value.PublicUrl)
+ : base(libraryManager.ShowRepository, files, thumbs)
{
_libraryManager = libraryManager;
_files = files;
+ _baseURL = options.Value.PublicUrl;
}
///
@@ -392,7 +399,7 @@ namespace Kyoo.Core.Api
return (await _files.ListFiles(path))
.ToDictionary(
Path.GetFileNameWithoutExtension,
- x => $"{BaseURL}api/shows/{identifier}/fonts/{Path.GetFileName(x)}"
+ x => $"{_baseURL}api/shows/{identifier}/fonts/{Path.GetFileName(x)}"
);
}
diff --git a/src/Kyoo.Core/Views/StudioApi.cs b/src/Kyoo.Core/Views/StudioApi.cs
index f7bd9c77..d15242f5 100644
--- a/src/Kyoo.Core/Views/StudioApi.cs
+++ b/src/Kyoo.Core/Views/StudioApi.cs
@@ -23,9 +23,7 @@ using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Permissions;
-using Kyoo.Core.Models.Options;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
namespace Kyoo.Core.Api
{
@@ -37,8 +35,8 @@ namespace Kyoo.Core.Api
{
private readonly ILibraryManager _libraryManager;
- public StudioApi(ILibraryManager libraryManager, IOptions options)
- : base(libraryManager.StudioRepository, options.Value.PublicUrl)
+ public StudioApi(ILibraryManager libraryManager)
+ : base(libraryManager.StudioRepository)
{
_libraryManager = libraryManager;
}
diff --git a/src/Kyoo.Core/Views/TrackApi.cs b/src/Kyoo.Core/Views/TrackApi.cs
index 1d2e89cb..60a5d0c2 100644
--- a/src/Kyoo.Core/Views/TrackApi.cs
+++ b/src/Kyoo.Core/Views/TrackApi.cs
@@ -22,22 +22,22 @@ using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Abstractions.Models.Permissions;
using Kyoo.Abstractions.Models.Utils;
-using Kyoo.Core.Models.Options;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
///
/// Information about one or multiple .
+ /// A track contain metadata about a video, an audio or a subtitles.
///
[Route("api/tracks")]
[Route("api/track", Order = AlternativeRoute)]
[ApiController]
+ [ResourceView]
[PartialPermission(nameof(Track))]
- [ApiDefinition("Tracks", Group = ResourcesGroup)]
+ [ApiDefinition("Tracks", Group = WatchGroup)]
public class TrackApi : CrudApi