mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-08 02:34:16 -04:00
Cleaning up the thumnail's manager
This commit is contained in:
parent
cb2c60c9ad
commit
f60f622e1d
@ -16,7 +16,6 @@ namespace Kyoo.Controllers
|
|||||||
public Task<ICollection<string>> ListFiles([NotNull] string path);
|
public Task<ICollection<string>> ListFiles([NotNull] string path);
|
||||||
|
|
||||||
public Task<bool> Exists([NotNull] string path);
|
public Task<bool> Exists([NotNull] string path);
|
||||||
// TODO replace every use of System.IO with this to allow custom paths (like uptobox://path)
|
|
||||||
// TODO find a way to handle Transmux/Transcode with this system.
|
// TODO find a way to handle Transmux/Transcode with this system.
|
||||||
|
|
||||||
public string GetExtraDirectory(Show show);
|
public string GetExtraDirectory(Show show);
|
||||||
|
@ -7,11 +7,11 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
public interface IThumbnailsManager
|
public interface IThumbnailsManager
|
||||||
{
|
{
|
||||||
Task<Show> Validate(Show show, bool alwaysDownload = false);
|
Task Validate(Show show, bool alwaysDownload = false);
|
||||||
Task<Season> Validate(Season season, bool alwaysDownload = false);
|
Task Validate(Season season, bool alwaysDownload = false);
|
||||||
Task<Episode> Validate(Episode episode, bool alwaysDownload = false);
|
Task Validate(Episode episode, bool alwaysDownload = false);
|
||||||
Task<People> Validate(People actors, bool alwaysDownload = false);
|
Task Validate(People actors, bool alwaysDownload = false);
|
||||||
Task<ProviderID> Validate(ProviderID actors, bool alwaysDownload = false);
|
Task Validate(ProviderID actors, bool alwaysDownload = false);
|
||||||
|
|
||||||
Task<string> GetShowPoster([NotNull] Show show);
|
Task<string> GetShowPoster([NotNull] Show show);
|
||||||
Task<string> GetShowLogo([NotNull] Show show);
|
Task<string> GetShowLogo([NotNull] Show show);
|
||||||
|
@ -38,7 +38,7 @@ namespace Kyoo.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Show> Validate(Show show, bool alwaysDownload)
|
public async Task Validate(Show show, bool alwaysDownload)
|
||||||
{
|
{
|
||||||
if (show.Poster != null)
|
if (show.Poster != null)
|
||||||
{
|
{
|
||||||
@ -61,11 +61,9 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
foreach (PeopleRole role in show.People)
|
foreach (PeopleRole role in show.People)
|
||||||
await Validate(role.People, alwaysDownload);
|
await Validate(role.People, alwaysDownload);
|
||||||
|
|
||||||
return show;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<People> Validate([NotNull] People people, bool alwaysDownload)
|
public async Task Validate([NotNull] People people, bool alwaysDownload)
|
||||||
{
|
{
|
||||||
if (people == null)
|
if (people == null)
|
||||||
throw new ArgumentNullException(nameof(people));
|
throw new ArgumentNullException(nameof(people));
|
||||||
@ -75,42 +73,32 @@ namespace Kyoo.Controllers
|
|||||||
Directory.CreateDirectory(root);
|
Directory.CreateDirectory(root);
|
||||||
if (alwaysDownload || !File.Exists(localPath))
|
if (alwaysDownload || !File.Exists(localPath))
|
||||||
await DownloadImage(people.Poster, localPath, $"The profile picture of {people.Name}");
|
await DownloadImage(people.Poster, localPath, $"The profile picture of {people.Name}");
|
||||||
|
|
||||||
return people;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Season> Validate(Season season, bool alwaysDownload)
|
public async Task Validate(Season season, bool alwaysDownload)
|
||||||
{
|
{
|
||||||
if (season?.Show?.Path == null)
|
if (season?.Show?.Path == null || season.Poster == null)
|
||||||
return default;
|
return;
|
||||||
|
|
||||||
if (season.Poster != null)
|
string localPath = await GetSeasonPoster(season);
|
||||||
{
|
if (alwaysDownload || !File.Exists(localPath))
|
||||||
string localPath = await GetSeasonPoster(season);
|
await DownloadImage(season.Poster, localPath, $"The poster of {season.Show.Title}'s season {season.SeasonNumber}");
|
||||||
if (alwaysDownload || !File.Exists(localPath))
|
|
||||||
await DownloadImage(season.Poster, localPath, $"The poster of {season.Show.Title}'s season {season.SeasonNumber}");
|
|
||||||
}
|
|
||||||
return season;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Episode> Validate(Episode episode, bool alwaysDownload)
|
public async Task Validate(Episode episode, bool alwaysDownload)
|
||||||
{
|
{
|
||||||
if (episode?.Path == null)
|
if (episode?.Path == null || episode.Thumb == null)
|
||||||
return default;
|
return;
|
||||||
|
|
||||||
if (episode.Thumb != null)
|
string localPath = await GetEpisodeThumb(episode);
|
||||||
{
|
if (alwaysDownload || !File.Exists(localPath))
|
||||||
string localPath = await GetEpisodeThumb(episode);
|
await DownloadImage(episode.Thumb, localPath, $"The thumbnail of {episode.Slug}");
|
||||||
if (alwaysDownload || !File.Exists(localPath))
|
|
||||||
await DownloadImage(episode.Thumb, localPath, $"The thumbnail of {episode.Slug}");
|
|
||||||
}
|
|
||||||
return episode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ProviderID> Validate(ProviderID provider, bool alwaysDownload)
|
public async Task Validate(ProviderID provider, bool alwaysDownload)
|
||||||
{
|
{
|
||||||
if (provider.Logo == null)
|
if (provider.Logo == null)
|
||||||
return provider;
|
return;
|
||||||
|
|
||||||
string root = _config.GetValue<string>("providerPath");
|
string root = _config.GetValue<string>("providerPath");
|
||||||
string localPath = Path.Combine(root, provider.Slug + ".jpg");
|
string localPath = Path.Combine(root, provider.Slug + ".jpg");
|
||||||
@ -118,7 +106,6 @@ namespace Kyoo.Controllers
|
|||||||
Directory.CreateDirectory(root);
|
Directory.CreateDirectory(root);
|
||||||
if (alwaysDownload || !File.Exists(localPath))
|
if (alwaysDownload || !File.Exists(localPath))
|
||||||
await DownloadImage(provider.Logo, localPath, $"The logo of {provider.Slug}");
|
await DownloadImage(provider.Logo, localPath, $"The logo of {provider.Slug}");
|
||||||
return provider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<string> GetShowBackdrop(Show show)
|
public Task<string> GetShowBackdrop(Show show)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user