mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-08 10:44:20 -04:00
Finishing subtitle selector.
This commit is contained in:
parent
7cf9a6fe6b
commit
9453f02cf2
@ -25,7 +25,7 @@ export class BrowseComponent implements OnInit
|
||||
|
||||
ngAfterViewInit()
|
||||
{
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
$('[data-toggle="tooltip"]').tooltip({ trigger: "hover" });
|
||||
}
|
||||
|
||||
getThumb(slug: string)
|
||||
|
@ -1,13 +1,13 @@
|
||||
<div class="root">
|
||||
<div class="episodes" id="episodes">
|
||||
<div class="episode" *ngFor="let episode of this.episodes" id="el-{{episode.episodeNumber}}">
|
||||
<a class="episode" *ngFor="let episode of this.episodes" id="el-{{episode.episodeNumber}}" routerLink="/watch/{{this.showSlug}}-s{{episode.seasonNumber}}e{{episode.episodeNumber}}" href="/watch/{{this.showSlug}}-s{{episode.seasonNumber}}e{{episode.episodeNumber}}">
|
||||
<div class="img" [style.background-image]="sanitize(episode.thumb, true)">
|
||||
<button mat-icon-button class="playBtn" routerLink="/watch/{{this.showSlug}}-s{{episode.seasonNumber}}e{{episode.episodeNumber}}"><i class="material-icons playIcon">play_circle_outline</i></button>
|
||||
<button mat-icon-button class="playBtn"><i class="material-icons playIcon">play_circle_outline</i></button>
|
||||
</div>
|
||||
<h6 *ngIf="episode.seasonNumber != 0; else elseBlock;" class="title">S{{episode.seasonNumber}}:E{{episode.episodeNumber}} - {{episode.title}}</h6>
|
||||
<ng-template #elseBlock><h6 class="title">{{episode.title}}</h6></ng-template>
|
||||
<p class="overview">{{episode.overview}}</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<button mat-raised-button color="accent" class="scrollBtn d-none" id="el-leftBtn" (click)="scrollLeft()"><mat-icon>arrow_left</mat-icon></button>
|
||||
<button mat-raised-button color="accent" class="scrollBtn" id="el-rightBtn" (click)="scrollRight()"><mat-icon>arrow_right</mat-icon></button>
|
||||
|
@ -57,6 +57,8 @@
|
||||
flex-shrink: 0;
|
||||
width: 55%;
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
text-decoration: inherit;
|
||||
|
||||
@include media-breakpoint-up(sm)
|
||||
{
|
||||
|
@ -6,6 +6,10 @@
|
||||
</video>
|
||||
</div>
|
||||
|
||||
<div id="loadIndicator">
|
||||
<div class="spinner-border align-self-center" role="status"></div>
|
||||
</div>
|
||||
|
||||
<div id="hover">
|
||||
<div class="back">
|
||||
<button mat-icon-button data-toggle="tooltip" data-placement="bottom" title="Back" (click)="back()">
|
||||
@ -81,18 +85,18 @@
|
||||
</div>
|
||||
|
||||
<mat-menu #subtitles="matMenu">
|
||||
<button mat-menu-item (click)="selectSubtitle(null)">
|
||||
<button [ngClass]="{'selected': this.selectedSubtitle == null}" mat-menu-item (click)="selectSubtitle(null)">
|
||||
<span>None</span>
|
||||
</button>
|
||||
|
||||
<div *ngFor="let subtitle of this.item.subtitles">
|
||||
<button mat-menu-item *ngIf="subtitle.codec == 'ass'; else elseBlock" (click)="selectSubtitle(subtitle)">
|
||||
<span>{{subtitle.language}}</span>
|
||||
<button [ngClass]="{'selected': this.selectedSubtitle == subtitle}" mat-menu-item *ngIf="subtitle.codec == 'ass'; else elseBlock" (click)="selectSubtitle(subtitle)">
|
||||
<span>{{subtitle.displayName}}</span>
|
||||
</button>
|
||||
|
||||
<ng-template #elseBlock>
|
||||
<button mat-menu-item disabled>
|
||||
<span>{{subtitle.language}}</span>
|
||||
<span>{{subtitle.displayName}} ({{subtitle.codec}})</span>
|
||||
</button>
|
||||
</ng-template>
|
||||
</div>
|
||||
|
@ -291,3 +291,28 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mat-menu-item
|
||||
{
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
.selected
|
||||
{
|
||||
background: #595959 !important;
|
||||
color: var(--accentColor);
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
#loadIndicator
|
||||
{
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
pointer-events: none;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
@ -98,6 +98,17 @@ export class PlayerComponent implements OnInit
|
||||
this.setDuration(this.player.duration);
|
||||
};
|
||||
|
||||
let loadIndicator: HTMLElement = document.getElementById("loadIndicator") as HTMLElement;
|
||||
this.player.onwaiting = () =>
|
||||
{
|
||||
loadIndicator.classList.remove("d-none");
|
||||
}
|
||||
|
||||
this.player.oncanplay = () =>
|
||||
{
|
||||
loadIndicator.classList.add("d-none");
|
||||
}
|
||||
|
||||
let progressBar: HTMLElement = document.getElementById("progress-bar") as HTMLElement;
|
||||
$(progressBar).click((event) =>
|
||||
{
|
||||
@ -212,6 +223,8 @@ export class PlayerComponent implements OnInit
|
||||
{
|
||||
document.getElementById("nav").classList.remove("d-none");
|
||||
this.title.setTitle("Kyoo");
|
||||
|
||||
$(document).unbind();
|
||||
}
|
||||
|
||||
back()
|
||||
@ -296,7 +309,7 @@ export class PlayerComponent implements OnInit
|
||||
|
||||
getSubtitleLink(subtitle: Track): string
|
||||
{
|
||||
let link: string = "/api/subtitle/" + this.item.link + "-" + subtitle.language;
|
||||
let link: string = "/api/subtitle/" + this.item.link + "." + subtitle.language;
|
||||
|
||||
if (subtitle.isForced)
|
||||
link += "-forced";
|
||||
|
@ -21,6 +21,7 @@ export interface WatchItem
|
||||
|
||||
export interface Track
|
||||
{
|
||||
displayName: string;
|
||||
title: string;
|
||||
language: string;
|
||||
isDefault: boolean;
|
||||
|
@ -2,11 +2,12 @@
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Watch;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
//[ApiController]
|
||||
public class SubtitleController : ControllerBase
|
||||
{
|
||||
private readonly ILibraryManager libraryManager;
|
||||
@ -18,29 +19,25 @@ namespace Kyoo.Controllers
|
||||
this.transcoder = transcoder;
|
||||
}
|
||||
|
||||
[HttpGet("{showSlug}-s{seasonNumber}e{episodeNumber}-{languageTag}.{codec?}")]
|
||||
public IActionResult GetSubtitle(string showSlug, long seasonNumber, long episodeNumber, string languageTag, string codec)
|
||||
[HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}.{identifier}.{codec?}")]
|
||||
public IActionResult GetSubtitle(string showSlug, int seasonNumber, int episodeNumber, string identifier, string codec)
|
||||
{
|
||||
Track subtitle = libraryManager.GetSubtitle(showSlug, seasonNumber, episodeNumber, languageTag, false);
|
||||
string languageTag = identifier.Substring(0, 3);
|
||||
bool forced = identifier.Length > 3 && identifier.Substring(4) == "forced";
|
||||
|
||||
Track subtitle = libraryManager.GetSubtitle(showSlug, seasonNumber, episodeNumber, languageTag, forced);
|
||||
|
||||
if (subtitle == null)
|
||||
return NotFound();
|
||||
|
||||
//Should use appropriate mime type here
|
||||
return PhysicalFile(subtitle.Path, "text/x-ssa");
|
||||
}
|
||||
|
||||
//This one is never called.
|
||||
[HttpGet("{showSlug}-s{seasonNumber}e{episodeNumber}-{languageTag}-{disposition}.{codec?}")] //Disposition can't be tagged as optional because there is a parametter after him.
|
||||
public IActionResult GetForcedSubtitle(string showSlug, long seasonNumber, long episodeNumber, string languageTag, string disposition, string codec)
|
||||
{
|
||||
Track subtitle = libraryManager.GetSubtitle(showSlug, seasonNumber, episodeNumber, languageTag, disposition == "forced");
|
||||
|
||||
if (subtitle == null)
|
||||
return NotFound();
|
||||
string mime = "text/vtt";
|
||||
if (subtitle.Codec == "ass")
|
||||
mime = "text/x-ssa";
|
||||
else if (subtitle.Codec == "subrip")
|
||||
mime = "application/x-subrip";
|
||||
|
||||
//Should use appropriate mime type here
|
||||
return PhysicalFile(subtitle.Path, "text/x-ssa");
|
||||
return PhysicalFile(subtitle.Path, mime);
|
||||
}
|
||||
|
||||
[HttpGet("extract/{showSlug}-s{seasonNumber}e{episodeNumber}")]
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Kyoo.Models.Watch;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Kyoo.Models
|
||||
@ -26,6 +28,7 @@ namespace Kyoo.Models
|
||||
|
||||
public class Track : Stream
|
||||
{
|
||||
public string DisplayName;
|
||||
[JsonIgnore] public readonly long id;
|
||||
[JsonIgnore] public long episodeID;
|
||||
[JsonIgnore] public StreamType type;
|
||||
@ -41,6 +44,14 @@ namespace Kyoo.Models
|
||||
Codec = codec;
|
||||
IsExternal = isExternal;
|
||||
Path = path;
|
||||
|
||||
//Converting mkv track language to c# system language tag.
|
||||
if (language == "fre")
|
||||
language = "fra";
|
||||
|
||||
DisplayName = CultureInfo.GetCultures(CultureTypes.NeutralCultures).Where(x => x.ThreeLetterISOLanguageName == language).FirstOrDefault()?.DisplayName ?? language;
|
||||
if (Title != null && Title.Length > 1)
|
||||
DisplayName += " - " + Title;
|
||||
}
|
||||
|
||||
public static Track FromReader(System.Data.SQLite.SQLiteDataReader reader)
|
||||
|
Loading…
x
Reference in New Issue
Block a user