diff --git a/Kyoo.Common/Models/Resources/Show.cs b/Kyoo.Common/Models/Resources/Show.cs
index c9d5ca8e..bddc6920 100644
--- a/Kyoo.Common/Models/Resources/Show.cs
+++ b/Kyoo.Common/Models/Resources/Show.cs
@@ -43,7 +43,7 @@ namespace Kyoo.Models
///
/// Is this show airing, not aired yet or finished?
///
- public Status? Status { get; set; }
+ public Status Status { get; set; }
///
/// An URL to a trailer. This could be any path supported by the .
diff --git a/Kyoo.CommonAPI/LocalRepository.cs b/Kyoo.CommonAPI/LocalRepository.cs
index 8ab23443..0187e0dd 100644
--- a/Kyoo.CommonAPI/LocalRepository.cs
+++ b/Kyoo.CommonAPI/LocalRepository.cs
@@ -208,7 +208,7 @@ namespace Kyoo.Controllers
}
catch (DuplicatedItemException)
{
- return await GetOrDefault(obj.Slug);
+ return await Get(obj.Slug);
}
}
diff --git a/Kyoo.Tests/Database/TestSample.cs b/Kyoo.Tests/Database/TestSample.cs
index 96cd63c1..e0ff955f 100644
--- a/Kyoo.Tests/Database/TestSample.cs
+++ b/Kyoo.Tests/Database/TestSample.cs
@@ -233,7 +233,7 @@ namespace Kyoo.Tests
provider.ID = 0;
context.Providers.Add(provider);
- Models.Library library = Get();
+ Library library = Get();
library.ID = 0;
library.Collections = new List {collection};
library.Providers = new List {provider};
diff --git a/Kyoo.Tests/Identifier/Tvdb/ConvertorTests.cs b/Kyoo.Tests/Identifier/Tvdb/ConvertorTests.cs
new file mode 100644
index 00000000..35e389b6
--- /dev/null
+++ b/Kyoo.Tests/Identifier/Tvdb/ConvertorTests.cs
@@ -0,0 +1,160 @@
+using System;
+using System.Linq;
+using Kyoo.Models;
+using Kyoo.TheTvdb;
+using TvDbSharper.Dto;
+using Xunit;
+
+namespace Kyoo.Tests.Identifier.Tvdb
+{
+ public class ConvertorTests
+ {
+ [Fact]
+ public void SeriesSearchToShow()
+ {
+ SeriesSearchResult result = new()
+ {
+ Slug = "slug",
+ SeriesName = "name",
+ Aliases = new[] { "Aliases" },
+ Overview = "overview",
+ Status = "Ended",
+ FirstAired = "2021-07-23",
+ Poster = "/poster",
+ Id = 5
+ };
+ Provider provider = TestSample.Get();
+ Show show = result.ToShow(provider);
+
+ Assert.Equal("slug", show.Slug);
+ Assert.Equal("name", show.Title);
+ Assert.Single(show.Aliases);
+ Assert.Equal("Aliases", show.Aliases[0]);
+ Assert.Equal("overview", show.Overview);
+ Assert.Equal(new DateTime(2021, 7, 23), show.StartAir);
+ Assert.Equal("https://www.thetvdb.com/poster", show.Poster);
+ Assert.Single(show.ExternalIDs);
+ Assert.Equal("5", show.ExternalIDs.First().DataID);
+ Assert.Equal(provider, show.ExternalIDs.First().Provider);
+ Assert.Equal("https://www.thetvdb.com/series/slug", show.ExternalIDs.First().Link);
+ Assert.Equal(Status.Finished, show.Status);
+ }
+
+ [Fact]
+ public void SeriesSearchToShowInvalidDate()
+ {
+ SeriesSearchResult result = new()
+ {
+ Slug = "slug",
+ SeriesName = "name",
+ Aliases = new[] { "Aliases" },
+ Overview = "overview",
+ Status = "ad",
+ FirstAired = "2e021-07-23",
+ Poster = "/poster",
+ Id = 5
+ };
+ Provider provider = TestSample.Get();
+ Show show = result.ToShow(provider);
+
+ Assert.Equal("slug", show.Slug);
+ Assert.Equal("name", show.Title);
+ Assert.Single(show.Aliases);
+ Assert.Equal("Aliases", show.Aliases[0]);
+ Assert.Equal("overview", show.Overview);
+ Assert.Null(show.StartAir);
+ Assert.Equal("https://www.thetvdb.com/poster", show.Poster);
+ Assert.Single(show.ExternalIDs);
+ Assert.Equal("5", show.ExternalIDs.First().DataID);
+ Assert.Equal(provider, show.ExternalIDs.First().Provider);
+ Assert.Equal("https://www.thetvdb.com/series/slug", show.ExternalIDs.First().Link);
+ Assert.Equal(Status.Unknown, show.Status);
+ }
+
+ [Fact]
+ public void SeriesToShow()
+ {
+ Series result = new()
+ {
+ Slug = "slug",
+ SeriesName = "name",
+ Aliases = new[] { "Aliases" },
+ Overview = "overview",
+ Status = "Continuing",
+ FirstAired = "2021-07-23",
+ Poster = "poster",
+ FanArt = "fanart",
+ Id = 5,
+ Genre = new []
+ {
+ "Action",
+ "Test With Spéàacial characters"
+ }
+ };
+ Provider provider = TestSample.Get();
+ Show show = result.ToShow(provider);
+
+ Assert.Equal("slug", show.Slug);
+ Assert.Equal("name", show.Title);
+ Assert.Single(show.Aliases);
+ Assert.Equal("Aliases", show.Aliases[0]);
+ Assert.Equal("overview", show.Overview);
+ Assert.Equal(new DateTime(2021, 7, 23), show.StartAir);
+ Assert.Equal("https://www.thetvdb.com/banners/poster", show.Poster);
+ Assert.Equal("https://www.thetvdb.com/banners/fanart", show.Backdrop);
+ Assert.Single(show.ExternalIDs);
+ Assert.Equal("5", show.ExternalIDs.First().DataID);
+ Assert.Equal(provider, show.ExternalIDs.First().Provider);
+ Assert.Equal("https://www.thetvdb.com/series/slug", show.ExternalIDs.First().Link);
+ Assert.Equal(Status.Airing, show.Status);
+ Assert.Equal(2, show.Genres.Count);
+ Assert.Equal("action", show.Genres.ToArray()[0].Slug);
+ Assert.Equal("Action", show.Genres.ToArray()[0].Name);
+ Assert.Equal("Test With Spéàacial characters", show.Genres.ToArray()[1].Name);
+ Assert.Equal("test-with-speaacial-characters", show.Genres.ToArray()[1].Slug);
+ }
+
+ [Fact]
+ public void ActorToPeople()
+ {
+ Actor actor = new()
+ {
+ Id = 5,
+ Image = "image",
+ Name = "Name",
+ Role = "role"
+ };
+ Provider provider = TestSample.Get();
+ PeopleRole people = actor.ToPeopleRole(provider);
+
+ Assert.Equal("name", people.Slug);
+ Assert.Equal("Name", people.People.Name);
+ Assert.Equal("role", people.Role);
+ Assert.Equal("https://www.thetvdb.com/banners/image", people.People.Poster);
+ }
+
+ [Fact]
+ public void EpisodeRecordToEpisode()
+ {
+ EpisodeRecord record = new()
+ {
+ Id = 5,
+ AiredSeason = 2,
+ AiredEpisodeNumber = 3,
+ AbsoluteNumber = 23,
+ EpisodeName = "title",
+ Overview = "overview",
+ Filename = "thumb"
+ };
+ Provider provider = TestSample.Get();
+ Episode episode = record.ToEpisode(provider);
+
+ Assert.Equal("title", episode.Title);
+ Assert.Equal(2, episode.SeasonNumber);
+ Assert.Equal(3, episode.EpisodeNumber);
+ Assert.Equal(23, episode.AbsoluteNumber);
+ Assert.Equal("overview", episode.Overview);
+ Assert.Equal("https://www.thetvdb.com/banners/thumb", episode.Thumb);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Kyoo.Tests/Kyoo.Tests.csproj b/Kyoo.Tests/Kyoo.Tests.csproj
index 9dce41fc..120f8ba7 100644
--- a/Kyoo.Tests/Kyoo.Tests.csproj
+++ b/Kyoo.Tests/Kyoo.Tests.csproj
@@ -18,6 +18,7 @@
+
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -33,6 +34,7 @@
+
diff --git a/Kyoo.Tests/Utility/EnumerableTests.cs b/Kyoo.Tests/Utility/EnumerableTests.cs
index 9cdd8a00..c03efa06 100644
--- a/Kyoo.Tests/Utility/EnumerableTests.cs
+++ b/Kyoo.Tests/Utility/EnumerableTests.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using Xunit;
-namespace Kyoo.Tests
+namespace Kyoo.Tests.Utility
{
public class EnumerableTests
{
diff --git a/Kyoo.Tests/Utility/MergerTests.cs b/Kyoo.Tests/Utility/MergerTests.cs
index 008daee1..285532c2 100644
--- a/Kyoo.Tests/Utility/MergerTests.cs
+++ b/Kyoo.Tests/Utility/MergerTests.cs
@@ -5,7 +5,7 @@ using Kyoo.Models;
using Kyoo.Models.Attributes;
using Xunit;
-namespace Kyoo.Tests
+namespace Kyoo.Tests.Utility
{
public class MergerTests
{
diff --git a/Kyoo.Tests/Utility/TaskTests.cs b/Kyoo.Tests/Utility/TaskTests.cs
index 3a7baa48..3bcd723f 100644
--- a/Kyoo.Tests/Utility/TaskTests.cs
+++ b/Kyoo.Tests/Utility/TaskTests.cs
@@ -3,7 +3,7 @@ using System.Threading;
using System.Threading.Tasks;
using Xunit;
-namespace Kyoo.Tests
+namespace Kyoo.Tests.Utility
{
public class TaskTests
{
diff --git a/Kyoo.Tests/Utility/UtilityTests.cs b/Kyoo.Tests/Utility/UtilityTests.cs
index 80d233c3..f6f279aa 100644
--- a/Kyoo.Tests/Utility/UtilityTests.cs
+++ b/Kyoo.Tests/Utility/UtilityTests.cs
@@ -4,7 +4,9 @@ using System.Reflection;
using Kyoo.Models;
using Xunit;
-namespace Kyoo.Tests
+using Utils = Kyoo.Utility;
+
+namespace Kyoo.Tests.Utility
{
public class UtilityTests
{
@@ -14,12 +16,12 @@ namespace Kyoo.Tests
Expression> member = x => x.ID;
Expression> memberCast = x => x.ID;
- Assert.False(Utility.IsPropertyExpression(null));
- Assert.True(Utility.IsPropertyExpression(member));
- Assert.True(Utility.IsPropertyExpression(memberCast));
+ Assert.False(Utils.IsPropertyExpression(null));
+ Assert.True(Utils.IsPropertyExpression(member));
+ Assert.True(Utils.IsPropertyExpression(memberCast));
Expression> call = x => x.GetID("test");
- Assert.False(Utility.IsPropertyExpression(call));
+ Assert.False(Utils.IsPropertyExpression(call));
}
[Fact]
@@ -28,15 +30,15 @@ namespace Kyoo.Tests
Expression> member = x => x.ID;
Expression> memberCast = x => x.ID;
- Assert.Equal("ID", Utility.GetPropertyName(member));
- Assert.Equal("ID", Utility.GetPropertyName(memberCast));
- Assert.Throws(() => Utility.GetPropertyName(null));
+ Assert.Equal("ID", Utils.GetPropertyName(member));
+ Assert.Equal("ID", Utils.GetPropertyName(memberCast));
+ Assert.Throws(() => Utils.GetPropertyName(null));
}
[Fact]
public void GetMethodTest()
{
- MethodInfo method = Utility.GetMethod(typeof(UtilityTests),
+ MethodInfo method = Utils.GetMethod(typeof(UtilityTests),
BindingFlags.Instance | BindingFlags.Public,
nameof(GetMethodTest),
Array.Empty(),
@@ -47,17 +49,17 @@ namespace Kyoo.Tests
[Fact]
public void GetMethodInvalidGenericsTest()
{
- Assert.Throws(() => Utility.GetMethod(typeof(UtilityTests),
+ Assert.Throws(() => Utils.GetMethod(typeof(UtilityTests),
BindingFlags.Instance | BindingFlags.Public,
nameof(GetMethodTest),
- new [] { typeof(Utility) },
+ new [] { typeof(Utils) },
Array.Empty
/// The string representing the status.
/// A kyoo value or null.
- private static Status? GetStatus(string status)
+ private static Status _GetStatus(string status)
{
return status switch
{
"Ended" => Status.Finished,
"Continuing" => Status.Airing,
- _ => null
+ _ => Status.Unknown
};
}
@@ -31,11 +31,12 @@ namespace Kyoo.TheTvdb
///
/// The date string to parse
/// The parsed or null.
- private static DateTime ParseDate(string date)
+ private static DateTime? _ParseDate(string date)
{
- DateTime.TryParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture,
- DateTimeStyles.None, out DateTime parsed);
- return parsed;
+ return DateTime.TryParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture,
+ DateTimeStyles.None, out DateTime parsed)
+ ? parsed
+ : null;
}
///
@@ -52,8 +53,8 @@ namespace Kyoo.TheTvdb
Title = result.SeriesName,
Aliases = result.Aliases,
Overview = result.Overview,
- Status = GetStatus(result.Status),
- StartAir = ParseDate(result.FirstAired),
+ Status = _GetStatus(result.Status),
+ StartAir = _ParseDate(result.FirstAired),
Poster = result.Poster != null ? $"https://www.thetvdb.com{result.Poster}" : null,
ExternalIDs = new[]
{
@@ -81,8 +82,8 @@ namespace Kyoo.TheTvdb
Title = series.SeriesName,
Aliases = series.Aliases,
Overview = series.Overview,
- Status = GetStatus(series.Status),
- StartAir = ParseDate(series.FirstAired),
+ Status = _GetStatus(series.Status),
+ StartAir = _ParseDate(series.FirstAired),
Poster = series.Poster != null ? $"https://www.thetvdb.com/banners/{series.Poster}" : null,
Backdrop = series.FanArt != null ? $"https://www.thetvdb.com/banners/{series.FanArt}" : null,
Genres = series.Genre.Select(y => new Genre(y)).ToList(),
diff --git a/Kyoo.TheTvdb/PluginTvdb.cs b/Kyoo.TheTvdb/PluginTvdb.cs
index 1d008fbf..e0b697ea 100644
--- a/Kyoo.TheTvdb/PluginTvdb.cs
+++ b/Kyoo.TheTvdb/PluginTvdb.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using Autofac;
-using Kyoo.Authentication.Models;
using Kyoo.Controllers;
using Kyoo.Models.Attributes;
+using Kyoo.TheTvdb.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
diff --git a/Kyoo.TheTvdb/ProviderTvdb.cs b/Kyoo.TheTvdb/ProviderTvdb.cs
index 78834bfd..892e8125 100644
--- a/Kyoo.TheTvdb/ProviderTvdb.cs
+++ b/Kyoo.TheTvdb/ProviderTvdb.cs
@@ -3,9 +3,9 @@ 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 Kyoo.TheTvdb.Models;
using Microsoft.Extensions.Options;
using TvDbSharper;
using TvDbSharper.Dto;
diff --git a/Kyoo.TheTvdb/TvdbOption.cs b/Kyoo.TheTvdb/TvdbOption.cs
index 3b21ed9e..9a884b24 100644
--- a/Kyoo.TheTvdb/TvdbOption.cs
+++ b/Kyoo.TheTvdb/TvdbOption.cs
@@ -1,4 +1,4 @@
-namespace Kyoo.Authentication.Models
+namespace Kyoo.TheTvdb.Models
{
///
/// The option containing the api key for the tvdb.
diff --git a/Kyoo.WebApp b/Kyoo.WebApp
index 87783a5b..c037270d 160000
--- a/Kyoo.WebApp
+++ b/Kyoo.WebApp
@@ -1 +1 @@
-Subproject commit 87783a5bfdd79f21d72bad13da1d96ec8e08cd42
+Subproject commit c037270d3339fcf0075984a089f353c5c332a751