62 lines
2.3 KiB
C#
62 lines
2.3 KiB
C#
using System.Net.Mime;
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Model.IO;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
using MediaBrowser.Controller;
|
|
using MediaBrowser.Controller.Providers;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using MediaBrowser.Controller.Collections;
|
|
using MediaBrowser.Common.Api;
|
|
|
|
|
|
namespace Jellyfin.Plugin.SmartPlaylist.Api {
|
|
[ApiController]
|
|
[Authorize(Policy = Policies.RequiresElevation)]
|
|
[Route("SmartCollection")]
|
|
[Produces(MediaTypeNames.Application.Json)]
|
|
public class SmartCollectionController : ControllerBase {
|
|
private readonly ILogger _logger;
|
|
private readonly ILibraryManager _libraryManager;
|
|
private readonly IUserManager _userManager;
|
|
private readonly IProviderManager _providerManager;
|
|
private readonly IFileSystem _fileSystem;
|
|
private readonly ICollectionManager _collectionManager;
|
|
|
|
private readonly IStore _store;
|
|
|
|
public SmartCollectionController(
|
|
ILogger<SmartCollectionController> logger,
|
|
ILibraryManager libraryManager,
|
|
IUserManager userManager,
|
|
IProviderManager providerManager,
|
|
IFileSystem fileSystem,
|
|
ICollectionManager collectionManager,
|
|
IServerApplicationPaths serverApplicationPaths
|
|
) {
|
|
_logger = logger;
|
|
_libraryManager = libraryManager;
|
|
_userManager = userManager;
|
|
_providerManager = providerManager;
|
|
_fileSystem = fileSystem;
|
|
_collectionManager = collectionManager;
|
|
|
|
_store = new Store(new SmartFileSystem(serverApplicationPaths));
|
|
}
|
|
|
|
[HttpGet]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
public async Task<ActionResult<IReadOnlyList<SmartCollectionDto>>> GetCollections() {
|
|
return Ok(await _store.GetAllSmartCollectionsAsync());
|
|
}
|
|
|
|
[HttpPost]
|
|
[ProducesResponseType(StatusCodes.Status201Created)]
|
|
public async Task<ActionResult> SetCollection([FromBody, Required] SmartCollectionDto smartCollection) {
|
|
await _store.SaveSmartCollectionAsync(smartCollection);
|
|
return Created();
|
|
}
|
|
}
|
|
}
|