mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 05:34:23 -04:00
Add next/previous episode field. Add movie load
This commit is contained in:
parent
3cdfc91c93
commit
ab12de8287
@ -150,6 +150,25 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Dictionary<string, MetadataId> ExternalId { get; set; } = new();
|
public Dictionary<string, MetadataId> ExternalId { get; set; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The previous episode that should be seen before viewing this one.
|
||||||
|
/// </summary>
|
||||||
|
[LoadableRelation] public Episode? PreviousEpisode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The next episode to watch after this one.
|
||||||
|
/// </summary>
|
||||||
|
[LoadableRelation] public Episode? NextEpisode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Links to watch this episode.
|
||||||
|
/// </summary>
|
||||||
|
public object Links => new
|
||||||
|
{
|
||||||
|
Direct = $"/video/episode/{Slug}/direct",
|
||||||
|
Hls = $"/video/episode/{Slug}/master.m3u8",
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the slug of an episode.
|
/// Get the slug of an episode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -121,6 +121,15 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[LoadableRelation] public ICollection<Collection>? Collections { get; set; }
|
[LoadableRelation] public ICollection<Collection>? Collections { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Links to watch this movie.
|
||||||
|
/// </summary>
|
||||||
|
public object Links => new
|
||||||
|
{
|
||||||
|
Direct = $"/video/movie/{Slug}/direct",
|
||||||
|
Hls = $"/video/movie/{Slug}/master.m3u8",
|
||||||
|
};
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void OnMerge(object merged)
|
public void OnMerge(object merged)
|
||||||
{
|
{
|
||||||
|
@ -255,6 +255,28 @@ namespace Kyoo.Core.Controllers
|
|||||||
.GetAll(x => x.Collections.Any(y => y.Id == obj.Id))
|
.GetAll(x => x.Collections.Any(y => y.Id == obj.Id))
|
||||||
.Then(x => c.Shows = x),
|
.Then(x => c.Shows = x),
|
||||||
|
|
||||||
|
(Collection c, nameof(Collection.Movies)) => MovieRepository
|
||||||
|
.GetAll(x => x.Collections.Any(y => y.Id == obj.Id))
|
||||||
|
.Then(x => c.Movies = x),
|
||||||
|
|
||||||
|
|
||||||
|
(Movie m, nameof(Movie.People)) => PeopleRepository
|
||||||
|
.GetFromShow(obj.Id)
|
||||||
|
.Then(x => m.People = x),
|
||||||
|
|
||||||
|
(Movie m, nameof(Movie.Collections)) => CollectionRepository
|
||||||
|
.GetAll(x => x.Movies.Any(y => y.Id == obj.Id))
|
||||||
|
.Then(x => m.Collections = x),
|
||||||
|
|
||||||
|
(Movie m, nameof(Movie.Studio)) => StudioRepository
|
||||||
|
.GetOrDefault(x => x.Movies.Any(y => y.Id == obj.Id))
|
||||||
|
.Then(x =>
|
||||||
|
{
|
||||||
|
m.Studio = x;
|
||||||
|
m.StudioID = x?.Id ?? 0;
|
||||||
|
}),
|
||||||
|
|
||||||
|
|
||||||
(Show s, nameof(Show.People)) => PeopleRepository
|
(Show s, nameof(Show.People)) => PeopleRepository
|
||||||
.GetFromShow(obj.Id)
|
.GetFromShow(obj.Id)
|
||||||
.Then(x => s.People = x),
|
.Then(x => s.People = x),
|
||||||
@ -312,11 +334,28 @@ namespace Kyoo.Core.Controllers
|
|||||||
e.SeasonID = x?.Id ?? 0;
|
e.SeasonID = x?.Id ?? 0;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
(Episode e, nameof(Episode.PreviousEpisode)) => EpisodeRepository
|
||||||
|
.GetAll(
|
||||||
|
where: x => x.ShowID == e.ShowID,
|
||||||
|
limit: new Pagination(1, e.Id, true)
|
||||||
|
).Then(x => e.PreviousEpisode = x.FirstOrDefault()),
|
||||||
|
|
||||||
|
(Episode e, nameof(Episode.NextEpisode)) => EpisodeRepository
|
||||||
|
.GetAll(
|
||||||
|
where: x => x.ShowID == e.ShowID,
|
||||||
|
limit: new Pagination(1, e.Id)
|
||||||
|
).Then(x => e.NextEpisode = x.FirstOrDefault()),
|
||||||
|
|
||||||
|
|
||||||
(Studio s, nameof(Studio.Shows)) => ShowRepository
|
(Studio s, nameof(Studio.Shows)) => ShowRepository
|
||||||
.GetAll(x => x.Studio.Id == obj.Id)
|
.GetAll(x => x.Studio.Id == obj.Id)
|
||||||
.Then(x => s.Shows = x),
|
.Then(x => s.Shows = x),
|
||||||
|
|
||||||
|
(Studio s, nameof(Studio.Movies)) => MovieRepository
|
||||||
|
.GetAll(x => x.Studio.Id == obj.Id)
|
||||||
|
.Then(x => s.Movies = x),
|
||||||
|
|
||||||
|
|
||||||
(People p, nameof(People.Roles)) => PeopleRepository
|
(People p, nameof(People.Roles)) => PeopleRepository
|
||||||
.GetFromPeople(obj.Id)
|
.GetFromPeople(obj.Id)
|
||||||
.Then(x => p.Roles = x),
|
.Then(x => p.Roles = x),
|
||||||
|
@ -69,8 +69,6 @@ namespace Kyoo.Core.Controllers
|
|||||||
Pagination limit = default)
|
Pagination limit = default)
|
||||||
{
|
{
|
||||||
return await ApplyFilters(_database.LibraryItems, where, sort, limit);
|
return await ApplyFilters(_database.LibraryItems, where, sort, limit);
|
||||||
// .Select(x => x.ToItem())
|
|
||||||
// .ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Kyoo.Abstractions.Models;
|
using Kyoo.Abstractions.Models;
|
||||||
@ -73,76 +72,5 @@ namespace Kyoo.Core.Api
|
|||||||
property.ShouldDeserialize = _ => false;
|
property.ShouldDeserialize = _ => false;
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
|
|
||||||
{
|
|
||||||
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
|
|
||||||
// if (!type.IsAssignableTo(typeof(Image)))
|
|
||||||
// return properties;
|
|
||||||
// foreach ((int id, string image) in Images.ImageName)
|
|
||||||
// {
|
|
||||||
// properties.Add(new JsonProperty
|
|
||||||
// {
|
|
||||||
// DeclaringType = type,
|
|
||||||
// PropertyName = image.ToLower(),
|
|
||||||
// UnderlyingName = image,
|
|
||||||
// PropertyType = typeof(string),
|
|
||||||
// Readable = true,
|
|
||||||
// Writable = false,
|
|
||||||
// ItemIsReference = false,
|
|
||||||
// TypeNameHandling = TypeNameHandling.None,
|
|
||||||
// ShouldSerialize = x =>
|
|
||||||
// {
|
|
||||||
// IThumbnails thumb = (IThumbnails)x;
|
|
||||||
// return thumb?.Images?.ContainsKey(id) == true;
|
|
||||||
// },
|
|
||||||
// ValueProvider = new ThumbnailProvider(id)
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A custom <see cref="IValueProvider"/> that uses the
|
|
||||||
/// <see cref="IThumbnails"/>.<see cref="IThumbnails.Images"/> as a value.
|
|
||||||
/// </summary>
|
|
||||||
private class ThumbnailProvider : IValueProvider
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The index/ID of the image to retrieve/set.
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _imageIndex;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a new <see cref="ThumbnailProvider"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="imageIndex">The index/ID of the image to retrieve/set.</param>
|
|
||||||
public ThumbnailProvider(int imageIndex)
|
|
||||||
{
|
|
||||||
_imageIndex = imageIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public void SetValue(object target, object value)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public object GetValue(object target)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
// string slug = (target as IResource)?.Slug ?? (target as ICustomTypeDescriptor)?.GetComponentName();
|
|
||||||
// if (target is not IThumbnails thumb
|
|
||||||
// || slug == null
|
|
||||||
// || string.IsNullOrEmpty(thumb.Images?.GetValueOrDefault(_imageIndex)))
|
|
||||||
// return null;
|
|
||||||
// string type = target is ICustomTypeDescriptor descriptor
|
|
||||||
// ? descriptor.GetClassName()
|
|
||||||
// : target.GetType().Name;
|
|
||||||
// return $"/{type}/{slug}/{Images.ImageName[_imageIndex]}".ToLowerInvariant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,6 +231,10 @@ namespace Kyoo.Postgresql
|
|||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Episode>()
|
||||||
|
.Ignore(x => x.PreviousEpisode)
|
||||||
|
.Ignore(x => x.NextEpisode);
|
||||||
|
|
||||||
modelBuilder.Entity<PeopleRole>()
|
modelBuilder.Entity<PeopleRole>()
|
||||||
.Ignore(x => x.ForPeople);
|
.Ignore(x => x.ForPeople);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user