Update player to use new api

This commit is contained in:
Zoe Roux
2023-09-01 17:55:18 +02:00
parent 25418071fe
commit 5ddfe1ddb2
33 changed files with 382 additions and 286 deletions
@@ -130,6 +130,16 @@ namespace Kyoo.Abstractions.Models
/// <inheritdoc />
public Dictionary<string, MetadataId> ExternalId { get; set; } = new();
/// <summary>
/// Links to watch this movie.
/// </summary>
public VideoLinks? Links => Kind == ItemKind.Movie ? new()
{
Direct = $"/video/movie/{Slug}/direct",
Hls = $"/video/movie/{Slug}/master.m3u8",
}
: null;
public LibraryItem() { }
[JsonConstructor]
@@ -163,7 +163,7 @@ namespace Kyoo.Abstractions.Models
/// <summary>
/// Links to watch this episode.
/// </summary>
public object Links => new
public VideoLinks Links => new()
{
Direct = $"/video/episode/{Slug}/direct",
Hls = $"/video/episode/{Slug}/master.m3u8",
@@ -124,7 +124,7 @@ namespace Kyoo.Abstractions.Models
/// <summary>
/// Links to watch this movie.
/// </summary>
public object Links => new
public VideoLinks Links => new()
{
Direct = $"/video/movie/{Slug}/direct",
Hls = $"/video/movie/{Slug}/master.m3u8",
@@ -0,0 +1,36 @@
// Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo.
//
// See AUTHORS.md and LICENSE file in the project root for full license information.
//
// Kyoo is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// Kyoo is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Abstractions.Models
{
/// <summary>
/// The links to see a movie or an episode.
/// </summary>
public class VideoLinks
{
/// <summary>
/// The direct link to the unprocessed video (pristine quality).
/// </summary>
public string Direct { get; set; }
/// <summary>
/// The link to an HLS master playlist containing all qualities available for this video.
/// </summary>
public string Hls { get; set; }
}
}
@@ -320,6 +320,11 @@ namespace Kyoo.Postgresql
modelBuilder.Entity<User>()
.HasIndex(x => x.Slug)
.IsUnique();
modelBuilder.Entity<Movie>()
.Ignore(x => x.Links);
modelBuilder.Entity<LibraryItem>()
.Ignore(x => x.Links);
}
/// <summary>
@@ -67,7 +67,7 @@ namespace Kyoo.Swagger
Kind? kind = controller.Type == null
? controller.Kind
: cur.Kind;
ICollection<string> permissions = _GetPermissionsList(agg, group!.Value);
ICollection<string> permissions = _GetPermissionsList(agg, group ?? Group.Overall);
permissions.Add($"{type}.{kind!.Value.ToString().ToLower()}");
agg[nameof(Kyoo)] = permissions;
return agg;