mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Finishing to rework image's path serialization
This commit is contained in:
parent
779702f969
commit
42ff22ad13
@ -261,7 +261,10 @@ namespace Kyoo.Controllers
|
||||
return obj;
|
||||
}
|
||||
|
||||
private async Task SetRelation<T1, T2>(T1 obj, Task<ICollection<T2>> loader, Action<T1, ICollection<T2>> setter, Action<T2, T1> inverse)
|
||||
private async Task SetRelation<T1, T2>(T1 obj,
|
||||
Task<ICollection<T2>> loader,
|
||||
Action<T1, ICollection<T2>> setter,
|
||||
Action<T2, T1> inverse)
|
||||
{
|
||||
ICollection<T2> loaded = await loader;
|
||||
setter(obj, loaded);
|
||||
@ -300,8 +303,8 @@ namespace Kyoo.Controllers
|
||||
|
||||
(Show s, nameof(Show.ExternalIDs)) => SetRelation(s,
|
||||
ProviderRepository.GetMetadataID(x => x.ShowID == obj.ID),
|
||||
(x, y) => x.ExternalIDs = y,
|
||||
(x, y) => x.Show = y),
|
||||
(x, y) => x.ExternalIDs = y,
|
||||
(x, y) => { x.Show = y; x.ShowID = y.ID; }),
|
||||
|
||||
(Show s, nameof(Show.Genres)) => GenreRepository
|
||||
.GetAll(x => x.Shows.Any(y => y.ID == obj.ID))
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Kyoo.Models.Attributes;
|
||||
|
||||
namespace Kyoo.Models
|
||||
{
|
||||
@ -20,7 +21,8 @@ namespace Kyoo.Models
|
||||
public string TrailerUrl { get; set; }
|
||||
public int? StartYear { get; set; }
|
||||
public int? EndYear { get; set; }
|
||||
public string Poster { get; set; }
|
||||
[SerializeAs("{HOST}/api/{_type}/{Slug}/poster")] public string Poster { get; set; }
|
||||
private string _type => Type == ItemType.Collection ? "collection" : "show";
|
||||
public ItemType Type { get; set; }
|
||||
|
||||
public LibraryItem() {}
|
||||
|
@ -9,7 +9,7 @@ namespace Kyoo.Models
|
||||
public int ID { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Poster { get; set; }
|
||||
[SerializeAs("{HOST}/api/people/{Slug}/poster")] public string Poster { get; set; }
|
||||
[EditableRelation] [LoadableRelation] public virtual ICollection<MetadataID> ExternalIDs { get; set; }
|
||||
|
||||
[EditableRelation] [LoadableRelation] public virtual ICollection<PeopleRole> Roles { get; set; }
|
||||
|
@ -25,31 +25,34 @@ namespace Kyoo.Models
|
||||
|
||||
public class WatchItem
|
||||
{
|
||||
public readonly int EpisodeID;
|
||||
public int EpisodeID { get; set; }
|
||||
|
||||
public string ShowTitle;
|
||||
public string ShowSlug;
|
||||
public int SeasonNumber;
|
||||
public int EpisodeNumber;
|
||||
public string Title;
|
||||
public string Slug;
|
||||
public DateTime? ReleaseDate;
|
||||
[SerializeIgnore] public string Path;
|
||||
public Episode PreviousEpisode;
|
||||
public Episode NextEpisode;
|
||||
public bool IsMovie;
|
||||
public string ShowTitle { get; set; }
|
||||
public string ShowSlug { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public int EpisodeNumber { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
[SerializeIgnore] public string Path { get; set; }
|
||||
public Episode PreviousEpisode { get; set; }
|
||||
public Episode NextEpisode { get; set; }
|
||||
public bool IsMovie { get; set; }
|
||||
|
||||
public string Container;
|
||||
public Track Video;
|
||||
public ICollection<Track> Audios;
|
||||
public ICollection<Track> Subtitles;
|
||||
public ICollection<Chapter> Chapters;
|
||||
[SerializeAs("{HOST}/api/show/{ShowSlug}/poster")] public string Poster { get; set; }
|
||||
[SerializeAs("{HOST}/api/show/{ShowSlug}/logo")] public string Logo { get; set; }
|
||||
[SerializeAs("{HOST}/api/show/{ShowSlug}/backdrop")] public string Backdrop { get; set; }
|
||||
|
||||
public string Container { get; set; }
|
||||
public Track Video { get; set; }
|
||||
public ICollection<Track> Audios { get; set; }
|
||||
public ICollection<Track> Subtitles { get; set; }
|
||||
public ICollection<Chapter> Chapters { get; set; }
|
||||
|
||||
public WatchItem() { }
|
||||
|
||||
private WatchItem(int episodeID,
|
||||
string showTitle,
|
||||
string showSlug,
|
||||
Show show,
|
||||
int seasonNumber,
|
||||
int episodeNumber,
|
||||
string title,
|
||||
@ -57,21 +60,25 @@ namespace Kyoo.Models
|
||||
string path)
|
||||
{
|
||||
EpisodeID = episodeID;
|
||||
ShowTitle = showTitle;
|
||||
ShowSlug = showSlug;
|
||||
ShowTitle = show.Title;
|
||||
ShowSlug = show.Slug;
|
||||
SeasonNumber = seasonNumber;
|
||||
EpisodeNumber = episodeNumber;
|
||||
Title = title;
|
||||
ReleaseDate = releaseDate;
|
||||
Path = path;
|
||||
IsMovie = show.IsMovie;
|
||||
|
||||
Poster = show.Poster;
|
||||
Logo = show.Logo;
|
||||
Backdrop = show.Backdrop;
|
||||
|
||||
Container = Path.Substring(Path.LastIndexOf('.') + 1);
|
||||
Slug = Episode.GetSlug(ShowSlug, seasonNumber, episodeNumber);
|
||||
}
|
||||
|
||||
private WatchItem(int episodeID,
|
||||
string showTitle,
|
||||
string showSlug,
|
||||
Show show,
|
||||
int seasonNumber,
|
||||
int episodeNumber,
|
||||
string title,
|
||||
@ -80,7 +87,7 @@ namespace Kyoo.Models
|
||||
Track video,
|
||||
ICollection<Track> audios,
|
||||
ICollection<Track> subtitles)
|
||||
: this(episodeID, showTitle, showSlug, seasonNumber, episodeNumber, title, releaseDate, path)
|
||||
: this(episodeID, show, seasonNumber, episodeNumber, title, releaseDate, path)
|
||||
{
|
||||
Video = video;
|
||||
Audios = audios;
|
||||
@ -89,11 +96,13 @@ namespace Kyoo.Models
|
||||
|
||||
public static async Task<WatchItem> FromEpisode(Episode ep, ILibraryManager library)
|
||||
{
|
||||
Show show = await library.GetShow(ep.ShowID);
|
||||
Episode previous = null;
|
||||
Episode next = null;
|
||||
|
||||
if (!show.IsMovie)
|
||||
await library.Load(ep, x => x.Show);
|
||||
await library.Load(ep, x => x.Tracks);
|
||||
|
||||
if (!ep.Show.IsMovie)
|
||||
{
|
||||
if (ep.EpisodeNumber > 1)
|
||||
previous = await library.GetEpisode(ep.ShowID, ep.SeasonNumber, ep.EpisodeNumber - 1);
|
||||
@ -109,11 +118,9 @@ namespace Kyoo.Models
|
||||
else
|
||||
next = await library.GetEpisode(ep.ShowID, ep.SeasonNumber, ep.EpisodeNumber + 1);
|
||||
}
|
||||
|
||||
await library.Load(ep, x => x.Tracks);
|
||||
|
||||
return new WatchItem(ep.ID,
|
||||
show.Title,
|
||||
show.Slug,
|
||||
ep.Show,
|
||||
ep.SeasonNumber,
|
||||
ep.EpisodeNumber,
|
||||
ep.Title,
|
||||
@ -123,7 +130,6 @@ namespace Kyoo.Models
|
||||
ep.Tracks.Where(x => x.Type == StreamType.Audio).ToArray(),
|
||||
ep.Tracks.Where(x => x.Type == StreamType.Subtitle).ToArray())
|
||||
{
|
||||
IsMovie = show.IsMovie,
|
||||
PreviousEpisode = previous,
|
||||
NextEpisode = next,
|
||||
Chapters = await GetChapters(ep.Path)
|
||||
|
@ -119,7 +119,8 @@ namespace Kyoo.Controllers
|
||||
if (value == "HOST")
|
||||
return _host;
|
||||
|
||||
PropertyInfo properties = target.GetType().GetProperties()
|
||||
PropertyInfo properties = target.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
|
||||
.FirstOrDefault(y => y.Name == value);
|
||||
if (properties == null)
|
||||
return null;
|
||||
|
@ -51,7 +51,7 @@ namespace Kyoo.Controllers
|
||||
Sort<MetadataID> sort = default,
|
||||
Pagination limit = default)
|
||||
{
|
||||
return ApplyFilters(_database.MetadataIds,
|
||||
return ApplyFilters(_database.MetadataIds.Include(y => y.Provider),
|
||||
x => _database.MetadataIds.FirstOrDefaultAsync(y => y.ID == x),
|
||||
x => x.ID,
|
||||
where,
|
||||
|
@ -23,7 +23,7 @@ namespace Kyoo.Api
|
||||
: base(libraryManager.PeopleRepository, configuration)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_peoplePath = configuration.GetValue<string>("peoplePath");
|
||||
_peoplePath = Path.GetFullPath(configuration.GetValue<string>("peoplePath"));
|
||||
}
|
||||
|
||||
[HttpGet("{id:int}/role")]
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 35e6a601edc494d1bea142fd419c7750c18d21d9
|
||||
Subproject commit f36ac1bb9bf60329a7f04ba76730f43ded7b0d9d
|
Loading…
x
Reference in New Issue
Block a user