diff --git a/Jellyfin.Plugin.MetaShark.Test/SeasonProviderTest.cs b/Jellyfin.Plugin.MetaShark.Test/SeasonProviderTest.cs new file mode 100644 index 0000000..3207e01 --- /dev/null +++ b/Jellyfin.Plugin.MetaShark.Test/SeasonProviderTest.cs @@ -0,0 +1,53 @@ +using Jellyfin.Plugin.MetaShark.Api; +using Jellyfin.Plugin.MetaShark.Core; +using Jellyfin.Plugin.MetaShark.Providers; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using Microsoft.Extensions.Logging; +using Moq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Jellyfin.Plugin.MetaShark.Test +{ + [TestClass] + public class SeasonProviderTest + { + + ILoggerFactory loggerFactory = LoggerFactory.Create(builder => + builder.AddSimpleConsole(options => + { + options.IncludeScopes = true; + options.SingleLine = true; + options.TimestampFormat = "hh:mm:ss "; + })); + + + + [TestMethod] + public void TestGetMetadata() + { + var info = new SeasonInfo() { Name = "第 18 季", IndexNumber = 18, SeriesProviderIds = new Dictionary() { { BaseProvider.DoubanProviderId, "2059529" }, { MetadataProvider.Tmdb.ToString(), "34860" } } }; + var doubanApi = new DoubanApi(loggerFactory); + var tmdbApi = new TmdbApi(loggerFactory); + var omdbApi = new OmdbApi(loggerFactory); + var httpClientFactory = new DefaultHttpClientFactory(); + var libraryManagerStub = new Mock(); + + Task.Run(async () => + { + var provider = new SeasonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, doubanApi, tmdbApi, omdbApi); + var result = await provider.GetMetadata(info, CancellationToken.None); + Assert.IsNotNull(result); + + var str = result.ToJson(); + Console.WriteLine(result.ToJson()); + }).GetAwaiter().GetResult(); + } + + } +} diff --git a/Jellyfin.Plugin.MetaShark/Api/TmdbApi.cs b/Jellyfin.Plugin.MetaShark/Api/TmdbApi.cs index 9069818..bd9563d 100644 --- a/Jellyfin.Plugin.MetaShark/Api/TmdbApi.cs +++ b/Jellyfin.Plugin.MetaShark/Api/TmdbApi.cs @@ -23,6 +23,7 @@ namespace Jellyfin.Plugin.MetaShark.Api public class TmdbApi : IDisposable { public const string DEFAULT_API_KEY = "4219e299c89411838049ab0dab19ebd5"; + public const string DEFAULT_API_HOST = "api.tmdb.org"; private const int CacheDurationInHours = 1; private readonly ILogger _logger; private readonly IMemoryCache _memoryCache; @@ -37,7 +38,8 @@ namespace Jellyfin.Plugin.MetaShark.Api _memoryCache = new MemoryCache(new MemoryCacheOptions()); var config = Plugin.Instance?.Configuration; var apiKey = config == null || string.IsNullOrEmpty(config.TmdbApiKey) ? DEFAULT_API_KEY : config.TmdbApiKey; - _tmDbClient = new TMDbClient(apiKey); + var host = config == null || string.IsNullOrEmpty(config.TmdbHost) ? DEFAULT_API_HOST : config.TmdbHost; + _tmDbClient = new TMDbClient(apiKey, true, host); _tmDbClient.RequestTimeout = TimeSpan.FromSeconds(10); // Not really interested in NotFoundException _tmDbClient.ThrowApiExceptions = false; diff --git a/Jellyfin.Plugin.MetaShark/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.MetaShark/Configuration/PluginConfiguration.cs index a262863..1d04943 100644 --- a/Jellyfin.Plugin.MetaShark/Configuration/PluginConfiguration.cs +++ b/Jellyfin.Plugin.MetaShark/Configuration/PluginConfiguration.cs @@ -35,6 +35,8 @@ public class PluginConfiguration : BasePluginConfiguration public string TmdbApiKey { get; set; } = string.Empty; + public string TmdbHost { get; set; } = string.Empty; + public string DoubanCookies { get; set; } = string.Empty; public int MaxCastMembers { get; set; } = 15; diff --git a/Jellyfin.Plugin.MetaShark/Configuration/configPage.html b/Jellyfin.Plugin.MetaShark/Configuration/configPage.html index 94ac884..6828312 100644 --- a/Jellyfin.Plugin.MetaShark/Configuration/configPage.html +++ b/Jellyfin.Plugin.MetaShark/Configuration/configPage.html @@ -53,6 +53,12 @@
填写自定义Api Key,不填写会使用默认api key.(需重启才能生效)
+
+ + +
填写Api域名,默认api.tmdb.org.(需重启才能生效)
+