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> <Company>SDG</Company>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression> <PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageVersion>1.0.24</PackageVersion> <PackageVersion>1.0.25</PackageVersion>
<IncludeSymbols>true</IncludeSymbols> <IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat> <SymbolPackageFormat>snupkg</SymbolPackageFormat>
<LangVersion>default</LangVersion> <LangVersion>default</LangVersion>

View File

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

View File

@ -142,16 +142,16 @@ 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)) return Task.FromResult(thumbPath.StartsWith(_peoplePath) ? thumbPath : null);
return Task.FromResult<string>(null);
return Task.FromResult(thumbPath);
} }
public Task<string> GetProviderLogo(ProviderID provider) public Task<string> GetProviderLogo(ProviderID provider)
{ {
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}.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); return Task.FromResult(thumbPath.StartsWith(_providerPath) ? thumbPath : null);
} }
} }