From a7a725173da0be952e0a7407f9f42f1ea1123f84 Mon Sep 17 00:00:00 2001 From: crobibero Date: Tue, 19 May 2020 08:28:02 -0600 Subject: [PATCH] Rename to AttachmentsController -> VideoAttachmentsController --- .../Controllers/AttachmentsController.cs | 85 ------------------- 1 file changed, 85 deletions(-) delete mode 100644 Jellyfin.Api/Controllers/AttachmentsController.cs diff --git a/Jellyfin.Api/Controllers/AttachmentsController.cs b/Jellyfin.Api/Controllers/AttachmentsController.cs deleted file mode 100644 index 30fb951cf..000000000 --- a/Jellyfin.Api/Controllers/AttachmentsController.cs +++ /dev/null @@ -1,85 +0,0 @@ -#nullable enable - -using System; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Common.Extensions; -using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.MediaEncoding; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - -namespace Jellyfin.Api.Controllers -{ - /// - /// Attachments controller. - /// - [Route("Videos")] - [Authorize] - public class AttachmentsController : Controller - { - private readonly ILibraryManager _libraryManager; - private readonly IAttachmentExtractor _attachmentExtractor; - - /// - /// Initializes a new instance of the class. - /// - /// Instance of the interface. - /// Instance of the interface. - public AttachmentsController( - ILibraryManager libraryManager, - IAttachmentExtractor attachmentExtractor) - { - _libraryManager = libraryManager; - _attachmentExtractor = attachmentExtractor; - } - - /// - /// Get video attachment. - /// - /// Video ID. - /// Media Source ID. - /// Attachment Index. - /// Attachment retrieved. - /// Video or attachment not found. - /// An containing the attachment stream on success, or a if the attachment could not be found. - [HttpGet("{VideoID}/{MediaSourceID}/Attachments/{Index}")] - [Produces("application/octet-stream")] - [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task> GetAttachment( - [FromRoute] Guid videoId, - [FromRoute] string mediaSourceId, - [FromRoute] int index) - { - try - { - var item = _libraryManager.GetItemById(videoId); - if (item == null) - { - return NotFound(); - } - - var (attachment, stream) = await _attachmentExtractor.GetAttachment( - item, - mediaSourceId, - index, - CancellationToken.None) - .ConfigureAwait(false); - - var contentType = "application/octet-stream"; - if (string.IsNullOrWhiteSpace(attachment.MimeType)) - { - contentType = attachment.MimeType; - } - - return new FileStreamResult(stream, contentType); - } - catch (ResourceNotFoundException e) - { - return StatusCode(StatusCodes.Status404NotFound, e.Message); - } - } - } -}