mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fixing small issues
This commit is contained in:
parent
adb6bdb3f2
commit
9b6aa68472
@ -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.23</PackageVersion>
|
<PackageVersion>1.0.24</PackageVersion>
|
||||||
<IncludeSymbols>true</IncludeSymbols>
|
<IncludeSymbols>true</IncludeSymbols>
|
||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
<LangVersion>default</LangVersion>
|
<LangVersion>default</LangVersion>
|
||||||
|
@ -91,18 +91,18 @@ namespace Kyoo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<T> MergeLists<T>(IEnumerable<T> first,
|
public static T[] MergeLists<T>(IEnumerable<T> first,
|
||||||
IEnumerable<T> second,
|
IEnumerable<T> second,
|
||||||
Func<T, T, bool> isEqual = null)
|
Func<T, T, bool> isEqual = null)
|
||||||
{
|
{
|
||||||
if (first == null)
|
if (first == null)
|
||||||
return second;
|
return second.ToArray();
|
||||||
if (second == null)
|
if (second == null)
|
||||||
return first;
|
return first.ToArray();
|
||||||
if (isEqual == null)
|
if (isEqual == null)
|
||||||
return first.Concat(second).ToList();
|
return first.Concat(second).ToArray();
|
||||||
List<T> list = first.ToList();
|
List<T> list = first.ToList();
|
||||||
return list.Concat(second.Where(x => !list.Any(y => isEqual(x, y))));
|
return list.Concat(second.Where(x => !list.Any(y => isEqual(x, y)))).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T Assign<T>(T first, T second)
|
public static T Assign<T>(T first, T second)
|
||||||
@ -183,7 +183,7 @@ namespace Kyoo
|
|||||||
{
|
{
|
||||||
property.SetValue(first, RunGenericMethod<object>(
|
property.SetValue(first, RunGenericMethod<object>(
|
||||||
typeof(Utility),
|
typeof(Utility),
|
||||||
"MergeLists",
|
nameof(MergeLists),
|
||||||
GetEnumerableType(property.PropertyType),
|
GetEnumerableType(property.PropertyType),
|
||||||
oldValue, newValue, null));
|
oldValue, newValue, null));
|
||||||
}
|
}
|
||||||
@ -384,18 +384,21 @@ namespace Kyoo
|
|||||||
.IfEmpty(() => throw new NullReferenceException($"A method named {name} with " +
|
.IfEmpty(() => throw new NullReferenceException($"A method named {name} with " +
|
||||||
$"{args.Length} arguments and {generics.Length} generic " +
|
$"{args.Length} arguments and {generics.Length} generic " +
|
||||||
$"types could not be found on {type.Name}."))
|
$"types could not be found on {type.Name}."))
|
||||||
.Where(x =>
|
// TODO this won't work but I don't know why.
|
||||||
{
|
// .Where(x =>
|
||||||
int i = 0;
|
// {
|
||||||
return x.GetGenericArguments().All(y => y.IsAssignableFrom(generics[i++]));
|
// int i = 0;
|
||||||
})
|
// return x.GetGenericArguments().All(y => y.IsAssignableFrom(generics[i++]));
|
||||||
.IfEmpty(() => throw new NullReferenceException($"No method {name} match the generics specified."))
|
// })
|
||||||
.Where(x =>
|
// .IfEmpty(() => throw new NullReferenceException($"No method {name} match the generics specified."))
|
||||||
{
|
|
||||||
int i = 0;
|
// TODO this won't work for Type<T> because T is specified in arguments but not in the parameters type.
|
||||||
return x.GetParameters().All(y => y.ParameterType == args[i++].GetType());
|
// .Where(x =>
|
||||||
})
|
// {
|
||||||
.IfEmpty(() => throw new NullReferenceException($"No method {name} match the parameters's types."))
|
// int i = 0;
|
||||||
|
// return x.GetParameters().All(y => y.ParameterType.IsInstanceOfType(args[i++]));
|
||||||
|
// })
|
||||||
|
// .IfEmpty(() => throw new NullReferenceException($"No method {name} match the parameters's types."))
|
||||||
.Take(2)
|
.Take(2)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
@ -10,14 +10,12 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
public class ThumbnailsManager : IThumbnailsManager
|
public class ThumbnailsManager : IThumbnailsManager
|
||||||
{
|
{
|
||||||
private readonly IConfiguration _config;
|
|
||||||
private readonly IFileManager _files;
|
private readonly IFileManager _files;
|
||||||
private readonly string _peoplePath;
|
private readonly string _peoplePath;
|
||||||
private readonly string _providerPath;
|
private readonly string _providerPath;
|
||||||
|
|
||||||
public ThumbnailsManager(IConfiguration configuration, IFileManager files)
|
public ThumbnailsManager(IConfiguration configuration, IFileManager files)
|
||||||
{
|
{
|
||||||
_config = configuration;
|
|
||||||
_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"));
|
||||||
@ -67,10 +65,9 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
if (people == null)
|
if (people == null)
|
||||||
throw new ArgumentNullException(nameof(people));
|
throw new ArgumentNullException(nameof(people));
|
||||||
string root = _config.GetValue<string>("peoplePath");
|
if (people.Poster == null)
|
||||||
string localPath = Path.Combine(root, people.Slug + ".jpg");
|
return;
|
||||||
|
string localPath = await GetPeoplePoster(people);
|
||||||
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}");
|
||||||
}
|
}
|
||||||
@ -100,10 +97,7 @@ namespace Kyoo.Controllers
|
|||||||
if (provider.Logo == null)
|
if (provider.Logo == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string root = _config.GetValue<string>("providerPath");
|
string localPath = await GetProviderLogo(provider);
|
||||||
string localPath = Path.Combine(root, provider.Slug + ".jpg");
|
|
||||||
|
|
||||||
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}");
|
||||||
}
|
}
|
||||||
@ -157,9 +151,7 @@ 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}.png"));
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user