mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 15:30:34 -04:00
CodingStlye: Fixing whitespaces
This commit is contained in:
parent
8ff2fe3965
commit
d3a03771dd
@ -7,6 +7,7 @@ trim_trailing_whitespace = true
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = tab
|
indent_size = tab
|
||||||
|
smart_tab = true
|
||||||
|
|
||||||
[{*.yaml,*.yml}]
|
[{*.yaml,*.yml}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
|
@ -6,12 +6,15 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354" />
|
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354" PrivateAssets="All" />
|
||||||
|
|
||||||
<None Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" Visible="false" />
|
<None Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" Visible="false" />
|
||||||
<None Include="$(MSBuildThisFileDirectory).editorconfig" Link="stylecop.json" Visible="false" />
|
<None Include="$(MSBuildThisFileDirectory).editorconfig" Link=".editorconfig" Visible="false" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Kyoo.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Kyoo.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<!-- <AnalysisMode>AllEnabledByDefault</AnalysisMode>-->
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -64,7 +64,7 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// <seealso cref="SA"/>
|
/// <seealso cref="SA"/>
|
||||||
virtual IEnumerable<IStartupAction> ConfigureSteps => ArraySegment<IStartupAction>.Empty;
|
virtual IEnumerable<IStartupAction> ConfigureSteps => ArraySegment<IStartupAction>.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A configure method that will be run on plugin's startup.
|
/// A configure method that will be run on plugin's startup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="builder">The autofac service container to register services.</param>
|
/// <param name="builder">The autofac service container to register services.</param>
|
||||||
|
@ -613,5 +613,5 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A repository to handle users.
|
/// A repository to handle users.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IUserRepository : IRepository<User> {}
|
public interface IUserRepository : IRepository<User> { }
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// <returns>A new parameter's value for this current parameter</returns>
|
/// <returns>A new parameter's value for this current parameter</returns>
|
||||||
public TaskParameter CreateValue(object value)
|
public TaskParameter CreateValue(object value)
|
||||||
{
|
{
|
||||||
return this with {Value = value};
|
return this with { Value = value };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -144,7 +144,7 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new, empty, <see cref="TaskParameters"/>
|
/// Create a new, empty, <see cref="TaskParameters"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TaskParameters() {}
|
public TaskParameters() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a <see cref="TaskParameters"/> with an initial parameters content
|
/// Create a <see cref="TaskParameters"/> with an initial parameters content
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Kyoo.Abstractions.Models;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Kyoo.Abstractions.Models;
|
||||||
|
|
||||||
namespace Kyoo.Abstractions.Controllers
|
namespace Kyoo.Abstractions.Controllers
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ namespace Kyoo.Abstractions.Models.Attributes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="LoadableRelationAttribute"/>.
|
/// Create a new <see cref="LoadableRelationAttribute"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LoadableRelationAttribute() {}
|
public LoadableRelationAttribute() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="LoadableRelationAttribute"/> with a baking relationID field.
|
/// Create a new <see cref="LoadableRelationAttribute"/> with a baking relationID field.
|
||||||
|
@ -6,13 +6,13 @@ namespace Kyoo.Abstractions.Models.Attributes
|
|||||||
/// Remove an property from the serialization pipeline. It will simply be skipped.
|
/// Remove an property from the serialization pipeline. It will simply be skipped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||||
public class SerializeIgnoreAttribute : Attribute {}
|
public class SerializeIgnoreAttribute : Attribute { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove a property from the deserialization pipeline. The user can't input value for this property.
|
/// Remove a property from the deserialization pipeline. The user can't input value for this property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||||
public class DeserializeIgnoreAttribute : Attribute {}
|
public class DeserializeIgnoreAttribute : Attribute { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Change the way the field is serialized. It allow one to use a string format like formatting instead of the default value.
|
/// Change the way the field is serialized. It allow one to use a string format like formatting instead of the default value.
|
||||||
|
@ -11,7 +11,7 @@ namespace Kyoo.Abstractions.Models
|
|||||||
public float StartTime { get; set; }
|
public float StartTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The end time of the chapter (in second from the start of the episode)&.
|
/// The end time of the chapter (in second from the start of the episode).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float EndTime { get; set; }
|
public float EndTime { get; set; }
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public TaskFailedException()
|
public TaskFailedException()
|
||||||
: base("A task failed.")
|
: base("A task failed.")
|
||||||
{}
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="TaskFailedException"/> with a custom message.
|
/// Create a new <see cref="TaskFailedException"/> with a custom message.
|
||||||
@ -23,7 +23,7 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
|||||||
/// <param name="message">The message to use.</param>
|
/// <param name="message">The message to use.</param>
|
||||||
public TaskFailedException(string message)
|
public TaskFailedException(string message)
|
||||||
: base(message)
|
: base(message)
|
||||||
{}
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="TaskFailedException"/> wrapping another exception.
|
/// Create a new <see cref="TaskFailedException"/> wrapping another exception.
|
||||||
@ -31,7 +31,7 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
|||||||
/// <param name="exception">The exception to wrap.</param>
|
/// <param name="exception">The exception to wrap.</param>
|
||||||
public TaskFailedException(Exception exception)
|
public TaskFailedException(Exception exception)
|
||||||
: base(exception)
|
: base(exception)
|
||||||
{}
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The serialization constructor
|
/// The serialization constructor
|
||||||
|
@ -74,7 +74,7 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new, empty <see cref="LibraryItem"/>.
|
/// Create a new, empty <see cref="LibraryItem"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LibraryItem() {}
|
public LibraryItem() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a <see cref="LibraryItem"/> from a show.
|
/// Create a <see cref="LibraryItem"/> from a show.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
@ -28,7 +28,7 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new, empty <see cref="Genre"/>.
|
/// Create a new, empty <see cref="Genre"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Genre() {}
|
public Genre() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="Genre"/> and specify it's <see cref="Name"/>.
|
/// Create a new <see cref="Genre"/> and specify it's <see cref="Name"/>.
|
||||||
|
@ -14,7 +14,8 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The link to metadata providers that this show has. See <see cref="MetadataID"/> for more information.
|
/// The link to metadata providers that this show has. See <see cref="MetadataID"/> for more information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditableRelation] [LoadableRelation]
|
[EditableRelation]
|
||||||
|
[LoadableRelation]
|
||||||
public ICollection<MetadataID> ExternalIDs { get; set; }
|
public ICollection<MetadataID> ExternalIDs { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@ -13,7 +13,7 @@ namespace Kyoo.Abstractions.Models
|
|||||||
public class Season : IResource, IMetadata, IThumbnails
|
public class Season : IResource, IMetadata, IThumbnails
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[Computed] public string Slug
|
[Computed] public string Slug
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -46,8 +46,10 @@ namespace Kyoo.Abstractions.Models
|
|||||||
@"(?<ep>[^\.]+)\.(?<lang>\w{0,3})(-(?<index>\d+))?(\.(?<forced>forced))?\.(?<type>\w+)(\.\w*)?");
|
@"(?<ep>[^\.]+)\.(?<lang>\w{0,3})(-(?<index>\d+))?(\.(?<forced>forced))?\.(?<type>\w+)(\.\w*)?");
|
||||||
|
|
||||||
if (!match.Success)
|
if (!match.Success)
|
||||||
|
{
|
||||||
throw new ArgumentException("Invalid track slug. " +
|
throw new ArgumentException("Invalid track slug. " +
|
||||||
"Format: {episodeSlug}.{language}[-{index}][.forced].{type}[.{extension}]");
|
"Format: {episodeSlug}.{language}[-{index}][.forced].{type}[.{extension}]");
|
||||||
|
}
|
||||||
|
|
||||||
EpisodeSlug = match.Groups["ep"].Value;
|
EpisodeSlug = match.Groups["ep"].Value;
|
||||||
Language = match.Groups["lang"].Value;
|
Language = match.Groups["lang"].Value;
|
||||||
@ -137,7 +139,7 @@ namespace Kyoo.Abstractions.Models
|
|||||||
name += " Forced";
|
name += " Forced";
|
||||||
if (IsExternal)
|
if (IsExternal)
|
||||||
name += " (External)";
|
name += " (External)";
|
||||||
if (Title is {Length: > 1})
|
if (Title is { Length: > 1 })
|
||||||
name += " - " + Title;
|
name += " - " + Title;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ namespace Kyoo.Utils
|
|||||||
.GenericTypeArguments
|
.GenericTypeArguments
|
||||||
.First();
|
.First();
|
||||||
Func<IResource, IResource, bool> equalityComparer = enumerableType.IsAssignableTo(typeof(IResource))
|
Func<IResource, IResource, bool> equalityComparer = enumerableType.IsAssignableTo(typeof(IResource))
|
||||||
? (x, y) => x.Slug == y.Slug
|
? (x, y) => x.Slug == y.Slug
|
||||||
: null;
|
: null;
|
||||||
property.SetValue(first, Utility.RunGenericMethod<object>(
|
property.SetValue(first, Utility.RunGenericMethod<object>(
|
||||||
typeof(Merger),
|
typeof(Merger),
|
||||||
|
@ -281,7 +281,7 @@ namespace Kyoo.Utils
|
|||||||
[NotNull] Type type,
|
[NotNull] Type type,
|
||||||
params object[] args)
|
params object[] args)
|
||||||
{
|
{
|
||||||
return RunGenericMethod<T>(owner, methodName, new[] {type}, args);
|
return RunGenericMethod<T>(owner, methodName, new[] { type }, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -361,7 +361,7 @@ namespace Kyoo.Utils
|
|||||||
[NotNull] Type type,
|
[NotNull] Type type,
|
||||||
params object[] args)
|
params object[] args)
|
||||||
{
|
{
|
||||||
return RunGenericMethod<T>(instance, methodName, new[] {type}, args);
|
return RunGenericMethod<T>(instance, methodName, new[] { type }, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@ -70,6 +71,8 @@ namespace Kyoo.Authentication
|
|||||||
/// <param name="configuration">The configuration to use</param>
|
/// <param name="configuration">The configuration to use</param>
|
||||||
/// <param name="logger">The logger used to allow IdentityServer to log things</param>
|
/// <param name="logger">The logger used to allow IdentityServer to log things</param>
|
||||||
/// <param name="environment">The environment information to check if the app runs in debug mode</param>
|
/// <param name="environment">The environment information to check if the app runs in debug mode</param>
|
||||||
|
[SuppressMessage("ReSharper", "ContextualLoggerProblem",
|
||||||
|
Justification = "The logger is used for a dependency that is not created via the container.")]
|
||||||
public AuthenticationModule(IConfiguration configuration,
|
public AuthenticationModule(IConfiguration configuration,
|
||||||
ILogger<DefaultCorsPolicyService> logger,
|
ILogger<DefaultCorsPolicyService> logger,
|
||||||
IWebHostEnvironment environment)
|
IWebHostEnvironment environment)
|
||||||
|
@ -104,7 +104,7 @@ namespace Kyoo.Authentication
|
|||||||
X509Certificate bouncyCert = certificateGenerator.Generate(signatureFactory);
|
X509Certificate bouncyCert = certificateGenerator.Generate(signatureFactory);
|
||||||
|
|
||||||
Pkcs12Store store = new Pkcs12StoreBuilder().Build();
|
Pkcs12Store store = new Pkcs12StoreBuilder().Build();
|
||||||
store.SetKeyEntry("Kyoo_key", new AsymmetricKeyEntry(subjectKeyPair.Private), new []
|
store.SetKeyEntry("Kyoo_key", new AsymmetricKeyEntry(subjectKeyPair.Private), new[]
|
||||||
{
|
{
|
||||||
new X509CertificateEntry(bouncyCert)
|
new X509CertificateEntry(bouncyCert)
|
||||||
});
|
});
|
||||||
|
@ -37,7 +37,7 @@ namespace Kyoo.Authentication
|
|||||||
return new(user.ID.ToString())
|
return new(user.ID.ToString())
|
||||||
{
|
{
|
||||||
DisplayName = user.Username,
|
DisplayName = user.Username,
|
||||||
AdditionalClaims = new[] {new Claim("permissions", string.Join(',', user.Permissions))}
|
AdditionalClaims = new[] { new Claim("permissions", string.Join(',', user.Permissions)) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,10 +78,10 @@ namespace Kyoo.Authentication.Views
|
|||||||
}
|
}
|
||||||
catch (DuplicatedItemException)
|
catch (DuplicatedItemException)
|
||||||
{
|
{
|
||||||
return Conflict(new {Errors = new {Duplicate = new[] {"A user with this name already exists"}}});
|
return Conflict(new { Errors = new { Duplicate = new[] { "A user with this name already exists" } } });
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(new {Otac = user.ExtraData["otac"]});
|
return Ok(new { Otac = user.ExtraData["otac"] });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -127,15 +127,16 @@ namespace Kyoo.Authentication.Views
|
|||||||
{
|
{
|
||||||
// TODO once hstore (Dictionary<string, string> accessor) are supported, use them.
|
// TODO once hstore (Dictionary<string, string> accessor) are supported, use them.
|
||||||
// We retrieve all users, this is inefficient.
|
// We retrieve all users, this is inefficient.
|
||||||
User user = (await _users.GetAll()).FirstOrDefault(x => x.ExtraData.GetValueOrDefault("otac") == otac.Otac);
|
User user = (await _users.GetAll()).FirstOrDefault(x => x.ExtraData.GetValueOrDefault("otac") == otac.Otac);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
if (DateTime.ParseExact(user.ExtraData["otac-expire"], "s", CultureInfo.InvariantCulture) <=
|
if (DateTime.ParseExact(user.ExtraData["otac-expire"], "s", CultureInfo.InvariantCulture) <=
|
||||||
DateTime.UtcNow)
|
DateTime.UtcNow)
|
||||||
{
|
{
|
||||||
return BadRequest(new
|
return BadRequest(new
|
||||||
{
|
{
|
||||||
code = "ExpiredOTAC", description = "The OTAC has expired. Try to login with your password."
|
code = "ExpiredOTAC",
|
||||||
|
description = "The OTAC has expired. Try to login with your password."
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ namespace Kyoo.Core.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="IFileSystem"/> for http/https links.
|
/// A <see cref="IFileSystem"/> for http/https links.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[FileSystemMetadata(new [] {"http", "https"})]
|
[FileSystemMetadata(new[] { "http", "https" })]
|
||||||
public class HttpFileSystem : IFileSystem
|
public class HttpFileSystem : IFileSystem
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -15,7 +15,7 @@ namespace Kyoo.Core.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="IFileSystem"/> for the local filesystem (using System.IO).
|
/// A <see cref="IFileSystem"/> for the local filesystem (using System.IO).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[FileSystemMetadata(new [] {"", "file"}, StripScheme = true)]
|
[FileSystemMetadata(new[] { "", "file" }, StripScheme = true)]
|
||||||
public class LocalFileSystem : IFileSystem
|
public class LocalFileSystem : IFileSystem
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -278,7 +278,7 @@ namespace Kyoo.Core.Controllers
|
|||||||
{
|
{
|
||||||
MethodInfo setter = typeof(T).GetProperty(nameof(resource.Slug))!.GetSetMethod();
|
MethodInfo setter = typeof(T).GetProperty(nameof(resource.Slug))!.GetSetMethod();
|
||||||
if (setter != null)
|
if (setter != null)
|
||||||
setter.Invoke(resource, new object[] {resource.Slug + '!'});
|
setter.Invoke(resource, new object[] { resource.Slug + '!' });
|
||||||
else
|
else
|
||||||
throw new ArgumentException("Resources slug can't be number only.");
|
throw new ArgumentException("Resources slug can't be number only.");
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ using Stream = Kyoo.Core.Models.Watch.Stream;
|
|||||||
|
|
||||||
namespace Kyoo.Core.Controllers
|
namespace Kyoo.Core.Controllers
|
||||||
{
|
{
|
||||||
public class BadTranscoderException : Exception {}
|
public class BadTranscoderException : Exception { }
|
||||||
|
|
||||||
public class Transcoder : ITranscoder
|
public class Transcoder : ITranscoder
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ namespace Kyoo.Core.Models.Watch
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The dictionary of known subtitles extensions and the name of the subtitle codec.
|
/// The dictionary of known subtitles extensions and the name of the subtitle codec.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly ImmutableDictionary<string, string> SubtitleExtensions = new Dictionary<string, string>
|
public static readonly ImmutableDictionary<string, string> SubtitleExtensions = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{".ass", "ass"},
|
{".ass", "ass"},
|
||||||
{".str", "subrip"}
|
{".str", "subrip"}
|
||||||
|
@ -69,7 +69,7 @@ namespace Kyoo.Core.Tasks
|
|||||||
string argument = arguments["slug"].As<string>();
|
string argument = arguments["slug"].As<string>();
|
||||||
ICollection<Library> libraries = argument == null
|
ICollection<Library> libraries = argument == null
|
||||||
? await _libraryManager.GetAll<Library>()
|
? await _libraryManager.GetAll<Library>()
|
||||||
: new [] { await _libraryManager.GetOrDefault<Library>(argument)};
|
: new[] { await _libraryManager.GetOrDefault<Library>(argument) };
|
||||||
|
|
||||||
if (argument != null && libraries.First() == null)
|
if (argument != null && libraries.First() == null)
|
||||||
throw new ArgumentException($"No library found with the name {argument}");
|
throw new ArgumentException($"No library found with the name {argument}");
|
||||||
|
@ -55,7 +55,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace Kyoo.Core.Api
|
|||||||
[PartialPermission(Kind.Read)]
|
[PartialPermission(Kind.Read)]
|
||||||
public async Task<ActionResult<Show>> GetShow(int episodeID)
|
public async Task<ActionResult<Show>> GetShow(int episodeID)
|
||||||
{
|
{
|
||||||
Show ret = await _libraryManager.GetOrDefault<Show>(x => x.Episodes.Any(y => y.ID == episodeID));
|
Show ret = await _libraryManager.GetOrDefault<Show>(x => x.Episodes.Any(y => y.ID == episodeID));
|
||||||
if (ret == null)
|
if (ret == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
return ret;
|
return ret;
|
||||||
@ -123,7 +123,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
catch (DuplicatedItemException)
|
catch (DuplicatedItemException)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ namespace Kyoo.Core.Api
|
|||||||
if (result.Value != null)
|
if (result.Value != null)
|
||||||
_taskManager.StartTask("scan",
|
_taskManager.StartTask("scan",
|
||||||
new Progress<float>(),
|
new Progress<float>(),
|
||||||
new Dictionary<string, object> {{"slug", result.Value.Slug}});
|
new Dictionary<string, object> { { "slug", result.Value.Slug } });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +370,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new { Error = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,19 +304,19 @@ namespace Kyoo.Database
|
|||||||
.HasIndex(x => x.Slug)
|
.HasIndex(x => x.Slug)
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
modelBuilder.Entity<Season>()
|
modelBuilder.Entity<Season>()
|
||||||
.HasIndex(x => new {x.ShowID, x.SeasonNumber})
|
.HasIndex(x => new { x.ShowID, x.SeasonNumber })
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
modelBuilder.Entity<Season>()
|
modelBuilder.Entity<Season>()
|
||||||
.HasIndex(x => x.Slug)
|
.HasIndex(x => x.Slug)
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
modelBuilder.Entity<Episode>()
|
modelBuilder.Entity<Episode>()
|
||||||
.HasIndex(x => new {x.ShowID, x.SeasonNumber, x.EpisodeNumber, x.AbsoluteNumber})
|
.HasIndex(x => new { x.ShowID, x.SeasonNumber, x.EpisodeNumber, x.AbsoluteNumber })
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
modelBuilder.Entity<Episode>()
|
modelBuilder.Entity<Episode>()
|
||||||
.HasIndex(x => x.Slug)
|
.HasIndex(x => x.Slug)
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
modelBuilder.Entity<Track>()
|
modelBuilder.Entity<Track>()
|
||||||
.HasIndex(x => new {x.EpisodeID, x.Type, x.Language, x.TrackIndex, x.IsForced})
|
.HasIndex(x => new { x.EpisodeID, x.Type, x.Language, x.TrackIndex, x.IsForced })
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
modelBuilder.Entity<Track>()
|
modelBuilder.Entity<Track>()
|
||||||
.HasIndex(x => x.Slug)
|
.HasIndex(x => x.Slug)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
@ -6,7 +6,6 @@
|
|||||||
<RootNamespace>Kyoo.Database</RootNamespace>
|
<RootNamespace>Kyoo.Database</RootNamespace>
|
||||||
<Authors>Zoe Roux</Authors>
|
<Authors>Zoe Roux</Authors>
|
||||||
<RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl>
|
<RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl>
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<LangVersion>default</LangVersion>
|
<LangVersion>default</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -155,7 +155,7 @@ namespace Kyoo.Postgresql
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override bool IsDuplicateException(Exception ex)
|
protected override bool IsDuplicateException(Exception ex)
|
||||||
{
|
{
|
||||||
return ex.InnerException is PostgresException {SqlState: PostgresErrorCodes.UniqueViolation};
|
return ex.InnerException is PostgresException { SqlState: PostgresErrorCodes.UniqueViolation };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -32,7 +32,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new []
|
ExternalIDs = new[]
|
||||||
{
|
{
|
||||||
new MetadataID
|
new MetadataID
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new []
|
ExternalIDs = new[]
|
||||||
{
|
{
|
||||||
new MetadataID
|
new MetadataID
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
? $"https://image.tmdb.org/t/p/original{episode.StillPath}"
|
? $"https://image.tmdb.org/t/p/original{episode.StillPath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new []
|
ExternalIDs = new[]
|
||||||
{
|
{
|
||||||
new MetadataID
|
new MetadataID
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
.Select(x => x.ToPeople(provider))
|
.Select(x => x.ToPeople(provider))
|
||||||
.Concat(movie.Credits.Crew.Select(x => x.ToPeople(provider)))
|
.Concat(movie.Credits.Crew.Select(x => x.ToPeople(provider)))
|
||||||
.ToArray(),
|
.ToArray(),
|
||||||
ExternalIDs = new []
|
ExternalIDs = new[]
|
||||||
{
|
{
|
||||||
new MetadataID
|
new MetadataID
|
||||||
{
|
{
|
||||||
@ -87,7 +87,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
IsMovie = true,
|
IsMovie = true,
|
||||||
ExternalIDs = new []
|
ExternalIDs = new[]
|
||||||
{
|
{
|
||||||
new MetadataID
|
new MetadataID
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
? $"https://image.tmdb.org/t/p/original{season.PosterPath}"
|
? $"https://image.tmdb.org/t/p/original{season.PosterPath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new []
|
ExternalIDs = new[]
|
||||||
{
|
{
|
||||||
new MetadataID
|
new MetadataID
|
||||||
{
|
{
|
||||||
|
@ -110,8 +110,8 @@ namespace Kyoo.TheTvdb
|
|||||||
if (!int.TryParse(episode.Show?.GetID(Provider.Slug), out int id))
|
if (!int.TryParse(episode.Show?.GetID(Provider.Slug), out int id))
|
||||||
return null;
|
return null;
|
||||||
EpisodeQuery query = episode.AbsoluteNumber != null
|
EpisodeQuery query = episode.AbsoluteNumber != null
|
||||||
? new EpisodeQuery {AbsoluteNumber = episode.AbsoluteNumber}
|
? new EpisodeQuery { AbsoluteNumber = episode.AbsoluteNumber }
|
||||||
: new EpisodeQuery {AiredSeason = episode.SeasonNumber, AiredEpisode = episode.EpisodeNumber};
|
: new EpisodeQuery { AiredSeason = episode.SeasonNumber, AiredEpisode = episode.EpisodeNumber };
|
||||||
TvDbResponse<EpisodeRecord[]> episodes = await _client.Series.GetEpisodesAsync(id, 0, query);
|
TvDbResponse<EpisodeRecord[]> episodes = await _client.Series.GetEpisodesAsync(id, 0, query);
|
||||||
return episodes.Data.FirstOrDefault()?.ToEpisode(Provider);
|
return episodes.Data.FirstOrDefault()?.ToEpisode(Provider);
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,10 @@ namespace Kyoo.WebApp
|
|||||||
public WebAppModule(ILogger<WebAppModule> logger)
|
public WebAppModule(ILogger<WebAppModule> logger)
|
||||||
{
|
{
|
||||||
if (!Enabled)
|
if (!Enabled)
|
||||||
|
{
|
||||||
logger.LogError("The web app files could not be found, it will be disabled. " +
|
logger.LogError("The web app files could not be found, it will be disabled. " +
|
||||||
"If you cloned the project, you probably forgot to use the --recurse flag");
|
"If you cloned the project, you probably forgot to use the --recurse flag");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -10,9 +10,14 @@
|
|||||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.ReadabilityRules">
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.ReadabilityRules">
|
||||||
<Rule Id="SA1101" Action="None" /> <!-- PrefixLocalCallsWithThis -->
|
<Rule Id="SA1101" Action="None" /> <!-- PrefixLocalCallsWithThis -->
|
||||||
<Rule Id="SX1101" Action="Warning" /> <!-- DoNotPrefixLocalMembersWithThis -->
|
<Rule Id="SX1101" Action="Warning" /> <!-- DoNotPrefixLocalMembersWithThis -->
|
||||||
|
<Rule Id="SA1134" Action="None" /> <!-- AttributesMustNotShareLine -->
|
||||||
</Rules>
|
</Rules>
|
||||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.SpacingRules">
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.SpacingRules">
|
||||||
<Rule Id="SA1502" Action="None"/> <!-- DocumentationLinesMustBeginWithSingleSpace -->
|
<Rule Id="SA1502" Action="None"/> <!-- DocumentationLinesMustBeginWithSingleSpace -->
|
||||||
|
</Rules>
|
||||||
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.LayoutRules">
|
||||||
|
<Rule Id="SA1503" Action="None"/> <!-- BracesMustNotBeOmitted -->
|
||||||
|
<Rule Id="SA1520" Action="None"/> <!-- UseBracesConsistently -->
|
||||||
</Rules>
|
</Rules>
|
||||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.DocumentationRules">
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.DocumentationRules">
|
||||||
<Rule Id="SA1642" Action="None" /> <!-- ConstructorSummaryDocumentationMustBeginWithStandardText -->
|
<Rule Id="SA1642" Action="None" /> <!-- ConstructorSummaryDocumentationMustBeginWithStandardText -->
|
||||||
|
@ -131,7 +131,7 @@ namespace Kyoo.Tests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task EditNonExistingTest()
|
public async Task EditNonExistingTest()
|
||||||
{
|
{
|
||||||
await Assert.ThrowsAsync<ItemNotFoundException>(() => _repository.Edit(new T {ID = 56}, false));
|
await Assert.ThrowsAsync<ItemNotFoundException>(() => _repository.Edit(new T { ID = 56 }, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -90,7 +90,7 @@ namespace Kyoo.Tests.Database
|
|||||||
public async Task EditTest()
|
public async Task EditTest()
|
||||||
{
|
{
|
||||||
Library value = await _repository.Get(TestSample.Get<Library>().Slug);
|
Library value = await _repository.Get(TestSample.Get<Library>().Slug);
|
||||||
value.Paths = new [] {"/super", "/test"};
|
value.Paths = new[] { "/super", "/test" };
|
||||||
value.Name = "New Title";
|
value.Name = "New Title";
|
||||||
Library edited = await _repository.Edit(value, false);
|
Library edited = await _repository.Edit(value, false);
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ namespace Kyoo.Tests.Database
|
|||||||
{
|
{
|
||||||
Slug = "super-test",
|
Slug = "super-test",
|
||||||
Name = "This is a test title",
|
Name = "This is a test title",
|
||||||
Paths = new [] {"path"}
|
Paths = new[] { "path" }
|
||||||
};
|
};
|
||||||
await _repository.Create(value);
|
await _repository.Create(value);
|
||||||
ICollection<Library> ret = await _repository.Search(query);
|
ICollection<Library> ret = await _repository.Search(query);
|
||||||
|
@ -13,7 +13,7 @@ namespace Kyoo.Tests.Database
|
|||||||
|
|
||||||
public GlobalTests(ITestOutputHelper output)
|
public GlobalTests(ITestOutputHelper output)
|
||||||
{
|
{
|
||||||
_repositories = new RepositoryActivator(output);
|
_repositories = new RepositoryActivator(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -61,11 +61,11 @@ namespace Kyoo.Tests.Database
|
|||||||
public async Task EditGenreTest()
|
public async Task EditGenreTest()
|
||||||
{
|
{
|
||||||
Show value = await _repository.Get(TestSample.Get<Show>().Slug);
|
Show value = await _repository.Get(TestSample.Get<Show>().Slug);
|
||||||
value.Genres = new[] {new Genre("test")};
|
value.Genres = new[] { new Genre("test") };
|
||||||
Show edited = await _repository.Edit(value, false);
|
Show edited = await _repository.Edit(value, false);
|
||||||
|
|
||||||
Assert.Equal(value.Slug, edited.Slug);
|
Assert.Equal(value.Slug, edited.Slug);
|
||||||
Assert.Equal(value.Genres.Select(x => new{x.Slug, x.Name}), edited.Genres.Select(x => new{x.Slug, x.Name}));
|
Assert.Equal(value.Genres.Select(x => new { x.Slug, x.Name }), edited.Genres.Select(x => new { x.Slug, x.Name }));
|
||||||
|
|
||||||
await using DatabaseContext database = Repositories.Context.New();
|
await using DatabaseContext database = Repositories.Context.New();
|
||||||
Show show = await database.Shows
|
Show show = await database.Shows
|
||||||
@ -73,7 +73,7 @@ namespace Kyoo.Tests.Database
|
|||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
|
|
||||||
Assert.Equal(value.Slug, show.Slug);
|
Assert.Equal(value.Slug, show.Slug);
|
||||||
Assert.Equal(value.Genres.Select(x => new{x.Slug, x.Name}), show.Genres.Select(x => new{x.Slug, x.Name}));
|
Assert.Equal(value.Genres.Select(x => new { x.Slug, x.Name }), show.Genres.Select(x => new { x.Slug, x.Name }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -85,7 +85,7 @@ namespace Kyoo.Tests.Database
|
|||||||
Show edited = await _repository.Edit(value, false);
|
Show edited = await _repository.Edit(value, false);
|
||||||
|
|
||||||
Assert.Equal(value.Slug, edited.Slug);
|
Assert.Equal(value.Slug, edited.Slug);
|
||||||
Assert.Equal(value.Genres.Select(x => new{x.Slug, x.Name}), edited.Genres.Select(x => new{x.Slug, x.Name}));
|
Assert.Equal(value.Genres.Select(x => new { x.Slug, x.Name }), edited.Genres.Select(x => new { x.Slug, x.Name }));
|
||||||
|
|
||||||
await using DatabaseContext database = Repositories.Context.New();
|
await using DatabaseContext database = Repositories.Context.New();
|
||||||
Show show = await database.Shows
|
Show show = await database.Shows
|
||||||
@ -93,7 +93,7 @@ namespace Kyoo.Tests.Database
|
|||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
|
|
||||||
Assert.Equal(value.Slug, show.Slug);
|
Assert.Equal(value.Slug, show.Slug);
|
||||||
Assert.Equal(value.Genres.Select(x => new{x.Slug, x.Name}), show.Genres.Select(x => new{x.Slug, x.Name}));
|
Assert.Equal(value.Genres.Select(x => new { x.Slug, x.Name }), show.Genres.Select(x => new { x.Slug, x.Name }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -119,7 +119,7 @@ namespace Kyoo.Tests.Database
|
|||||||
public async Task EditAliasesTest()
|
public async Task EditAliasesTest()
|
||||||
{
|
{
|
||||||
Show value = await _repository.Get(TestSample.Get<Show>().Slug);
|
Show value = await _repository.Get(TestSample.Get<Show>().Slug);
|
||||||
value.Aliases = new[] {"NiceNewAlias", "SecondAlias"};
|
value.Aliases = new[] { "NiceNewAlias", "SecondAlias" };
|
||||||
Show edited = await _repository.Edit(value, false);
|
Show edited = await _repository.Edit(value, false);
|
||||||
|
|
||||||
Assert.Equal(value.Slug, edited.Slug);
|
Assert.Equal(value.Slug, edited.Slug);
|
||||||
@ -152,8 +152,8 @@ namespace Kyoo.Tests.Database
|
|||||||
Assert.Equal(value.Slug, edited.Slug);
|
Assert.Equal(value.Slug, edited.Slug);
|
||||||
Assert.Equal(edited.People.First().ShowID, value.ID);
|
Assert.Equal(edited.People.First().ShowID, value.ID);
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
value.People.Select(x => new{x.Role, x.Slug, x.People.Name}),
|
value.People.Select(x => new { x.Role, x.Slug, x.People.Name }),
|
||||||
edited.People.Select(x => new{x.Role, x.Slug, x.People.Name}));
|
edited.People.Select(x => new { x.Role, x.Slug, x.People.Name }));
|
||||||
|
|
||||||
await using DatabaseContext database = Repositories.Context.New();
|
await using DatabaseContext database = Repositories.Context.New();
|
||||||
Show show = await database.Shows
|
Show show = await database.Shows
|
||||||
@ -163,8 +163,8 @@ namespace Kyoo.Tests.Database
|
|||||||
|
|
||||||
Assert.Equal(value.Slug, show.Slug);
|
Assert.Equal(value.Slug, show.Slug);
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
value.People.Select(x => new{x.Role, x.Slug, x.People.Name}),
|
value.People.Select(x => new { x.Role, x.Slug, x.People.Name }),
|
||||||
show.People.Select(x => new{x.Role, x.Slug, x.People.Name}));
|
show.People.Select(x => new { x.Role, x.Slug, x.People.Name }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -183,8 +183,8 @@ namespace Kyoo.Tests.Database
|
|||||||
|
|
||||||
Assert.Equal(value.Slug, edited.Slug);
|
Assert.Equal(value.Slug, edited.Slug);
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
value.ExternalIDs.Select(x => new {x.DataID, x.Provider.Slug}),
|
value.ExternalIDs.Select(x => new { x.DataID, x.Provider.Slug }),
|
||||||
edited.ExternalIDs.Select(x => new {x.DataID, x.Provider.Slug}));
|
edited.ExternalIDs.Select(x => new { x.DataID, x.Provider.Slug }));
|
||||||
|
|
||||||
await using DatabaseContext database = Repositories.Context.New();
|
await using DatabaseContext database = Repositories.Context.New();
|
||||||
Show show = await database.Shows
|
Show show = await database.Shows
|
||||||
@ -194,8 +194,8 @@ namespace Kyoo.Tests.Database
|
|||||||
|
|
||||||
Assert.Equal(value.Slug, show.Slug);
|
Assert.Equal(value.Slug, show.Slug);
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
value.ExternalIDs.Select(x => new {x.DataID, x.Provider.Slug}),
|
value.ExternalIDs.Select(x => new { x.DataID, x.Provider.Slug }),
|
||||||
show.ExternalIDs.Select(x => new {x.DataID, x.Provider.Slug}));
|
show.ExternalIDs.Select(x => new { x.DataID, x.Provider.Slug }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -63,7 +63,7 @@ namespace Kyoo.Tests
|
|||||||
|
|
||||||
[CollectionDefinition(nameof(Postgresql))]
|
[CollectionDefinition(nameof(Postgresql))]
|
||||||
public class PostgresCollection : ICollectionFixture<PostgresFixture>
|
public class PostgresCollection : ICollectionFixture<PostgresFixture>
|
||||||
{}
|
{ }
|
||||||
|
|
||||||
public sealed class PostgresFixture : IDisposable
|
public sealed class PostgresFixture : IDisposable
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ namespace Kyoo.Tests
|
|||||||
ID = 2,
|
ID = 2,
|
||||||
Slug = "new-library",
|
Slug = "new-library",
|
||||||
Name = "New Library",
|
Name = "New Library",
|
||||||
Paths = new [] {"/a/random/path"}
|
Paths = new[] { "/a/random/path" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -132,7 +132,7 @@ namespace Kyoo.Tests
|
|||||||
ID = 1,
|
ID = 1,
|
||||||
Slug = "deck",
|
Slug = "deck",
|
||||||
Name = "Deck",
|
Name = "Deck",
|
||||||
Paths = new[] {"/path/to/deck"}
|
Paths = new[] { "/path/to/deck" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -190,7 +190,7 @@ namespace Kyoo.Tests
|
|||||||
Title = "Season 1",
|
Title = "Season 1",
|
||||||
Overview = "The first season",
|
Overview = "The first season",
|
||||||
StartDate = new DateTime(2020, 06, 05),
|
StartDate = new DateTime(2020, 06, 05),
|
||||||
EndDate = new DateTime(2020, 07, 05),
|
EndDate = new DateTime(2020, 07, 05),
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = "Poster",
|
[Images.Poster] = "Poster",
|
||||||
@ -297,7 +297,7 @@ namespace Kyoo.Tests
|
|||||||
Username = "User",
|
Username = "User",
|
||||||
Email = "user@im-a-user.com",
|
Email = "user@im-a-user.com",
|
||||||
Password = "MD5-encoded",
|
Password = "MD5-encoded",
|
||||||
Permissions = new [] {"overall.read"}
|
Permissions = new[] { "overall.read" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -345,12 +345,12 @@ namespace Kyoo.Tests
|
|||||||
|
|
||||||
Studio studio = Get<Studio>();
|
Studio studio = Get<Studio>();
|
||||||
studio.ID = 0;
|
studio.ID = 0;
|
||||||
studio.Shows = new List<Show> {show};
|
studio.Shows = new List<Show> { show };
|
||||||
context.Studios.Add(studio);
|
context.Studios.Add(studio);
|
||||||
|
|
||||||
Genre genre = Get<Genre>();
|
Genre genre = Get<Genre>();
|
||||||
genre.ID = 0;
|
genre.ID = 0;
|
||||||
genre.Shows = new List<Show> {show};
|
genre.Shows = new List<Show> { show };
|
||||||
context.Genres.Add(genre);
|
context.Genres.Add(genre);
|
||||||
|
|
||||||
People people = Get<People>();
|
People people = Get<People>();
|
||||||
@ -363,8 +363,8 @@ namespace Kyoo.Tests
|
|||||||
|
|
||||||
Library library = Get<Library>();
|
Library library = Get<Library>();
|
||||||
library.ID = 0;
|
library.ID = 0;
|
||||||
library.Collections = new List<Collection> {collection};
|
library.Collections = new List<Collection> { collection };
|
||||||
library.Providers = new List<Provider> {provider};
|
library.Providers = new List<Provider> { provider };
|
||||||
context.Libraries.Add(library);
|
context.Libraries.Add(library);
|
||||||
|
|
||||||
User user = Get<User>();
|
User user = Get<User>();
|
||||||
|
@ -20,7 +20,7 @@ namespace Kyoo.Tests.Identifier
|
|||||||
Mock<IOptionsMonitor<MediaOptions>> options = new();
|
Mock<IOptionsMonitor<MediaOptions>> options = new();
|
||||||
options.Setup(x => x.CurrentValue).Returns(new MediaOptions
|
options.Setup(x => x.CurrentValue).Returns(new MediaOptions
|
||||||
{
|
{
|
||||||
Regex = new []
|
Regex = new[]
|
||||||
{
|
{
|
||||||
"^\\/?(?<Collection>.+)?\\/(?<Show>.+?)(?: \\((?<StartYear>\\d+)\\))?\\/\\k<Show>(?: \\(\\d+\\))? S(?<Season>\\d+)E(?<Episode>\\d+)\\..*$",
|
"^\\/?(?<Collection>.+)?\\/(?<Show>.+?)(?: \\((?<StartYear>\\d+)\\))?\\/\\k<Show>(?: \\(\\d+\\))? S(?<Season>\\d+)E(?<Episode>\\d+)\\..*$",
|
||||||
"^\\/?(?<Collection>.+)?\\/(?<Show>.+?)(?: \\((?<StartYear>\\d+)\\))?\\/\\k<Show>(?: \\(\\d+\\))? (?<Absolute>\\d+)\\..*$",
|
"^\\/?(?<Collection>.+)?\\/(?<Show>.+?)(?: \\((?<StartYear>\\d+)\\))?\\/\\k<Show>(?: \\(\\d+\\))? (?<Absolute>\\d+)\\..*$",
|
||||||
|
@ -60,9 +60,9 @@ namespace Kyoo.Tests.Identifier
|
|||||||
mock.Setup(x => x.Get(show)).ReturnsAsync(new Show
|
mock.Setup(x => x.Get(show)).ReturnsAsync(new Show
|
||||||
{
|
{
|
||||||
Title = "title",
|
Title = "title",
|
||||||
Genres = new[] { new Genre("ToMerge")}
|
Genres = new[] { new Genre("ToMerge") }
|
||||||
});
|
});
|
||||||
AProviderComposite provider = new ProviderComposite(new []
|
AProviderComposite provider = new ProviderComposite(new[]
|
||||||
{
|
{
|
||||||
mock.Object
|
mock.Object
|
||||||
},
|
},
|
||||||
@ -89,7 +89,7 @@ namespace Kyoo.Tests.Identifier
|
|||||||
mock.Setup(x => x.Get(show)).ReturnsAsync(new Show
|
mock.Setup(x => x.Get(show)).ReturnsAsync(new Show
|
||||||
{
|
{
|
||||||
Title = "title",
|
Title = "title",
|
||||||
Genres = new[] { new Genre("ToMerge")}
|
Genres = new[] { new Genre("ToMerge") }
|
||||||
});
|
});
|
||||||
|
|
||||||
Mock<IMetadataProvider> mockTwo = new();
|
Mock<IMetadataProvider> mockTwo = new();
|
||||||
@ -98,14 +98,14 @@ namespace Kyoo.Tests.Identifier
|
|||||||
{
|
{
|
||||||
Title = "title2",
|
Title = "title2",
|
||||||
Status = Status.Finished,
|
Status = Status.Finished,
|
||||||
Genres = new[] { new Genre("ToMerge")}
|
Genres = new[] { new Genre("ToMerge") }
|
||||||
});
|
});
|
||||||
|
|
||||||
Mock<IMetadataProvider> mockFailing = new();
|
Mock<IMetadataProvider> mockFailing = new();
|
||||||
mockFailing.Setup(x => x.Provider).Returns(new Provider("mockFail", ""));
|
mockFailing.Setup(x => x.Provider).Returns(new Provider("mockFail", ""));
|
||||||
mockFailing.Setup(x => x.Get(show)).Throws<ArgumentException>();
|
mockFailing.Setup(x => x.Get(show)).Throws<ArgumentException>();
|
||||||
|
|
||||||
AProviderComposite provider = new ProviderComposite(new []
|
AProviderComposite provider = new ProviderComposite(new[]
|
||||||
{
|
{
|
||||||
mock.Object,
|
mock.Object,
|
||||||
mockTwo.Object,
|
mockTwo.Object,
|
||||||
|
@ -85,7 +85,7 @@ namespace Kyoo.Tests.Identifier.Tvdb
|
|||||||
Poster = "poster",
|
Poster = "poster",
|
||||||
FanArt = "fanart",
|
FanArt = "fanart",
|
||||||
Id = 5,
|
Id = 5,
|
||||||
Genre = new []
|
Genre = new[]
|
||||||
{
|
{
|
||||||
"Action",
|
"Action",
|
||||||
"Test With Spéàacial characters"
|
"Test With Spéàacial characters"
|
||||||
|
@ -12,7 +12,7 @@ namespace Kyoo.Tests.Utility
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void MapTest()
|
public void MapTest()
|
||||||
{
|
{
|
||||||
int[] list = {1, 2, 3, 4};
|
int[] list = { 1, 2, 3, 4 };
|
||||||
Assert.All(list.Map((x, i) => (x, i)), x => Assert.Equal(x.x - 1, x.i));
|
Assert.All(list.Map((x, i) => (x, i)), x => Assert.Equal(x.x - 1, x.i));
|
||||||
Assert.Throws<ArgumentNullException>(() => list.Map(((Func<int, int, int>)null)!));
|
Assert.Throws<ArgumentNullException>(() => list.Map(((Func<int, int, int>)null)!));
|
||||||
list = null;
|
list = null;
|
||||||
@ -22,8 +22,8 @@ namespace Kyoo.Tests.Utility
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task MapAsyncTest()
|
public async Task MapAsyncTest()
|
||||||
{
|
{
|
||||||
int[] list = {1, 2, 3, 4};
|
int[] list = { 1, 2, 3, 4 };
|
||||||
await foreach((int x, int i) in list.MapAsync((x, i) => Task.FromResult((x, i))))
|
await foreach ((int x, int i) in list.MapAsync((x, i) => Task.FromResult((x, i))))
|
||||||
{
|
{
|
||||||
Assert.Equal(x - 1, i);
|
Assert.Equal(x - 1, i);
|
||||||
}
|
}
|
||||||
@ -35,9 +35,9 @@ namespace Kyoo.Tests.Utility
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task SelectAsyncTest()
|
public async Task SelectAsyncTest()
|
||||||
{
|
{
|
||||||
int[] list = {1, 2, 3, 4};
|
int[] list = { 1, 2, 3, 4 };
|
||||||
int i = 2;
|
int i = 2;
|
||||||
await foreach(int x in list.SelectAsync(x => Task.FromResult(x + 1)))
|
await foreach (int x in list.SelectAsync(x => Task.FromResult(x + 1)))
|
||||||
{
|
{
|
||||||
Assert.Equal(i++, x);
|
Assert.Equal(i++, x);
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ namespace Kyoo.Tests.Utility
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task ToListAsyncTest()
|
public async Task ToListAsyncTest()
|
||||||
{
|
{
|
||||||
int[] expected = {1, 2, 3, 4};
|
int[] expected = { 1, 2, 3, 4 };
|
||||||
IAsyncEnumerable<int> list = expected.SelectAsync(Task.FromResult);
|
IAsyncEnumerable<int> list = expected.SelectAsync(Task.FromResult);
|
||||||
Assert.Equal(expected, await list.ToListAsync());
|
Assert.Equal(expected, await list.ToListAsync());
|
||||||
list = null;
|
list = null;
|
||||||
@ -59,14 +59,14 @@ namespace Kyoo.Tests.Utility
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void IfEmptyTest()
|
public void IfEmptyTest()
|
||||||
{
|
{
|
||||||
int[] list = {1, 2, 3, 4};
|
int[] list = { 1, 2, 3, 4 };
|
||||||
list = list.IfEmpty(() => KAssert.Fail("Empty action should not be triggered.")).ToArray();
|
list = list.IfEmpty(() => KAssert.Fail("Empty action should not be triggered.")).ToArray();
|
||||||
Assert.Throws<ArgumentNullException>(() => list.IfEmpty(null!).ToList());
|
Assert.Throws<ArgumentNullException>(() => list.IfEmpty(null!).ToList());
|
||||||
list = null;
|
list = null;
|
||||||
Assert.Throws<ArgumentNullException>(() => list!.IfEmpty(() => {}).ToList());
|
Assert.Throws<ArgumentNullException>(() => list!.IfEmpty(() => { }).ToList());
|
||||||
list = Array.Empty<int>();
|
list = Array.Empty<int>();
|
||||||
Assert.Throws<ArgumentException>(() => list.IfEmpty(() => throw new ArgumentException()).ToList());
|
Assert.Throws<ArgumentException>(() => list.IfEmpty(() => throw new ArgumentException()).ToList());
|
||||||
Assert.Empty(list.IfEmpty(() => {}));
|
Assert.Empty(list.IfEmpty(() => { }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -95,11 +95,11 @@ namespace Kyoo.Tests.Utility
|
|||||||
Test test = new()
|
Test test = new()
|
||||||
{
|
{
|
||||||
ID = 5,
|
ID = 5,
|
||||||
Numbers = new [] { 1 }
|
Numbers = new[] { 1 }
|
||||||
};
|
};
|
||||||
Test test2 = new()
|
Test test2 = new()
|
||||||
{
|
{
|
||||||
Numbers = new [] { 3 }
|
Numbers = new[] { 3 }
|
||||||
};
|
};
|
||||||
Test ret = Merger.Merge(test, test2);
|
Test ret = Merger.Merge(test, test2);
|
||||||
Assert.True(ReferenceEquals(test, ret));
|
Assert.True(ReferenceEquals(test, ret));
|
||||||
@ -116,11 +116,11 @@ namespace Kyoo.Tests.Utility
|
|||||||
Test test = new()
|
Test test = new()
|
||||||
{
|
{
|
||||||
ID = 5,
|
ID = 5,
|
||||||
Numbers = new [] { 1 }
|
Numbers = new[] { 1 }
|
||||||
};
|
};
|
||||||
Test test2 = new()
|
Test test2 = new()
|
||||||
{
|
{
|
||||||
Numbers = new []
|
Numbers = new[]
|
||||||
{
|
{
|
||||||
1,
|
1,
|
||||||
3,
|
3,
|
||||||
@ -206,11 +206,11 @@ namespace Kyoo.Tests.Utility
|
|||||||
Show test = new()
|
Show test = new()
|
||||||
{
|
{
|
||||||
ID = 5,
|
ID = 5,
|
||||||
Genres = new [] { new Genre("test") }
|
Genres = new[] { new Genre("test") }
|
||||||
};
|
};
|
||||||
Show test2 = new()
|
Show test2 = new()
|
||||||
{
|
{
|
||||||
Genres = new []
|
Genres = new[]
|
||||||
{
|
{
|
||||||
new Genre("test"),
|
new Genre("test"),
|
||||||
new Genre("test2")
|
new Genre("test2")
|
||||||
@ -410,7 +410,8 @@ namespace Kyoo.Tests.Utility
|
|||||||
{
|
{
|
||||||
public Dictionary<int, int> Backing;
|
public Dictionary<int, int> Backing;
|
||||||
|
|
||||||
[UsedImplicitly] public Dictionary<int, int> Dictionary
|
[UsedImplicitly]
|
||||||
|
public Dictionary<int, int> Dictionary
|
||||||
{
|
{
|
||||||
get => Backing;
|
get => Backing;
|
||||||
set
|
set
|
||||||
|
@ -21,7 +21,7 @@ namespace Kyoo.Tests.Utility
|
|||||||
await Assert.ThrowsAsync<ArgumentException>(() => Task.FromResult(1)
|
await Assert.ThrowsAsync<ArgumentException>(() => Task.FromResult(1)
|
||||||
.Then(_ => throw new ArgumentException()));
|
.Then(_ => throw new ArgumentException()));
|
||||||
Assert.Equal(1, await Task.FromResult(1)
|
Assert.Equal(1, await Task.FromResult(1)
|
||||||
.Then(_ => {}));
|
.Then(_ => { }));
|
||||||
|
|
||||||
static async Task<int> Faulted()
|
static async Task<int> Faulted()
|
||||||
{
|
{
|
||||||
@ -39,7 +39,7 @@ namespace Kyoo.Tests.Utility
|
|||||||
CancellationTokenSource token = new();
|
CancellationTokenSource token = new();
|
||||||
token.Cancel();
|
token.Cancel();
|
||||||
await Assert.ThrowsAsync<TaskCanceledException>(() => Task.Run(Infinite, token.Token)
|
await Assert.ThrowsAsync<TaskCanceledException>(() => Task.Run(Infinite, token.Token)
|
||||||
.Then(_ => {}));
|
.Then(_ => { }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -53,7 +53,7 @@ namespace Kyoo.Tests.Utility
|
|||||||
Assert.Throws<ArgumentException>(() => KUtility.GetMethod(typeof(UtilityTests),
|
Assert.Throws<ArgumentException>(() => KUtility.GetMethod(typeof(UtilityTests),
|
||||||
BindingFlags.Instance | BindingFlags.Public,
|
BindingFlags.Instance | BindingFlags.Public,
|
||||||
nameof(GetMethodTest),
|
nameof(GetMethodTest),
|
||||||
new [] { typeof(KUtility) },
|
new[] { typeof(KUtility) },
|
||||||
Array.Empty<object>()));
|
Array.Empty<object>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ namespace Kyoo.Tests.Utility
|
|||||||
MethodInfo method = KUtility.GetMethod(typeof(Merger),
|
MethodInfo method = KUtility.GetMethod(typeof(Merger),
|
||||||
BindingFlags.Static | BindingFlags.Public,
|
BindingFlags.Static | BindingFlags.Public,
|
||||||
nameof(Merger.MergeLists),
|
nameof(Merger.MergeLists),
|
||||||
new [] { typeof(string) },
|
new[] { typeof(string) },
|
||||||
new object[] { "string", "string2", null });
|
new object[] { "string", "string2", null });
|
||||||
Assert.Equal(nameof(Merger.MergeLists), method.Name);
|
Assert.Equal(nameof(Merger.MergeLists), method.Name);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user