diff --git a/Kyoo/Views/API/EpisodeApi.cs b/Kyoo/Views/API/EpisodeApi.cs index b39c224d..eff5fe78 100644 --- a/Kyoo/Views/API/EpisodeApi.cs +++ b/Kyoo/Views/API/EpisodeApi.cs @@ -2,6 +2,7 @@ using Kyoo.Models; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; using Kyoo.CommonApi; @@ -163,5 +164,20 @@ namespace Kyoo.Api return BadRequest(new {Error = ex.Message}); } } + + [HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}/thumb")] + [Authorize(Policy="Read")] + public async Task GetThumb(string showSlug, int seasonNumber, int episodeNumber) + { + string path = (await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber))?.Path; + if (path == null) + return NotFound(); + + string thumb = Path.ChangeExtension(path, "jpg"); + + if (System.IO.File.Exists(thumb)) + return new PhysicalFileResult(Path.GetFullPath(thumb), "image/jpg"); + return NotFound(); + } } } \ No newline at end of file diff --git a/Kyoo/Views/API/PeopleApi.cs b/Kyoo/Views/API/PeopleApi.cs index b671fe8a..41d16f04 100644 --- a/Kyoo/Views/API/PeopleApi.cs +++ b/Kyoo/Views/API/PeopleApi.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; +using System.IO; using System.Threading.Tasks; using Kyoo.CommonApi; using Kyoo.Controllers; @@ -17,11 +17,13 @@ namespace Kyoo.Api public class PeopleApi : CrudApi { private readonly ILibraryManager _libraryManager; + private readonly string _peoplePath; public PeopleApi(ILibraryManager libraryManager, IConfiguration configuration) : base(libraryManager.PeopleRepository, configuration) { _libraryManager = libraryManager; + _peoplePath = configuration.GetValue("peoplePath"); } [HttpGet("{id:int}/role")] @@ -89,5 +91,16 @@ namespace Kyoo.Api return BadRequest(new {Error = ex.Message}); } } + + [HttpGet("{slug}/poster")] + [Authorize(Policy="Read")] + public IActionResult GetPeopleIcon(string slug) + { + string thumbPath = Path.Combine(_peoplePath, slug + ".jpg"); + if (!System.IO.File.Exists(thumbPath)) + return NotFound(); + + return new PhysicalFileResult(Path.GetFullPath(thumbPath), "image/jpg"); + } } } \ No newline at end of file diff --git a/Kyoo/Views/API/ShowApi.cs b/Kyoo/Views/API/ShowApi.cs index 9e49fd54..dcb90a66 100644 --- a/Kyoo/Views/API/ShowApi.cs +++ b/Kyoo/Views/API/ShowApi.cs @@ -447,5 +447,50 @@ namespace Kyoo.Api _provider.TryGetContentType(path, out string contentType); return PhysicalFile(fontPath, contentType ?? "application/x-font-ttf"); } + + [HttpGet("{slug}/poster")] + [Authorize(Policy = "Read")] + public async Task GetPoster(string slug) + { + string path = (await _libraryManager.GetShow(slug))?.Path; + if (path == null) + return NotFound(); + + string poster = Path.Combine(path, "poster.jpg"); + + if (System.IO.File.Exists(poster)) + return new PhysicalFileResult(Path.GetFullPath(poster), "image/jpg"); + return NotFound(); + } + + [HttpGet("{slug}/logo")] + [Authorize(Policy="Read")] + public async Task GetLogo(string slug) + { + string path = (await _libraryManager.GetShow(slug))?.Path; + if (path == null) + return NotFound(); + + string logo = Path.Combine(path, "logo.png"); + + if (System.IO.File.Exists(logo)) + return new PhysicalFileResult(Path.GetFullPath(logo), "image/png"); + return NotFound(); + } + + [HttpGet("{slug}/backdrop")] + [Authorize(Policy="Read")] + public async Task GetBackdrop(string slug) + { + string path = (await _libraryManager.GetShow(slug))?.Path; + if (path == null) + return NotFound(); + + string thumb = Path.Combine(path, "backdrop.jpg"); + + if (System.IO.File.Exists(thumb)) + return new PhysicalFileResult(Path.GetFullPath(thumb), "image/jpg"); + return NotFound(); + } } } diff --git a/Kyoo/Views/API/VideoApi.cs b/Kyoo/Views/API/VideoApi.cs index 61a37292..4c0789c0 100644 --- a/Kyoo/Views/API/VideoApi.cs +++ b/Kyoo/Views/API/VideoApi.cs @@ -68,7 +68,7 @@ namespace Kyoo.Api } - [HttpGet("transmux/{showSlug}-s{seasonNumber:int}e{episodeNumber:int}")] + [HttpGet("transmux/{showSlug}-s{seasonNumber:int}e{episodeNumber:int}/master.m3u8")] [Authorize(Policy="Play")] public async Task TransmuxEpisode(string showSlug, int seasonNumber, int episodeNumber) { @@ -84,7 +84,7 @@ namespace Kyoo.Api return PhysicalFile(path, "application/x-mpegurl", true); } - [HttpGet("transmux/{movieSlug}")] + [HttpGet("transmux/{movieSlug}/master.m3u8")] [Authorize(Policy="Play")] public async Task TransmuxMovie(string movieSlug) { @@ -98,7 +98,7 @@ namespace Kyoo.Api return PhysicalFile(path, "application/x-mpegurl", true); } - [HttpGet("transcode/{showSlug}-s{seasonNumber:int}e{episodeNumber:int}")] + [HttpGet("transcode/{showSlug}-s{seasonNumber:int}e{episodeNumber:int}/master.m3u8")] [Authorize(Policy="Play")] public async Task TranscodeEpisode(string showSlug, int seasonNumber, int episodeNumber) { @@ -114,7 +114,7 @@ namespace Kyoo.Api return PhysicalFile(path, "application/x-mpegurl", true); } - [HttpGet("transcode/{movieSlug}")] + [HttpGet("transcode/{movieSlug}/master.m3u8")] [Authorize(Policy="Play")] public async Task TranscodeMovie(string movieSlug) { @@ -129,7 +129,7 @@ namespace Kyoo.Api } - [HttpGet("transmux/{episodeLink}/segment/{chunk}")] + [HttpGet("transmux/{episodeLink}/segments/{chunk}")] [Authorize(Policy="Play")] public IActionResult GetTransmuxedChunk(string episodeLink, string chunk) { @@ -138,7 +138,7 @@ namespace Kyoo.Api return PhysicalFile(path, "video/MP2T"); } - [HttpGet("transcode/{episodeLink}/segment/{chunk}")] + [HttpGet("transcode/{episodeLink}/segments/{chunk}")] [Authorize(Policy="Play")] public IActionResult GetTranscodedChunk(string episodeLink, string chunk) { diff --git a/Kyoo/Views/WebClient b/Kyoo/Views/WebClient index 45976671..8d3747e6 160000 --- a/Kyoo/Views/WebClient +++ b/Kyoo/Views/WebClient @@ -1 +1 @@ -Subproject commit 459766717070ee420c933923727c1e9816b7ddd6 +Subproject commit 8d3747e6021538b9015d8a32f456fcc3799ad8e8 diff --git a/transcoder b/transcoder index e242eb5f..2d15a6ce 160000 --- a/transcoder +++ b/transcoder @@ -1 +1 @@ -Subproject commit e242eb5f19fcf2c4b10aed5bd96072dd498f9476 +Subproject commit 2d15a6cea98639e286083c96443f56a354ed2002