mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fixing authorization on the video API
This commit is contained in:
parent
906e0551e5
commit
10eb7d57a8
@ -20,8 +20,8 @@ namespace Kyoo.Controllers
|
||||
|
||||
public Transcoder(IConfiguration config)
|
||||
{
|
||||
_transmuxPath = config.GetValue<string>("transmuxTempPath");
|
||||
_transcodePath = config.GetValue<string>("transcodeTempPath");
|
||||
_transmuxPath = Path.GetFullPath(config.GetValue<string>("transmuxTempPath"));
|
||||
_transcodePath = Path.GetFullPath(config.GetValue<string>("transcodeTempPath"));
|
||||
|
||||
if (TranscoderAPI.init() != Marshal.SizeOf<Models.Watch.Stream>())
|
||||
throw new BadTranscoderException();
|
||||
@ -78,10 +78,11 @@ namespace Kyoo.Controllers
|
||||
|
||||
public async Task<string> Transcode(WatchItem episode)
|
||||
{
|
||||
return null; // Not implemented yet.
|
||||
string folder = Path.Combine(_transcodePath, episode.Link);
|
||||
string manifest = Path.Combine(folder, episode.Link + ".m3u8");
|
||||
float playableDuration = 0;
|
||||
bool transmuxFailed = false;
|
||||
bool transcodeFailed = false;
|
||||
|
||||
try
|
||||
{
|
||||
@ -99,11 +100,11 @@ namespace Kyoo.Controllers
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
transmuxFailed = TranscoderAPI.transcode(episode.Path, manifest.Replace('\\', '/'), out playableDuration) != 0;
|
||||
transcodeFailed = TranscoderAPI.transcode(episode.Path, manifest.Replace('\\', '/'), out playableDuration) != 0;
|
||||
});
|
||||
while (playableDuration < 10 || (!File.Exists(manifest) && !transmuxFailed))
|
||||
while (playableDuration < 10 || (!File.Exists(manifest) && !transcodeFailed))
|
||||
await Task.Delay(10);
|
||||
return transmuxFailed ? null : manifest;
|
||||
return transcodeFailed ? null : manifest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,14 @@ namespace Kyoo.Api
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ITranscoder _transcoder;
|
||||
private readonly string _transmuxPath;
|
||||
private readonly string _transcodePath;
|
||||
|
||||
public VideoController(ILibraryManager libraryManager, ITranscoder transcoder, IConfiguration config)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_transcoder = transcoder;
|
||||
_transmuxPath = config.GetValue<string>("transmuxTempPath");
|
||||
_transcodePath = config.GetValue<string>("transcodeTempPath");
|
||||
}
|
||||
|
||||
[HttpGet("{showSlug}-s{seasonNumber}e{episodeNumber}")]
|
||||
@ -51,7 +53,7 @@ namespace Kyoo.Api
|
||||
[HttpGet("transmux/{episodeLink}/segment/{chunk}")]
|
||||
public IActionResult GetTransmuxedChunk(string episodeLink, string chunk)
|
||||
{
|
||||
string path = Path.Combine(_transmuxPath, episodeLink);
|
||||
string path = Path.GetFullPath(Path.Combine(_transmuxPath, episodeLink));
|
||||
path = Path.Combine(path, "segments" + Path.DirectorySeparatorChar + chunk);
|
||||
|
||||
return PhysicalFile(path, "video/MP2T");
|
||||
@ -71,6 +73,15 @@ namespace Kyoo.Api
|
||||
return StatusCode(500);
|
||||
}
|
||||
|
||||
[HttpGet("transcode/{episodeLink}/segment/{chunk}")]
|
||||
public IActionResult GetTranscodedChunk(string episodeLink, string chunk)
|
||||
{
|
||||
string path = Path.GetFullPath(Path.Combine(_transcodePath, episodeLink));
|
||||
path = Path.Combine(path, "segments" + Path.DirectorySeparatorChar + chunk);
|
||||
|
||||
return PhysicalFile(path, "video/MP2T");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("{movieSlug}")]
|
||||
[Authorize(Policy="Play")]
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a0f3da729cf4160d12f1b45d093b388c8e9f9199
|
||||
Subproject commit ee72f573bd4815ebf7918e76a797310c140cf454
|
Loading…
x
Reference in New Issue
Block a user