From 5f98484b4ae642c1d999babef38f027750ad7e77 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 16 Jul 2021 18:58:11 +0200 Subject: [PATCH] Reworking the thumbnail manager --- Kyoo.Common/Controllers/IFileManager.cs | 14 + Kyoo.Common/Controllers/IThumbnailsManager.cs | 62 +++- Kyoo/Controllers/FileManager.cs | 15 + Kyoo/Controllers/ThumbnailsManager.cs | 277 ++++++++++++------ Kyoo/Tasks/RegisterEpisode.cs | 120 ++++---- Kyoo/Views/EpisodeApi.cs | 10 +- Kyoo/Views/PeopleApi.cs | 4 +- Kyoo/Views/ProviderApi.cs | 4 +- Kyoo/Views/SeasonApi.cs | 12 +- Kyoo/Views/ShowApi.cs | 7 +- 10 files changed, 349 insertions(+), 176 deletions(-) diff --git a/Kyoo.Common/Controllers/IFileManager.cs b/Kyoo.Common/Controllers/IFileManager.cs index 33d1dd76..d39cff6e 100644 --- a/Kyoo.Common/Controllers/IFileManager.cs +++ b/Kyoo.Common/Controllers/IFileManager.cs @@ -50,6 +50,20 @@ namespace Kyoo.Controllers /// A writer to write to the new file. public Stream NewFile([NotNull] string path); + /// + /// Create a new directory at the given path + /// + /// The path of the directory + /// The path of the newly created directory is returned. + public Task CreateDirectory([NotNull] string path); + + /// + /// Combine multiple paths. + /// + /// The paths to combine + /// The combined path. + public string Combine(params string[] paths); + /// /// List files in a directory. /// diff --git a/Kyoo.Common/Controllers/IThumbnailsManager.cs b/Kyoo.Common/Controllers/IThumbnailsManager.cs index ee31498a..465d4c62 100644 --- a/Kyoo.Common/Controllers/IThumbnailsManager.cs +++ b/Kyoo.Common/Controllers/IThumbnailsManager.cs @@ -1,23 +1,59 @@ -using Kyoo.Models; +using System; +using Kyoo.Models; using System.Threading.Tasks; using JetBrains.Annotations; namespace Kyoo.Controllers { + /// + /// Download images and retrieve the path of those images for a resource. + /// public interface IThumbnailsManager { - Task Validate(Show show, bool alwaysDownload = false); - Task Validate(Season season, bool alwaysDownload = false); - Task Validate(Episode episode, bool alwaysDownload = false); - Task Validate(People actors, bool alwaysDownload = false); - Task Validate(Provider actors, bool alwaysDownload = false); + /// + /// Download images of a specified item. + /// If no images is available to download, do nothing and silently return. + /// + /// + /// The item to cache images. + /// + /// + /// true if images should be downloaded even if they already exists locally, false otherwise. + /// + /// The type of the item + /// true if an image has been downloaded, false otherwise. + Task DownloadImages([NotNull] T item, bool alwaysDownload = false) + where T : IResource; + - Task GetShowPoster([NotNull] Show show); - Task GetShowLogo([NotNull] Show show); - Task GetShowBackdrop([NotNull] Show show); - Task GetSeasonPoster([NotNull] Season season); - Task GetEpisodeThumb([NotNull] Episode episode); - Task GetPeoplePoster([NotNull] People people); - Task GetProviderLogo([NotNull] Provider provider); + /// + /// Retrieve the local path of the poster of the given item. + /// + /// The item to retrieve the poster from. + /// The type of the item + /// If the type does not have a poster + /// The path of the poster for the given resource (it might or might not exists). + Task GetPoster([NotNull] T item) + where T : IResource; + + /// + /// Retrieve the local path of the logo of the given item. + /// + /// The item to retrieve the logo from. + /// The type of the item + /// If the type does not have a logo + /// The path of the logo for the given resource (it might or might not exists). + Task GetLogo([NotNull] T item) + where T : IResource; + + /// + /// Retrieve the local path of the thumbnail of the given item. + /// + /// The item to retrieve the thumbnail from. + /// The type of the item + /// If the type does not have a thumbnail + /// The path of the thumbnail for the given resource (it might or might not exists). + Task GetThumbnail([NotNull] T item) + where T : IResource; } } diff --git a/Kyoo/Controllers/FileManager.cs b/Kyoo/Controllers/FileManager.cs index f6669c32..bd7ee4c2 100644 --- a/Kyoo/Controllers/FileManager.cs +++ b/Kyoo/Controllers/FileManager.cs @@ -68,6 +68,21 @@ namespace Kyoo.Controllers throw new ArgumentNullException(nameof(path)); return File.Create(path); } + + /// + public Task CreateDirectory(string path) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + Directory.CreateDirectory(path); + return Task.FromResult(path); + } + + /// + public string Combine(params string[] paths) + { + return Path.Combine(paths); + } /// public Task> ListFiles(string path, SearchOption options = SearchOption.TopDirectoryOnly) diff --git a/Kyoo/Controllers/ThumbnailsManager.cs b/Kyoo/Controllers/ThumbnailsManager.cs index 1e84cef6..f76123ee 100644 --- a/Kyoo/Controllers/ThumbnailsManager.cs +++ b/Kyoo/Controllers/ThumbnailsManager.cs @@ -1,157 +1,266 @@ using Kyoo.Models; using System; using System.IO; -using System.Net; using System.Threading.Tasks; using JetBrains.Annotations; using Kyoo.Models.Options; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace Kyoo.Controllers { + /// + /// Download images and retrieve the path of those images for a resource. + /// public class ThumbnailsManager : IThumbnailsManager { + /// + /// The file manager used to download the image if the file is distant + /// private readonly IFileManager _files; + /// + /// A logger to report errors. + /// + private readonly ILogger _logger; + /// + /// The options containing the base path of people images and provider logos. + /// private readonly IOptionsMonitor _options; - public ThumbnailsManager(IFileManager files, IOptionsMonitor options) + /// + /// Create a new . + /// + /// The file manager to use. + /// A logger to report errors + /// The options to use. + public ThumbnailsManager(IFileManager files, + ILogger logger, + IOptionsMonitor options) { _files = files; + _logger = logger; _options = options; - Directory.CreateDirectory(_options.CurrentValue.PeoplePath); - Directory.CreateDirectory(_options.CurrentValue.ProviderPath); + + options.OnChange(x => + { + _files.CreateDirectory(x.PeoplePath); + _files.CreateDirectory(x.ProviderPath); + }); } - private static async Task DownloadImage(string url, string localPath, string what) + /// + public Task DownloadImages(T item, bool alwaysDownload = false) + where T : IResource { + if (item == null) + throw new ArgumentNullException(nameof(item)); + return item switch + { + Show show => _Validate(show, alwaysDownload), + Season season => _Validate(season, alwaysDownload), + Episode episode => _Validate(episode, alwaysDownload), + People people => _Validate(people, alwaysDownload), + Provider provider => _Validate(provider, alwaysDownload), + _ => Task.FromResult(false) + }; + } + + /// + /// An helper function to download an image using a . + /// + /// The distant url of the image + /// The local path of the image + /// What is currently downloaded (used for errors) + /// true if an image has been downloaded, false otherwise. + private async Task _DownloadImage(string url, string localPath, string what) + { + if (url == localPath) + return false; + try { - using WebClient client = new(); - await client.DownloadFileTaskAsync(new Uri(url), localPath); + await using Stream reader = _files.GetReader(url); + await using Stream local = _files.NewFile(localPath); + await reader.CopyToAsync(local); + return true; } - catch (WebException exception) + catch (Exception ex) { - await Console.Error.WriteLineAsync($"{what} could not be downloaded. Error: {exception.Message}."); + _logger.LogError(ex, "{What} could not be downloaded", what); + return false; } } - public async Task Validate(Show show, bool alwaysDownload) + /// + /// Download images of a specified show. + /// + /// + /// The item to cache images. + /// + /// + /// true if images should be downloaded even if they already exists locally, false otherwise. + /// + /// true if an image has been downloaded, false otherwise. + private async Task _Validate([NotNull] Show show, bool alwaysDownload) { + bool ret = false; + if (show.Poster != null) { - string posterPath = await GetShowPoster(show); - if (alwaysDownload || !File.Exists(posterPath)) - await DownloadImage(show.Poster, posterPath, $"The poster of {show.Title}"); + string posterPath = await GetPoster(show); + if (alwaysDownload || !await _files.Exists(posterPath)) + ret |= await _DownloadImage(show.Poster, posterPath, $"The poster of {show.Title}"); } if (show.Logo != null) { - string logoPath = await GetShowLogo(show); - if (alwaysDownload || !File.Exists(logoPath)) - await DownloadImage(show.Logo, logoPath, $"The logo of {show.Title}"); + string logoPath = await GetLogo(show); + if (alwaysDownload || !await _files.Exists(logoPath)) + ret |= await _DownloadImage(show.Logo, logoPath, $"The logo of {show.Title}"); } if (show.Backdrop != null) { - string backdropPath = await GetShowBackdrop(show); - if (alwaysDownload || !File.Exists(backdropPath)) - await DownloadImage(show.Backdrop, backdropPath, $"The backdrop of {show.Title}"); + string backdropPath = await GetThumbnail(show); + if (alwaysDownload || !await _files.Exists(backdropPath)) + ret |= await _DownloadImage(show.Backdrop, backdropPath, $"The backdrop of {show.Title}"); } - - foreach (PeopleRole role in show.People) - await Validate(role.People, alwaysDownload); + + return ret; } - public async Task Validate([NotNull] People people, bool alwaysDownload) + /// + /// Download images of a specified person. + /// + /// + /// The item to cache images. + /// + /// + /// true if images should be downloaded even if they already exists locally, false otherwise. + /// + /// true if an image has been downloaded, false otherwise. + private async Task _Validate([NotNull] People people, bool alwaysDownload) { if (people == null) throw new ArgumentNullException(nameof(people)); if (people.Poster == null) - return; - string localPath = await GetPeoplePoster(people); - if (alwaysDownload || !File.Exists(localPath)) - await DownloadImage(people.Poster, localPath, $"The profile picture of {people.Name}"); + return false; + string localPath = await GetPoster(people); + if (alwaysDownload || !await _files.Exists(localPath)) + return await _DownloadImage(people.Poster, localPath, $"The profile picture of {people.Name}"); + return false; } - public async Task Validate(Season season, bool alwaysDownload) + /// + /// Download images of a specified season. + /// + /// + /// The item to cache images. + /// + /// + /// true if images should be downloaded even if they already exists locally, false otherwise. + /// + /// true if an image has been downloaded, false otherwise. + private async Task _Validate([NotNull] Season season, bool alwaysDownload) { - if (season?.Show?.Path == null || season.Poster == null) - return; + if (season.Poster == null) + return false; - string localPath = await GetSeasonPoster(season); - if (alwaysDownload || !File.Exists(localPath)) - await DownloadImage(season.Poster, localPath, $"The poster of {season.Show.Title}'s season {season.SeasonNumber}"); + string localPath = await GetPoster(season); + if (alwaysDownload || !await _files.Exists(localPath)) + return await _DownloadImage(season.Poster, localPath, $"The poster of {season.Slug}"); + return false; } - public async Task Validate(Episode episode, bool alwaysDownload) + /// + /// Download images of a specified episode. + /// + /// + /// The item to cache images. + /// + /// + /// true if images should be downloaded even if they already exists locally, false otherwise. + /// + /// true if an image has been downloaded, false otherwise. + private async Task _Validate([NotNull] Episode episode, bool alwaysDownload) { - if (episode?.Path == null || episode.Thumb == null) - return; + if (episode.Thumb == null) + return false; string localPath = await GetEpisodeThumb(episode); - if (alwaysDownload || !File.Exists(localPath)) - await DownloadImage(episode.Thumb, localPath, $"The thumbnail of {episode.Slug}"); + if (alwaysDownload || !await _files.Exists(localPath)) + return await _DownloadImage(episode.Thumb, localPath, $"The thumbnail of {episode.Slug}"); + return false; } - public async Task Validate(Provider provider, bool alwaysDownload) + /// + /// Download images of a specified provider. + /// + /// + /// The item to cache images. + /// + /// + /// true if images should be downloaded even if they already exists locally, false otherwise. + /// + /// true if an image has been downloaded, false otherwise. + private async Task _Validate([NotNull] Provider provider, bool alwaysDownload) { if (provider.Logo == null) - return; + return false; - string localPath = await GetProviderLogo(provider); - if (alwaysDownload || !File.Exists(localPath)) - await DownloadImage(provider.Logo, localPath, $"The logo of {provider.Slug}"); + string localPath = await GetLogo(provider); + if (alwaysDownload || !await _files.Exists(localPath)) + return await _DownloadImage(provider.Logo, localPath, $"The logo of {provider.Slug}"); + return false; } - public Task GetShowBackdrop(Show show) + /// + public Task GetPoster(T item) + where T : IResource { - if (show?.Path == null) - throw new ArgumentNullException(nameof(show)); - return Task.FromResult(Path.Combine(_files.GetExtraDirectory(show), "backdrop.jpg")); + if (item == null) + throw new ArgumentNullException(nameof(item)); + return Task.FromResult(item switch + { + Show show => _files.Combine(_files.GetExtraDirectory(show), "poster.jpg"), + Season season => _files.Combine(_files.GetExtraDirectory(season), $"season-{season.SeasonNumber}.jpg"), + People people => _files.Combine(_options.CurrentValue.PeoplePath, $"{people.Slug}.jpg"), + _ => throw new NotSupportedException($"The type {typeof(T).Name} does not have a poster.") + }); } - public Task GetShowLogo(Show show) + /// + public Task GetThumbnail(T item) + where T : IResource { - if (show?.Path == null) - throw new ArgumentNullException(nameof(show)); - return Task.FromResult(Path.Combine(_files.GetExtraDirectory(show), "logo.png")); + if (item == null) + throw new ArgumentNullException(nameof(item)); + return item switch + { + Show show => Task.FromResult(_files.Combine(_files.GetExtraDirectory(show), "backdrop.jpg")), + Episode episode => GetEpisodeThumb(episode), + _ => throw new NotSupportedException($"The type {typeof(T).Name} does not have a thumbnail.") + }; } - public Task GetShowPoster(Show show) + private async Task GetEpisodeThumb(Episode episode) { - if (show?.Path == null) - throw new ArgumentNullException(nameof(show)); - return Task.FromResult(Path.Combine(_files.GetExtraDirectory(show), "poster.jpg")); + string dir = _files.Combine(_files.GetExtraDirectory(episode), "Thumbnails"); + await _files.CreateDirectory(dir); + return _files.Combine(dir, $"{Path.GetFileNameWithoutExtension(episode.Path)}.jpg"); } - public Task GetSeasonPoster(Season season) + /// + public Task GetLogo(T item) + where T : IResource { - if (season == null) - throw new ArgumentNullException(nameof(season)); - return Task.FromResult(Path.Combine(_files.GetExtraDirectory(season), $"season-{season.SeasonNumber}.jpg")); - } - - public Task GetEpisodeThumb(Episode episode) - { - string dir = Path.Combine(_files.GetExtraDirectory(episode), "Thumbnails"); - Directory.CreateDirectory(dir); - return Task.FromResult(Path.Combine(dir, $"{Path.GetFileNameWithoutExtension(episode.Path)}.jpg")); - } - - public Task GetPeoplePoster(People people) - { - if (people == null) - throw new ArgumentNullException(nameof(people)); - string peoplePath = _options.CurrentValue.PeoplePath; - string thumbPath = Path.GetFullPath(Path.Combine(peoplePath, $"{people.Slug}.jpg")); - return Task.FromResult(thumbPath.StartsWith(peoplePath) ? thumbPath : null); - } - - public Task GetProviderLogo(Provider provider) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - string providerPath = _options.CurrentValue.ProviderPath; - string thumbPath = Path.GetFullPath(Path.Combine(providerPath, $"{provider.Slug}.{provider.LogoExtension}")); - return Task.FromResult(thumbPath.StartsWith(providerPath) ? thumbPath : null); + if (item == null) + throw new ArgumentNullException(nameof(item)); + return Task.FromResult(item switch + { + Show show => _files.Combine(_files.GetExtraDirectory(show), "logo.png"), + Provider provider => _files.Combine(_options.CurrentValue.ProviderPath, + $"{provider.Slug}.{provider.LogoExtension}"), + _ => throw new NotSupportedException($"The type {typeof(T).Name} does not have a thumbnail.") + }); } } } diff --git a/Kyoo/Tasks/RegisterEpisode.cs b/Kyoo/Tasks/RegisterEpisode.cs index 74001792..51949675 100644 --- a/Kyoo/Tasks/RegisterEpisode.cs +++ b/Kyoo/Tasks/RegisterEpisode.cs @@ -48,6 +48,10 @@ namespace Kyoo.Tasks /// [Injected] public AProviderComposite MetadataProvider { private get; set; } /// + /// The thumbnail manager used to download images. + /// + [Injected] public IThumbnailsManager ThumbnailsManager { private get; set; } + /// /// The logger used to inform the current status to the console. /// [Injected] public ILogger Logger { private get; set; } @@ -74,8 +78,10 @@ namespace Kyoo.Tasks if (library != null) MetadataProvider.UseProviders(library.Providers); - collection = await _RegisterAndFillCollection(collection); - // show = await _RegisterAndFillShow(show); + if (collection != null) + collection.Slug ??= Utility.ToSlug(collection.Name); + collection = await _RegisterAndFill(collection); + show = await _RegisterAndFill(show); // if (isMovie) // await libraryManager!.Create(await GetMovie(show, path)); // else @@ -106,22 +112,62 @@ namespace Kyoo.Tasks } } - private async Task _RegisterAndFillCollection(Collection collection) + private async Task _RegisterAndFill(T item) + where T : class, IResource { - if (collection == null) + if (item == null || string.IsNullOrEmpty(item.Slug)) return null; - - collection.Slug ??= Utility.ToSlug(collection.Name); - if (string.IsNullOrEmpty(collection.Slug)) - return null; - - Collection existing = await LibraryManager.GetOrDefault(collection.Slug); + + T existing = await LibraryManager.GetOrDefault(item.Slug); if (existing != null) return existing; - collection = await MetadataProvider.Get(collection); - return await LibraryManager.CreateIfNotExists(collection); + item = await MetadataProvider.Get(item); + await ThumbnailsManager.DownloadImages(item); + return await LibraryManager.CreateIfNotExists(item); } + // private async Task GetShow(ILibraryManager libraryManager, + // string showTitle, + // string showPath, + // bool isMovie, + // Library library) + // { + // Show old = await libraryManager.GetOrDefault(x => x.Path == showPath); + // if (old != null) + // { + // await libraryManager.Load(old, x => x.ExternalIDs); + // return old; + // } + // + // Show show = await MetadataProvider.SearchShow(showTitle, isMovie, library); + // show.Path = showPath; + // show.People = await MetadataProvider.GetPeople(show, library); + // + // try + // { + // show = await libraryManager.Create(show); + // } + // catch (DuplicatedItemException) + // { + // old = await libraryManager.GetOrDefault(show.Slug); + // if (old != null && old.Path == showPath) + // { + // await libraryManager.Load(old, x => x.ExternalIDs); + // return old; + // } + // + // if (show.StartAir != null) + // { + // show.Slug += $"-{show.StartAir.Value.Year}"; + // await libraryManager.Create(show); + // } + // else + // throw; + // } + // await ThumbnailsManager.Validate(show); + // return show; + // } + // /* * private async Task RegisterExternalSubtitle(string path, CancellationToken token) @@ -170,56 +216,6 @@ namespace Kyoo.Tasks } } - private async Task RegisterFile(string path, string relativePath, Library library, CancellationToken token) - { - if (token.IsCancellationRequested) - return; - - - } - - private async Task GetShow(ILibraryManager libraryManager, - string showTitle, - string showPath, - bool isMovie, - Library library) - { - Show old = await libraryManager.GetOrDefault(x => x.Path == showPath); - if (old != null) - { - await libraryManager.Load(old, x => x.ExternalIDs); - return old; - } - - Show show = new();//await MetadataProvider.SearchShow(showTitle, isMovie, library); - show.Path = showPath; - // show.People = await MetadataProvider.GetPeople(show, library); - - try - { - show = await libraryManager.Create(show); - } - catch (DuplicatedItemException) - { - old = await libraryManager.GetOrDefault(show.Slug); - if (old != null && old.Path == showPath) - { - await libraryManager.Load(old, x => x.ExternalIDs); - return old; - } - - if (show.StartAir != null) - { - show.Slug += $"-{show.StartAir.Value.Year}"; - await libraryManager.Create(show); - } - else - throw; - } - await ThumbnailsManager.Validate(show); - return show; - } - private async Task GetSeason(ILibraryManager libraryManager, Show show, int seasonNumber, diff --git a/Kyoo/Views/EpisodeApi.cs b/Kyoo/Views/EpisodeApi.cs index 490d0b34..a0d92ff8 100644 --- a/Kyoo/Views/EpisodeApi.cs +++ b/Kyoo/Views/EpisodeApi.cs @@ -188,13 +188,14 @@ namespace Kyoo.Api } } - [HttpGet("{id:int}/thumb")] + [HttpGet("{id:int}/thumbnail")] + [HttpGet("{id:int}/backdrop")] public async Task GetThumb(int id) { try { Episode episode = await _libraryManager.Get(id); - return _files.FileResult(await _thumbnails.GetEpisodeThumb(episode)); + return _files.FileResult(await _thumbnails.GetThumbnail(episode)); } catch (ItemNotFoundException) { @@ -202,13 +203,14 @@ namespace Kyoo.Api } } - [HttpGet("{slug}/thumb")] + [HttpGet("{slug}/thumbnail")] + [HttpGet("{slug}/backdrop")] public async Task GetThumb(string slug) { try { Episode episode = await _libraryManager.Get(slug); - return _files.FileResult(await _thumbnails.GetEpisodeThumb(episode)); + return _files.FileResult(await _thumbnails.GetThumbnail(episode)); } catch (ItemNotFoundException) { diff --git a/Kyoo/Views/PeopleApi.cs b/Kyoo/Views/PeopleApi.cs index c421fc16..6a468272 100644 --- a/Kyoo/Views/PeopleApi.cs +++ b/Kyoo/Views/PeopleApi.cs @@ -94,7 +94,7 @@ namespace Kyoo.Api People people = await _libraryManager.GetOrDefault(id); if (people == null) return NotFound(); - return _files.FileResult(await _thumbs.GetPeoplePoster(people)); + return _files.FileResult(await _thumbs.GetPoster(people)); } [HttpGet("{slug}/poster")] @@ -103,7 +103,7 @@ namespace Kyoo.Api People people = await _libraryManager.GetOrDefault(slug); if (people == null) return NotFound(); - return _files.FileResult(await _thumbs.GetPeoplePoster(people)); + return _files.FileResult(await _thumbs.GetPoster(people)); } } } \ No newline at end of file diff --git a/Kyoo/Views/ProviderApi.cs b/Kyoo/Views/ProviderApi.cs index eac22675..ede70dec 100644 --- a/Kyoo/Views/ProviderApi.cs +++ b/Kyoo/Views/ProviderApi.cs @@ -36,7 +36,7 @@ namespace Kyoo.Api Provider provider = await _libraryManager.GetOrDefault(id); if (provider == null) return NotFound(); - return _files.FileResult(await _thumbnails.GetProviderLogo(provider)); + return _files.FileResult(await _thumbnails.GetLogo(provider)); } [HttpGet("{slug}/logo")] @@ -45,7 +45,7 @@ namespace Kyoo.Api Provider provider = await _libraryManager.GetOrDefault(slug); if (provider == null) return NotFound(); - return _files.FileResult(await _thumbnails.GetProviderLogo(provider)); + return _files.FileResult(await _thumbnails.GetLogo(provider)); } } } \ No newline at end of file diff --git a/Kyoo/Views/SeasonApi.cs b/Kyoo/Views/SeasonApi.cs index a32b0b1c..85944c6b 100644 --- a/Kyoo/Views/SeasonApi.cs +++ b/Kyoo/Views/SeasonApi.cs @@ -144,24 +144,24 @@ namespace Kyoo.Api return ret; } - [HttpGet("{id:int}/thumb")] - public async Task GetThumb(int id) + [HttpGet("{id:int}/poster")] + public async Task GetPoster(int id) { Season season = await _libraryManager.GetOrDefault(id); if (season == null) return NotFound(); await _libraryManager.Load(season, x => x.Show); - return _files.FileResult(await _thumbs.GetSeasonPoster(season)); + return _files.FileResult(await _thumbs.GetPoster(season)); } - [HttpGet("{slug}/thumb")] - public async Task GetThumb(string slug) + [HttpGet("{slug}/poster")] + public async Task GetPoster(string slug) { Season season = await _libraryManager.GetOrDefault(slug); if (season == null) return NotFound(); await _libraryManager.Load(season, x => x.Show); - return _files.FileResult(await _thumbs.GetSeasonPoster(season)); + return _files.FileResult(await _thumbs.GetPoster(season)); } } } \ No newline at end of file diff --git a/Kyoo/Views/ShowApi.cs b/Kyoo/Views/ShowApi.cs index 966aad05..605ac28e 100644 --- a/Kyoo/Views/ShowApi.cs +++ b/Kyoo/Views/ShowApi.cs @@ -417,7 +417,7 @@ namespace Kyoo.Api try { Show show = await _libraryManager.Get(slug); - return _files.FileResult(await _thumbs.GetShowPoster(show)); + return _files.FileResult(await _thumbs.GetPoster(show)); } catch (ItemNotFoundException) { @@ -431,7 +431,7 @@ namespace Kyoo.Api try { Show show = await _libraryManager.Get(slug); - return _files.FileResult(await _thumbs.GetShowLogo(show)); + return _files.FileResult(await _thumbs.GetLogo(show)); } catch (ItemNotFoundException) { @@ -440,12 +440,13 @@ namespace Kyoo.Api } [HttpGet("{slug}/backdrop")] + [HttpGet("{slug}/thumbnail")] public async Task GetBackdrop(string slug) { try { Show show = await _libraryManager.Get(slug); - return _files.FileResult(await _thumbs.GetShowBackdrop(show)); + return _files.FileResult(await _thumbs.GetThumbnail(show)); } catch (ItemNotFoundException) {