Adding custom extensions for provider's logo

This commit is contained in:
Zoe Roux 2021-03-25 19:24:52 +01:00
parent 9b6aa68472
commit a620cc1818
3 changed files with 6 additions and 6 deletions

View File

@ -12,7 +12,7 @@
<Company>SDG</Company>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageVersion>1.0.24</PackageVersion>
<PackageVersion>1.0.25</PackageVersion>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<LangVersion>default</LangVersion>

View File

@ -9,7 +9,7 @@ namespace Kyoo.Models
public string Slug { get; set; }
public string Name { get; set; }
[SerializeAs("{HOST}/api/providers/{Slug}/logo")] public string Logo { get; set; }
[SerializeIgnore] public string LogoExtension { get; set; }
[LoadableRelation] public virtual ICollection<Library> Libraries { get; set; }
#if ENABLE_INTERNAL_LINKS

View File

@ -142,16 +142,16 @@ namespace Kyoo.Controllers
if (people == null)
throw new ArgumentNullException(nameof(people));
string thumbPath = Path.GetFullPath(Path.Combine(_peoplePath, $"{people.Slug}.jpg"));
if (!thumbPath.StartsWith(_peoplePath))
return Task.FromResult<string>(null);
return Task.FromResult(thumbPath);
return Task.FromResult(thumbPath.StartsWith(_peoplePath) ? thumbPath : null);
}
public Task<string> GetProviderLogo(ProviderID provider)
{
if (provider == null)
throw new ArgumentNullException(nameof(provider));
string thumbPath = Path.GetFullPath(Path.Combine(_providerPath, $"{provider.Slug}.png"));
// TODO add a image's type on the provider to allow svg here.
// TODO fix trailer display.
string thumbPath = Path.GetFullPath(Path.Combine(_providerPath, $"{provider.Slug}.{provider.LogoExtension}"));
return Task.FromResult(thumbPath.StartsWith(_providerPath) ? thumbPath : null);
}
}