diff --git a/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj b/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj
index 1b6aee8f..8877cb95 100644
--- a/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj
+++ b/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj
@@ -20,6 +20,7 @@
+
diff --git a/Kyoo.TheTvdb/PluginTVDB.cs b/Kyoo.TheTvdb/PluginTvdb.cs
similarity index 92%
rename from Kyoo.TheTvdb/PluginTVDB.cs
rename to Kyoo.TheTvdb/PluginTvdb.cs
index ea4cab62..62fc0885 100644
--- a/Kyoo.TheTvdb/PluginTVDB.cs
+++ b/Kyoo.TheTvdb/PluginTvdb.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using Autofac;
using Kyoo.Controllers;
+using TvDbSharper;
namespace Kyoo.TheTvdb
{
@@ -35,6 +36,7 @@ namespace Kyoo.TheTvdb
///
public void Configure(ContainerBuilder builder)
{
+ builder.RegisterType().As();
builder.RegisterProvider();
}
}
diff --git a/Kyoo.TheTvdb/ProviderTVDB.cs b/Kyoo.TheTvdb/ProviderTvdb.cs
similarity index 81%
rename from Kyoo.TheTvdb/ProviderTVDB.cs
rename to Kyoo.TheTvdb/ProviderTvdb.cs
index 5497cac1..c6d57fd0 100644
--- a/Kyoo.TheTvdb/ProviderTVDB.cs
+++ b/Kyoo.TheTvdb/ProviderTvdb.cs
@@ -3,8 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
+using Kyoo.Authentication.Models;
using Kyoo.Controllers;
using Kyoo.Models;
+using Microsoft.Extensions.Options;
using TvDbSharper;
using TvDbSharper.Dto;
@@ -18,12 +20,12 @@ namespace Kyoo.TheTvdb
///
/// The internal tvdb client used to make requests.
///
- private readonly TvDbClient _client = new();
+ private readonly ITvDbClient _client;
///
/// The API key used to authenticate with the tvdb API.
///
- private readonly string _apiKey;
+ private readonly IOptions _apiKey;
///
public Provider Provider => new()
@@ -35,15 +37,24 @@ namespace Kyoo.TheTvdb
};
- public ProviderTvdb(string apiKey)
+ ///
+ /// Create a new using a tvdb client and an api key.
+ ///
+ /// The tvdb client to use
+ /// The api key
+ public ProviderTvdb(ITvDbClient client, IOptions apiKey)
{
+ _client = client;
_apiKey = apiKey;
}
+ ///
+ /// Authenticate and refresh the token of the tvdb client.
+ ///
private Task _Authenticate()
{
if (_client.Authentication.Token == null)
- return _client.Authentication.AuthenticateAsync(_apiKey);
+ return _client.Authentication.AuthenticateAsync(_apiKey.Value.ApiKey);
return _client.Authentication.RefreshTokenAsync();
}
diff --git a/Kyoo.TheTvdb/TvdbOption.cs b/Kyoo.TheTvdb/TvdbOption.cs
new file mode 100644
index 00000000..3b21ed9e
--- /dev/null
+++ b/Kyoo.TheTvdb/TvdbOption.cs
@@ -0,0 +1,18 @@
+namespace Kyoo.Authentication.Models
+{
+ ///
+ /// The option containing the api key for the tvdb.
+ ///
+ public class TvdbOption
+ {
+ ///
+ /// The path to get this option from the root configuration.
+ ///
+ public const string Path = "tvdb";
+
+ ///
+ /// The api key of the tvdb.
+ ///
+ public string ApiKey { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Kyoo/Controllers/TaskManager.cs b/Kyoo/Controllers/TaskManager.cs
index c850a516..a10875c1 100644
--- a/Kyoo/Controllers/TaskManager.cs
+++ b/Kyoo/Controllers/TaskManager.cs
@@ -144,7 +144,7 @@ namespace Kyoo.Controllers
ICollection all = task.GetParameters();
ICollection invalids = arguments.Keys
- .Where(x => all.Any(y => x != y.Name))
+ .Where(x => all.All(y => x != y.Name))
.ToArray();
if (invalids.Any())
{
diff --git a/Kyoo/CoreModule.cs b/Kyoo/CoreModule.cs
index a0dc0729..f19ba596 100644
--- a/Kyoo/CoreModule.cs
+++ b/Kyoo/CoreModule.cs
@@ -38,7 +38,9 @@ namespace Kyoo
typeof(IThumbnailsManager),
typeof(IMetadataProvider),
typeof(ITaskManager),
- typeof(ILibraryManager)
+ typeof(ILibraryManager),
+ typeof(IIdentifier),
+ typeof(AProviderComposite)
};
///
@@ -99,9 +101,14 @@ namespace Kyoo
builder.RegisterType().As().SingleInstance();
builder.RegisterType().As().SingleInstance();
builder.RegisterType().As().InstancePerLifetimeScope();
- builder.RegisterComposite().InstancePerLifetimeScope();
-
+ builder.RegisterType().As().SingleInstance();
+ builder.RegisterComposite();
+ builder.Register(x => (AProviderComposite)x.Resolve());
+
builder.RegisterTask();
+ builder.RegisterTask();
+ builder.RegisterTask();
+ builder.RegisterTask();
static bool DatabaseIsPresent(IComponentRegistryBuilder x)
=> x.IsRegistered(new TypedService(typeof(DatabaseContext)));
diff --git a/Kyoo/Models/FileExtensions.cs b/Kyoo/Models/FileExtensions.cs
index f8058a67..b42b4be2 100644
--- a/Kyoo/Models/FileExtensions.cs
+++ b/Kyoo/Models/FileExtensions.cs
@@ -4,8 +4,14 @@ using System.Linq;
namespace Kyoo.Models.Watch
{
+ ///
+ /// A static class allowing one to identify files extensions.
+ ///
public static class FileExtensions
{
+ ///
+ /// The list of known video extensions
+ ///
public static readonly string[] VideoExtensions =
{
".webm",
@@ -34,17 +40,30 @@ namespace Kyoo.Models.Watch
".3g2"
};
+ ///
+ /// Check if a file represent a video file (only by checking the extension of the file)
+ ///
+ /// The path of the file to check
+ /// true if the file is a video file, false otherwise.
public static bool IsVideo(string filePath)
{
return VideoExtensions.Contains(Path.GetExtension(filePath));
}
+ ///
+ /// The dictionary of known subtitles extensions and the name of the subtitle codec.
+ ///
public static readonly Dictionary SubtitleExtensions = new()
{
{".ass", "ass"},
{".str", "subrip"}
};
+ ///
+ /// Check if a file represent a subtitle file (only by checking the extension of the file)
+ ///
+ /// The path of the file to check
+ /// true if the file is a subtitle file, false otherwise.
public static bool IsSubtitle(string filePath)
{
return SubtitleExtensions.ContainsKey(Path.GetExtension(filePath));