mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-06-05 13:55:18 -04:00
Reworking video & images paths
This commit is contained in:
@@ -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<IActionResult> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<People>
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly string _peoplePath;
|
||||
|
||||
public PeopleApi(ILibraryManager libraryManager, IConfiguration configuration)
|
||||
: base(libraryManager.PeopleRepository, configuration)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_peoplePath = configuration.GetValue<string>("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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<ActionResult> 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<IActionResult> 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<IActionResult> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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)
|
||||
{
|
||||
|
||||
+1
-1
Submodule Kyoo/Views/WebClient updated: 4597667170...8d3747e602
+1
-1
Submodule transcoder updated: e242eb5f19...2d15a6cea9
Reference in New Issue
Block a user