Fix remaining issues with new track implementation

This commit is contained in:
Zoe Roux 2023-07-31 22:49:51 +09:00
parent e6f263b6de
commit f58597379b
5 changed files with 25 additions and 7 deletions

View File

@ -11,6 +11,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Composition" Version="7.0.0" />
</ItemGroup>
</Project>

View File

@ -21,10 +21,10 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models.Attributes;
using Newtonsoft.Json;
namespace Kyoo.Abstractions.Models
{
@ -165,9 +165,10 @@ namespace Kyoo.Abstractions.Models
private static async Task<object> _GetInfo(Episode ep, HttpClient client)
{
return await client.GetFromJsonAsync<object>(
$"http://transcoder:7666/info/{(ep.Show.IsMovie ? "movie" : "episode")}/${ep.Slug}/info"
);
HttpResponseMessage ret = await client.GetAsync($"http://transcoder:7666/{(ep.Show.IsMovie ? "movie" : "episode")}/{ep.Slug}/info");
ret.EnsureSuccessStatusCode();
string content = await ret.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<object>(content);
}
/// <inheritdoc />

View File

@ -127,8 +127,8 @@ namespace Kyoo.Core.Controllers
string directory = item switch
{
IResource res => Path.Combine("/metadata", typeof(T).Name.ToLowerInvariant(), res.Slug),
_ => Path.Combine("/metadata", typeof(T).Name.ToLowerInvariant())
IResource res => Path.Combine("./metadata", typeof(T).Name.ToLowerInvariant(), res.Slug),
_ => Path.Combine("./metadata", typeof(T).Name.ToLowerInvariant())
};
Directory.CreateDirectory(directory);
string imageName = imageId switch

View File

@ -31,6 +31,17 @@ import MusicNote from "@material-symbols/svg-400/rounded/music_note-fill.svg";
import { Stylable, useYoshiki } from "yoshiki/native";
import { fullscreenAtom, subtitleAtom } from "../state";
import { AudiosMenu, QualitiesMenu } from "../video";
import i18next from "i18next";
export const getDisplayName = (sub: Subtitle) => {
const languageNames = new Intl.DisplayNames([i18next.language], { type: "language" });
const lng = sub.language ? languageNames.of(sub.language) : undefined;
if (lng && sub.title) return `${lng} - ${sub.title}`;
if (lng) return lng;
if (sub.title) return sub.title;
return `Unknwon (${sub.index})`;
};
export const RightButtons = ({
subtitles,
@ -72,7 +83,7 @@ export const RightButtons = ({
{subtitles.map((x) => (
<Menu.Item
key={x.index}
label={x.displayName}
label={getDisplayName(x)}
selected={selectedSubtitle === x}
onSelect={() => setSubtitle(x)}
/>

View File

@ -13,6 +13,7 @@ use utoipa::ToSchema;
use crate::transcode::Quality;
#[derive(Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MediaInfo {
/// The sha1 of the video file.
pub sha: String,
@ -30,6 +31,7 @@ pub struct MediaInfo {
}
#[derive(Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct Video {
/// The codec of this stream (defined as the RFC 6381).
pub codec: String,
@ -46,6 +48,7 @@ pub struct Video {
}
#[derive(Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct Audio {
/// The index of this track on the media.
pub index: u32,
@ -62,6 +65,7 @@ pub struct Audio {
}
#[derive(Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct Subtitle {
/// The index of this track on the media.
pub index: u32,
@ -80,6 +84,7 @@ pub struct Subtitle {
}
#[derive(Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct Chapter {
/// The start time of the chapter (in second from the start of the episode).
pub start_time: f32,