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