Supporting custom fonts

This commit is contained in:
Zoe Roux 2020-10-31 03:38:39 +01:00
parent 201f059349
commit 38eff27001
5 changed files with 13 additions and 6 deletions

View File

@ -41,7 +41,7 @@ namespace Kyoo.Controllers.TranscoderLink
for (int i = 0; i < arrayLength; i++)
{
Stream stream = Marshal.PtrToStructure<Stream>(streamsPtr);
if (stream!.Type != StreamType.Unknow && stream.Type != StreamType.Font)
if (stream!.Type != StreamType.Unknow)
{
tracks[j] = new Track(stream);
j++;

View File

@ -8,6 +8,7 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Kyoo.Models.Exceptions;
using Kyoo.Models.Watch;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Controllers
@ -306,7 +307,9 @@ namespace Kyoo.Controllers
private async Task<IEnumerable<Track>> GetTracks(Episode episode)
{
episode.Tracks = await _transcoder.ExtractInfos(episode.Path);
episode.Tracks = (await _transcoder.ExtractInfos(episode.Path))
.Where(x => x.Type != StreamType.Font)
.ToArray();
return episode.Tracks;
}

View File

@ -422,14 +422,18 @@ namespace Kyoo.Api
string path = (await _libraryManager.GetShow(slug))?.Path;
if (path == null)
return NotFound();
path = Path.Combine(path, "Subtitles", "fonts");
if (!Directory.Exists(path))
return new Dictionary<string, string>();
return Directory.GetFiles(path)
.ToDictionary(Path.GetFileNameWithoutExtension, x => $"{BaseURL}/shows/{slug}/fonts/{x}");
.ToDictionary(Path.GetFileNameWithoutExtension,
x => $"{BaseURL}/api/shows/{slug}/fonts/{Path.GetFileName(x)}");
}
[HttpGet("{showSlug}/font/{slug}")]
[HttpGet("{showSlug}/fonts/{slug}")]
[Authorize(Policy = "Read")]
public async Task<ActionResult<Dictionary<string, string>>> GetFont(string showSlug, string slug)
public async Task<ActionResult> GetFont(string showSlug, string slug)
{
string path = (await _libraryManager.GetShow(showSlug))?.Path;
if (path == null)

@ -1 +1 @@
Subproject commit 83d20f5ebca1ce7cc5ccc987fbcc81e3459a7e53
Subproject commit df4919833fdd5ecd6c3d0eed09d30fae2a4cf965

@ -1 +1 @@
Subproject commit 00b52325c5bda97f03fcb8e33caf9fef239c6c2c
Subproject commit 542241feb932113ea6481f4e49823872fca4f30a