mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix thumbnails for episodse
This commit is contained in:
parent
5ddfe1ddb2
commit
70466aba7e
@ -44,8 +44,9 @@ namespace Kyoo.Core.Controllers
|
||||
/// Create a new <see cref="CollectionRepository"/>.
|
||||
/// </summary>
|
||||
/// <param name="database">The database handle to use</param>
|
||||
public CollectionRepository(DatabaseContext database)
|
||||
: base(database)
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public CollectionRepository(DatabaseContext database, IThumbnailsManager thumbs)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
@ -54,9 +54,11 @@ namespace Kyoo.Core.Controllers
|
||||
/// </summary>
|
||||
/// <param name="database">The database handle to use.</param>
|
||||
/// <param name="shows">A show repository</param>
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public EpisodeRepository(DatabaseContext database,
|
||||
IShowRepository shows)
|
||||
: base(database)
|
||||
IShowRepository shows,
|
||||
IThumbnailsManager thumbs)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
_shows = shows;
|
||||
@ -144,8 +146,8 @@ namespace Kyoo.Core.Controllers
|
||||
/// <inheritdoc />
|
||||
public override async Task<Episode> Create(Episode obj)
|
||||
{
|
||||
await base.Create(obj);
|
||||
obj.ShowSlug = obj.Show?.Slug ?? _database.Shows.First(x => x.Id == obj.ShowId).Slug;
|
||||
await base.Create(obj);
|
||||
_database.Entry(obj).State = EntityState.Added;
|
||||
await _database.SaveChangesAsync(() =>
|
||||
obj.SeasonNumber != null && obj.EpisodeNumber != null
|
||||
|
@ -46,8 +46,9 @@ namespace Kyoo.Core.Controllers
|
||||
/// Create a new <see cref="ILibraryItemRepository"/>.
|
||||
/// </summary>
|
||||
/// <param name="database">The database instance</param>
|
||||
public LibraryItemRepository(DatabaseContext database)
|
||||
: base(database)
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public LibraryItemRepository(DatabaseContext database, IThumbnailsManager thumbs)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ namespace Kyoo.Core.Controllers
|
||||
/// </summary>
|
||||
protected DbContext Database { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The thumbnail manager used to store images.
|
||||
/// </summary>
|
||||
private readonly IThumbnailsManager _thumbs;
|
||||
|
||||
/// <summary>
|
||||
/// The default sort order that will be used for this resource's type.
|
||||
/// </summary>
|
||||
@ -54,9 +59,11 @@ namespace Kyoo.Core.Controllers
|
||||
/// Create a new base <see cref="LocalRepository{T}"/> with the given database handle.
|
||||
/// </summary>
|
||||
/// <param name="database">A database connection to load resources of type <typeparamref name="T"/></param>
|
||||
protected LocalRepository(DbContext database)
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
protected LocalRepository(DbContext database, IThumbnailsManager thumbs)
|
||||
{
|
||||
Database = database;
|
||||
_thumbs = thumbs;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@ -365,6 +372,7 @@ namespace Kyoo.Core.Controllers
|
||||
await Validate(obj);
|
||||
if (obj is IThumbnails thumbs)
|
||||
{
|
||||
await _thumbs.DownloadImages(thumbs);
|
||||
if (thumbs.Poster != null)
|
||||
Database.Entry(thumbs).Reference(x => x.Poster).TargetEntry.State = EntityState.Added;
|
||||
if (thumbs.Thumbnail != null)
|
||||
|
@ -55,10 +55,12 @@ namespace Kyoo.Core.Controllers
|
||||
/// <param name="database">The database handle to use</param>
|
||||
/// <param name="studios">A studio repository</param>
|
||||
/// <param name="people">A people repository</param>
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public MovieRepository(DatabaseContext database,
|
||||
IStudioRepository studios,
|
||||
IPeopleRepository people)
|
||||
: base(database)
|
||||
IPeopleRepository people,
|
||||
IThumbnailsManager thumbs)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
_studios = studios;
|
||||
|
@ -52,9 +52,11 @@ namespace Kyoo.Core.Controllers
|
||||
/// </summary>
|
||||
/// <param name="database">The database handle</param>
|
||||
/// <param name="shows">A lazy loaded show repository</param>
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public PeopleRepository(DatabaseContext database,
|
||||
Lazy<IShowRepository> shows)
|
||||
: base(database)
|
||||
Lazy<IShowRepository> shows,
|
||||
IThumbnailsManager thumbs)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
_shows = shows;
|
||||
|
@ -47,9 +47,11 @@ namespace Kyoo.Core.Controllers
|
||||
/// </summary>
|
||||
/// <param name="database">The database handle that will be used</param>
|
||||
/// <param name="shows">A shows repository</param>
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public SeasonRepository(DatabaseContext database,
|
||||
IShowRepository shows)
|
||||
: base(database)
|
||||
IShowRepository shows,
|
||||
IThumbnailsManager thumbs)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
|
||||
|
@ -56,10 +56,12 @@ namespace Kyoo.Core.Controllers
|
||||
/// <param name="database">The database handle to use</param>
|
||||
/// <param name="studios">A studio repository</param>
|
||||
/// <param name="people">A people repository</param>
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public ShowRepository(DatabaseContext database,
|
||||
IStudioRepository studios,
|
||||
IPeopleRepository people)
|
||||
: base(database)
|
||||
IPeopleRepository people,
|
||||
IThumbnailsManager thumbs)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
_studios = studios;
|
||||
|
@ -44,8 +44,9 @@ namespace Kyoo.Core.Controllers
|
||||
/// Create a new <see cref="StudioRepository"/>.
|
||||
/// </summary>
|
||||
/// <param name="database">The database handle</param>
|
||||
public StudioRepository(DatabaseContext database)
|
||||
: base(database)
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public StudioRepository(DatabaseContext database, IThumbnailsManager thumbs)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
@ -43,8 +43,9 @@ namespace Kyoo.Core.Controllers
|
||||
/// Create a new <see cref="UserRepository"/>
|
||||
/// </summary>
|
||||
/// <param name="database">The database handle to use</param>
|
||||
public UserRepository(DatabaseContext database)
|
||||
: base(database)
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public UserRepository(DatabaseContext database, IThumbnailsManager thumbs)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace Kyoo.Core.Controllers
|
||||
{
|
||||
string directory = item switch
|
||||
{
|
||||
IResource res => Path.Combine("./metadata", typeof(T).Name.ToLowerInvariant(), res.Slug),
|
||||
IResource res => Path.Combine("./metadata", item.GetType().Name.ToLowerInvariant(), res.Slug),
|
||||
_ => Path.Combine("./metadata", typeof(T).Name.ToLowerInvariant())
|
||||
};
|
||||
Directory.CreateDirectory(directory);
|
||||
|
@ -131,12 +131,5 @@ namespace Kyoo.Core.Api
|
||||
{
|
||||
return _GetImage(identifier, "thumbnail", quality);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task<ActionResult<T>> Create([FromBody] T resource)
|
||||
{
|
||||
await _thumbs.DownloadImages(resource);
|
||||
return await base.Create(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,6 @@ export const Image = ({
|
||||
<div
|
||||
style={{
|
||||
// To reproduce view's behavior
|
||||
position: "relative",
|
||||
boxSizing: "border-box",
|
||||
overflow: "hidden",
|
||||
|
||||
@ -82,7 +81,7 @@ export const Image = ({
|
||||
backgroundRepeat: "no-repeat",
|
||||
backgroundPosition: "50% 50%",
|
||||
}}
|
||||
{...wCss([layout as any, { ...border, borderRadius: "6px" }], {
|
||||
{...wCss([layout as any, { ...border, borderRadius: "6px", position: "relative" }], {
|
||||
// Gather classnames from props (to support parent's hover for example).
|
||||
className: extractClassNames(props),
|
||||
})}
|
||||
|
@ -220,6 +220,7 @@ const VideoPoster = ({ poster }: { poster?: KyooImage | null }) => {
|
||||
>
|
||||
<Poster
|
||||
src={poster}
|
||||
quality="low"
|
||||
layout={{ width: percent(100) }}
|
||||
{...css({ position: "absolute", bottom: 0 })}
|
||||
/>
|
||||
|
@ -75,7 +75,7 @@ const mapData = (
|
||||
name: data.type === "movie" ? data.name : `${episodeDisplayNumber(data, "")} ${data.name}`,
|
||||
showName: data.type === "movie" ? data.name! : data.show!.name,
|
||||
href: data ? (data.type === "movie" ? `/movie/${data.slug}` : `/show/${data.show!.slug}`) : "#",
|
||||
poster: data.poster,
|
||||
poster: data.type === "movie" ? data.poster : data.show!.poster,
|
||||
subtitles: info.subtitles,
|
||||
chapters: info.chapters,
|
||||
fonts: info.fonts,
|
||||
|
Loading…
x
Reference in New Issue
Block a user