Fixing people & epiosode thumbnails

This commit is contained in:
Zoe Roux 2021-03-24 01:46:00 +01:00
parent 1ad84174f2
commit cb2c60c9ad
2 changed files with 9 additions and 6 deletions

View File

@ -21,6 +21,8 @@ namespace Kyoo.Controllers
_files = files; _files = files;
_peoplePath = Path.GetFullPath(configuration.GetValue<string>("peoplePath")); _peoplePath = Path.GetFullPath(configuration.GetValue<string>("peoplePath"));
_providerPath = Path.GetFullPath(configuration.GetValue<string>("providerPath")); _providerPath = Path.GetFullPath(configuration.GetValue<string>("providerPath"));
Directory.CreateDirectory(_peoplePath);
Directory.CreateDirectory(_providerPath);
} }
private static async Task DownloadImage(string url, string localPath, string what) private static async Task DownloadImage(string url, string localPath, string what)
@ -149,10 +151,9 @@ namespace Kyoo.Controllers
public Task<string> GetEpisodeThumb(Episode episode) public Task<string> GetEpisodeThumb(Episode episode)
{ {
return Task.FromResult(Path.Combine( string dir = Path.Combine(_files.GetExtraDirectory(episode), "Thumbnails");
_files.GetExtraDirectory(episode), Directory.CreateDirectory(dir);
"Thumbnails", return Task.FromResult(Path.Combine(dir, $"{Path.GetFileNameWithoutExtension(episode.Path)}.jpg"));
$"{Path.GetFileNameWithoutExtension(episode.Path)}.jpg"));
} }
public Task<string> GetPeoplePoster(People people) public Task<string> GetPeoplePoster(People people)
@ -160,7 +161,7 @@ namespace Kyoo.Controllers
if (people == null) if (people == null)
throw new ArgumentNullException(nameof(people)); throw new ArgumentNullException(nameof(people));
string thumbPath = Path.GetFullPath(Path.Combine(_peoplePath, $"{people.Slug}.jpg")); string thumbPath = Path.GetFullPath(Path.Combine(_peoplePath, $"{people.Slug}.jpg"));
if (!thumbPath.StartsWith(_peoplePath) || File.Exists(thumbPath)) if (!thumbPath.StartsWith(_peoplePath))
return Task.FromResult<string>(null); return Task.FromResult<string>(null);
return Task.FromResult(thumbPath); return Task.FromResult(thumbPath);
} }
@ -170,6 +171,8 @@ namespace Kyoo.Controllers
if (provider == null) if (provider == null)
throw new ArgumentNullException(nameof(provider)); throw new ArgumentNullException(nameof(provider));
string thumbPath = Path.GetFullPath(Path.Combine(_providerPath, $"{provider.Slug}.jpg")); string thumbPath = Path.GetFullPath(Path.Combine(_providerPath, $"{provider.Slug}.jpg"));
if (!thumbPath.StartsWith(_providerPath))
return Task.FromResult<string>(null);
return Task.FromResult(thumbPath.StartsWith(_providerPath) ? thumbPath : null); return Task.FromResult(thumbPath.StartsWith(_providerPath) ? thumbPath : null);
} }
} }

@ -1 +1 @@
Subproject commit a8a576bdd9e0c69fbae8e5e4f392c112fe3af8a2 Subproject commit ab52f039021928cab9f6ed8c17a0488ca198ef74