fix: fix missing parts of English name. close #37
This commit is contained in:
parent
0d3aa8ce80
commit
aa37dd4e99
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Reflection;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -147,7 +148,7 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetCelebritiesByCidAsync()
|
public void TestGetCelebritiesByCidAsync()
|
||||||
{
|
{
|
||||||
var sid = "1340364";
|
var cid = "1340364";
|
||||||
|
|
||||||
var api = new DoubanApi(loggerFactory);
|
var api = new DoubanApi(loggerFactory);
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await api.GetCelebrityAsync(sid, CancellationToken.None);
|
var result = await api.GetCelebrityAsync(cid, CancellationToken.None);
|
||||||
TestContext.WriteLine(result.ToJson());
|
TestContext.WriteLine(result.ToJson());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -164,5 +165,53 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
}
|
}
|
||||||
}).GetAwaiter().GetResult();
|
}).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestGetCelebrityPhotosAsync()
|
||||||
|
{
|
||||||
|
var cid = "1322205";
|
||||||
|
|
||||||
|
var api = new DoubanApi(loggerFactory);
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await api.GetCelebrityPhotosAsync(cid, CancellationToken.None);
|
||||||
|
TestContext.WriteLine(result.ToJson());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestParseCelebrityName()
|
||||||
|
{
|
||||||
|
|
||||||
|
var api = new DoubanApi(loggerFactory);
|
||||||
|
|
||||||
|
|
||||||
|
var name = "佩吉·陆 Peggy Lu";
|
||||||
|
var result = api.ParseCelebrityName(name);
|
||||||
|
Assert.AreEqual<string>(result, "佩吉·陆");
|
||||||
|
|
||||||
|
name = "Antony Coleman Antony Coleman";
|
||||||
|
result = api.ParseCelebrityName(name);
|
||||||
|
Assert.AreEqual<string>(result, "Antony Coleman");
|
||||||
|
|
||||||
|
name = "Dick Cook";
|
||||||
|
result = api.ParseCelebrityName(name);
|
||||||
|
Assert.AreEqual<string>(result, "Dick Cook");
|
||||||
|
|
||||||
|
name = "李凡秀";
|
||||||
|
result = api.ParseCelebrityName(name);
|
||||||
|
Assert.AreEqual<string>(result, "李凡秀");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,15 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetMetadata()
|
public void TestGetMetadata()
|
||||||
{
|
{
|
||||||
|
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
@ -52,7 +54,7 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
SeriesProviderIds = new Dictionary<string, string>() { { MetadataProvider.Tmdb.ToString(), "26707" } },
|
SeriesProviderIds = new Dictionary<string, string>() { { MetadataProvider.Tmdb.ToString(), "26707" } },
|
||||||
IsAutomated = false,
|
IsAutomated = false,
|
||||||
};
|
};
|
||||||
var provider = new EpisodeProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new EpisodeProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetMetadata(info, CancellationToken.None);
|
var result = await provider.GetMetadata(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
@ -64,15 +66,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestFixParseInfo()
|
public void TestFixParseInfo()
|
||||||
{
|
{
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
|
|
||||||
var provider = new EpisodeProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new EpisodeProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var parseResult = provider.FixParseInfo(new EpisodeInfo() { Path = "/test/[POPGO][Stand_Alone_Complex][05][1080P][BluRay][x264_FLACx2_AC3x1][chs_jpn][D87C36B6].mkv" });
|
var parseResult = provider.FixParseInfo(new EpisodeInfo() { Path = "/test/[POPGO][Stand_Alone_Complex][05][1080P][BluRay][x264_FLACx2_AC3x1][chs_jpn][D87C36B6].mkv" });
|
||||||
Assert.AreEqual(parseResult.IndexNumber, 5);
|
Assert.AreEqual(parseResult.IndexNumber, 5);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Jellyfin.Plugin.MetaShark.Api;
|
||||||
|
using Jellyfin.Plugin.MetaShark.Core;
|
||||||
|
using Jellyfin.Plugin.MetaShark.Model;
|
||||||
|
using Jellyfin.Plugin.MetaShark.Providers;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class ImdbApiTest
|
||||||
|
{
|
||||||
|
private TestContext testContextInstance;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the test context which provides
|
||||||
|
/// information about and functionality for the current test run.
|
||||||
|
/// </summary>
|
||||||
|
public TestContext TestContext
|
||||||
|
{
|
||||||
|
get { return testContextInstance; }
|
||||||
|
set { testContextInstance = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
|
||||||
|
builder.AddSimpleConsole(options =>
|
||||||
|
{
|
||||||
|
options.IncludeScopes = true;
|
||||||
|
options.SingleLine = true;
|
||||||
|
options.TimestampFormat = "hh:mm:ss ";
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestCheckPersonNewImdbID()
|
||||||
|
{
|
||||||
|
var api = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var id = "nm1123737";
|
||||||
|
var result = await api.CheckPersonNewIDAsync(id, CancellationToken.None);
|
||||||
|
Assert.AreEqual("nm0170924", result);
|
||||||
|
|
||||||
|
id = "nm0170924";
|
||||||
|
result = await api.CheckPersonNewIDAsync(id, CancellationToken.None);
|
||||||
|
Assert.AreEqual(null, result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
TestContext.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,7 +29,6 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetMovieImage()
|
public void TestGetMovieImage()
|
||||||
{
|
{
|
||||||
|
@ -39,16 +38,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
PreferredMetadataLanguage = "zh",
|
PreferredMetadataLanguage = "zh",
|
||||||
ProviderIds = new Dictionary<string, string> { { BaseProvider.DoubanProviderId, "2043546" }, { MetadataProvider.Tmdb.ToString(), "38142" } }
|
ProviderIds = new Dictionary<string, string> { { BaseProvider.DoubanProviderId, "2043546" }, { MetadataProvider.Tmdb.ToString(), "38142" } }
|
||||||
};
|
};
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new MovieImageProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new MovieImageProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetImages(info, CancellationToken.None);
|
var result = await provider.GetImages(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
@ -65,16 +65,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
PreferredMetadataLanguage = "zh",
|
PreferredMetadataLanguage = "zh",
|
||||||
ProviderIds = new Dictionary<string, string> { { MetadataProvider.Tmdb.ToString(), "752" }, { Plugin.ProviderId, MetaSource.Tmdb } }
|
ProviderIds = new Dictionary<string, string> { { MetadataProvider.Tmdb.ToString(), "752" }, { Plugin.ProviderId, MetaSource.Tmdb } }
|
||||||
};
|
};
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new MovieImageProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new MovieImageProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetImages(info, CancellationToken.None);
|
var result = await provider.GetImages(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
@ -86,16 +87,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetImageResponse()
|
public void TestGetImageResponse()
|
||||||
{
|
{
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new MovieImageProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new MovieImageProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetImageResponse("https://img1.doubanio.com/view/photo/m/public/p2893270877.jpg", CancellationToken.None);
|
var result = await provider.GetImageResponse("https://img1.doubanio.com/view/photo/m/public/p2893270877.jpg", CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
|
|
@ -29,22 +29,21 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetMetadata()
|
public void TestGetMetadata()
|
||||||
{
|
{
|
||||||
|
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var info = new MovieInfo() { Name = "我", MetadataLanguage = "zh" };
|
var info = new MovieInfo() { Name = "我", MetadataLanguage = "zh" };
|
||||||
var provider = new MovieProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new MovieProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetSearchResults(info, CancellationToken.None);
|
var result = await provider.GetSearchResults(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
@ -57,16 +56,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
public void TestGetMetadataAnime()
|
public void TestGetMetadataAnime()
|
||||||
{
|
{
|
||||||
var info = new MovieInfo() { Name = "[SAIO-Raws] もののけ姫 Mononoke Hime [BD 1920x1036 HEVC-10bit OPUSx2 AC3]" };
|
var info = new MovieInfo() { Name = "[SAIO-Raws] もののけ姫 Mononoke Hime [BD 1920x1036 HEVC-10bit OPUSx2 AC3]" };
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new MovieProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new MovieProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetMetadata(info, CancellationToken.None);
|
var result = await provider.GetMetadata(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
@ -79,16 +79,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
public void TestGetMetadataByTMDB()
|
public void TestGetMetadataByTMDB()
|
||||||
{
|
{
|
||||||
var info = new MovieInfo() { Name = "人生大事", MetadataLanguage = "zh", ProviderIds = new Dictionary<string, string> { { Plugin.ProviderId, MetaSource.Tmdb }, { MetadataProvider.Tmdb.ToString(), "945664" } } };
|
var info = new MovieInfo() { Name = "人生大事", MetadataLanguage = "zh", ProviderIds = new Dictionary<string, string> { { Plugin.ProviderId, MetaSource.Tmdb }, { MetadataProvider.Tmdb.ToString(), "945664" } } };
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new MovieProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new MovieProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetMetadata(info, CancellationToken.None);
|
var result = await provider.GetMetadata(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
|
|
@ -28,22 +28,21 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetMetadata()
|
public void TestGetMetadata()
|
||||||
{
|
{
|
||||||
|
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var info = new PersonLookupInfo() { ProviderIds = new Dictionary<string, string>() { { BaseProvider.DoubanProviderId, "1016771" } } };
|
var info = new PersonLookupInfo() { ProviderIds = new Dictionary<string, string>() { { BaseProvider.DoubanProviderId, "1016771" } } };
|
||||||
var provider = new PersonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new PersonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetMetadata(info, CancellationToken.None);
|
var result = await provider.GetMetadata(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
@ -55,18 +54,18 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetMetadataByTmdb()
|
public void TestGetMetadataByTmdb()
|
||||||
{
|
{
|
||||||
|
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var info = new PersonLookupInfo() { ProviderIds = new Dictionary<string, string>() { { MetadataProvider.Tmdb.ToString(), "78871" } } };
|
var info = new PersonLookupInfo() { ProviderIds = new Dictionary<string, string>() { { MetadataProvider.Tmdb.ToString(), "78871" } } };
|
||||||
var provider = new PersonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new PersonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetMetadata(info, CancellationToken.None);
|
var result = await provider.GetMetadata(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
|
|
@ -28,21 +28,21 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetMetadata()
|
public void TestGetMetadata()
|
||||||
{
|
{
|
||||||
var info = new SeasonInfo() { Name = "第 18 季", IndexNumber = 18, SeriesProviderIds = new Dictionary<string, string>() { { BaseProvider.DoubanProviderId, "2059529" }, { MetadataProvider.Tmdb.ToString(), "34860" } } };
|
var info = new SeasonInfo() { Name = "第 18 季", IndexNumber = 18, SeriesProviderIds = new Dictionary<string, string>() { { 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 httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new SeasonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new SeasonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetMetadata(info, CancellationToken.None);
|
var result = await provider.GetMetadata(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
@ -55,14 +55,15 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
public void TestGuessSeasonNumberByFileName()
|
public void TestGuessSeasonNumberByFileName()
|
||||||
{
|
{
|
||||||
var info = new SeasonInfo() { };
|
var info = new SeasonInfo() { };
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
var provider = new SeasonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new SeasonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = provider.GuessSeasonNumberByDirectoryName("/data/downloads/jellyfin/tv/向往的生活/第2季");
|
var result = provider.GuessSeasonNumberByDirectoryName("/data/downloads/jellyfin/tv/向往的生活/第2季");
|
||||||
Assert.AreEqual(result, 2);
|
Assert.AreEqual(result, 2);
|
||||||
|
|
||||||
|
@ -88,15 +89,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGuestDoubanSeasonByYearAsync()
|
public void TestGuestDoubanSeasonByYearAsync()
|
||||||
{
|
{
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new SeasonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new SeasonProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GuestDoubanSeasonByYearAsync("机动战士高达0083 星尘的回忆", 1991, null, CancellationToken.None);
|
var result = await provider.GuestDoubanSeasonByYearAsync("机动战士高达0083 星尘的回忆", 1991, null, CancellationToken.None);
|
||||||
Assert.AreEqual(result, "1766564");
|
Assert.AreEqual(result, "1766564");
|
||||||
}).GetAwaiter().GetResult();
|
}).GetAwaiter().GetResult();
|
||||||
|
|
|
@ -29,8 +29,6 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetMovieImageFromTMDB()
|
public void TestGetMovieImageFromTMDB()
|
||||||
{
|
{
|
||||||
|
@ -39,16 +37,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
PreferredMetadataLanguage = "zh",
|
PreferredMetadataLanguage = "zh",
|
||||||
ProviderIds = new Dictionary<string, string> { { MetadataProvider.Tmdb.ToString(), "67534" }, { Plugin.ProviderId, MetaSource.Tmdb } }
|
ProviderIds = new Dictionary<string, string> { { MetadataProvider.Tmdb.ToString(), "67534" }, { Plugin.ProviderId, MetaSource.Tmdb } }
|
||||||
};
|
};
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new SeriesImageProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new SeriesImageProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetImages(info, CancellationToken.None);
|
var result = await provider.GetImages(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
|
|
@ -27,21 +27,21 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetMetadata()
|
public void TestGetMetadata()
|
||||||
{
|
{
|
||||||
var info = new SeriesInfo() { Name = "一年一度喜剧大赛" };
|
var info = new SeriesInfo() { Name = "一年一度喜剧大赛" };
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new SeriesProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new SeriesProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetMetadata(info, CancellationToken.None);
|
var result = await provider.GetMetadata(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
||||||
|
@ -54,16 +54,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
public void TestGetAnimeMetadata()
|
public void TestGetAnimeMetadata()
|
||||||
{
|
{
|
||||||
var info = new SeriesInfo() { Name = "命运-冠位嘉年华" };
|
var info = new SeriesInfo() { Name = "命运-冠位嘉年华" };
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
|
||||||
var httpClientFactory = new DefaultHttpClientFactory();
|
var httpClientFactory = new DefaultHttpClientFactory();
|
||||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||||
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
|
||||||
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
var imdbApi = new ImdbApi(loggerFactory);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var provider = new SeriesProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new SeriesProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi, imdbApi);
|
||||||
var result = await provider.GetMetadata(info, CancellationToken.None);
|
var result = await provider.GetMetadata(info, CancellationToken.None);
|
||||||
Assert.AreEqual(result.Item.Name, "命运/冠位指定嘉年华 公元2020奥林匹亚英灵限界大祭");
|
Assert.AreEqual(result.Item.Name, "命运/冠位指定嘉年华 公元2020奥林匹亚英灵限界大祭");
|
||||||
Assert.AreEqual(result.Item.OriginalTitle, "Fate/Grand Carnival");
|
Assert.AreEqual(result.Item.OriginalTitle, "Fate/Grand Carnival");
|
||||||
|
|
|
@ -67,6 +67,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
Regex regImgHost = new Regex(@"\/\/(img\d+?)\.", RegexOptions.Compiled);
|
Regex regImgHost = new Regex(@"\/\/(img\d+?)\.", RegexOptions.Compiled);
|
||||||
// 匹配除了换行符之外所有空白
|
// 匹配除了换行符之外所有空白
|
||||||
Regex regOverviewSpace = new Regex(@"\n[^\S\n]+", RegexOptions.Compiled);
|
Regex regOverviewSpace = new Regex(@"\n[^\S\n]+", RegexOptions.Compiled);
|
||||||
|
Regex regPhotoId = new Regex(@"/photo/(\d+?)/", RegexOptions.Compiled);
|
||||||
|
|
||||||
// 默认200毫秒请求1次
|
// 默认200毫秒请求1次
|
||||||
private TimeLimiter _defaultTimeConstraint = TimeLimiter.GetFromMaxCountByInterval(1, TimeSpan.FromMilliseconds(200));
|
private TimeLimiter _defaultTimeConstraint = TimeLimiter.GetFromMaxCountByInterval(1, TimeSpan.FromMilliseconds(200));
|
||||||
|
@ -442,8 +443,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
var celebrityImgStr = node.GetAttr("div.avatar", "style") ?? string.Empty;
|
var celebrityImgStr = node.GetAttr("div.avatar", "style") ?? string.Empty;
|
||||||
var celebrityImg = celebrityImgStr.GetMatchGroup(this.regBackgroundImage);
|
var celebrityImg = celebrityImgStr.GetMatchGroup(this.regBackgroundImage);
|
||||||
var celebrityNameStr = node.GetText("div.info a.name") ?? string.Empty;
|
var celebrityNameStr = node.GetText("div.info a.name") ?? string.Empty;
|
||||||
var arr = celebrityNameStr.Split(" ");
|
var celebrityName = this.ParseCelebrityName(celebrityNameStr);
|
||||||
var celebrityName = arr.Length > 1 ? arr[0].Trim() : celebrityNameStr;
|
|
||||||
// 有时存在演员信息缺少名字的
|
// 有时存在演员信息缺少名字的
|
||||||
if (string.IsNullOrEmpty(celebrityName))
|
if (string.IsNullOrEmpty(celebrityName))
|
||||||
{
|
{
|
||||||
|
@ -502,8 +502,8 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
{
|
{
|
||||||
var img = contentNode.GetAttr("#headline .nbg img", "src") ?? string.Empty;
|
var img = contentNode.GetAttr("#headline .nbg img", "src") ?? string.Empty;
|
||||||
var nameStr = contentNode.GetText("h1") ?? string.Empty;
|
var nameStr = contentNode.GetText("h1") ?? string.Empty;
|
||||||
var arr = nameStr.Split(" ");
|
var name = this.ParseCelebrityName(nameStr);
|
||||||
var name = arr.Length > 1 ? arr[0] : nameStr;
|
var englishName = nameStr.Replace(name, "").Trim();
|
||||||
|
|
||||||
var intro = contentNode.GetText("#intro span.all") ?? string.Empty;
|
var intro = contentNode.GetText("#intro span.all") ?? string.Empty;
|
||||||
if (string.IsNullOrEmpty(intro))
|
if (string.IsNullOrEmpty(intro))
|
||||||
|
@ -534,7 +534,8 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
celebrity.Gender = gender;
|
celebrity.Gender = gender;
|
||||||
celebrity.Birthdate = birthdate;
|
celebrity.Birthdate = birthdate;
|
||||||
celebrity.Enddate = enddate;
|
celebrity.Enddate = enddate;
|
||||||
celebrity.Nickname = nickname;
|
celebrity.NickName = nickname;
|
||||||
|
celebrity.EnglishName = englishName;
|
||||||
celebrity.Imdb = imdb;
|
celebrity.Imdb = imdb;
|
||||||
celebrity.Birthplace = birthplace;
|
celebrity.Birthplace = birthplace;
|
||||||
celebrity.Name = name;
|
celebrity.Name = name;
|
||||||
|
@ -551,6 +552,106 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<DoubanPhoto>> GetCelebrityPhotosAsync(string cid, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var list = new List<DoubanPhoto>();
|
||||||
|
if (string.IsNullOrEmpty(cid))
|
||||||
|
{
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
var cacheKey = $"celebrity_photo_{cid}";
|
||||||
|
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
||||||
|
if (_memoryCache.TryGetValue<List<DoubanPhoto>>(cacheKey, out var photos))
|
||||||
|
{
|
||||||
|
return photos;
|
||||||
|
}
|
||||||
|
|
||||||
|
await LimitRequestFrequently();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = $"https://movie.douban.com/celebrity/{cid}/photos/";
|
||||||
|
var response = await httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
var body = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
var context = BrowsingContext.New();
|
||||||
|
var doc = await context.OpenAsync(req => req.Content(body), cancellationToken).ConfigureAwait(false);
|
||||||
|
var elements = doc.QuerySelectorAll(".poster-col3>li");
|
||||||
|
|
||||||
|
foreach (var node in elements)
|
||||||
|
{
|
||||||
|
|
||||||
|
var href = node.QuerySelector("a")?.GetAttribute("href") ?? string.Empty;
|
||||||
|
var id = href.GetMatchGroup(this.regPhotoId);
|
||||||
|
var raw = node.QuerySelector("img")?.GetAttribute("src") ?? string.Empty;
|
||||||
|
var size = node.GetText("div.prop") ?? string.Empty;
|
||||||
|
|
||||||
|
var photo = new DoubanPhoto();
|
||||||
|
photo.Id = id;
|
||||||
|
photo.Size = size;
|
||||||
|
photo.Raw = raw;
|
||||||
|
if (!string.IsNullOrEmpty(size))
|
||||||
|
{
|
||||||
|
var arr = size.Split('x');
|
||||||
|
if (arr.Length == 2)
|
||||||
|
{
|
||||||
|
photo.Width = arr[0].ToInt();
|
||||||
|
photo.Height = arr[1].ToInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(photo);
|
||||||
|
}
|
||||||
|
|
||||||
|
_memoryCache.Set<List<DoubanPhoto>>(cacheKey, list, expiredOption);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this._logger.LogError(ex, "GetCelebrityPhotosAsync error. cid: {0}", cid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ParseCelebrityName(string nameString)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(nameString))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 只有中文名情况
|
||||||
|
var idx = nameString.IndexOf(" ", StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (idx < 0)
|
||||||
|
{
|
||||||
|
return nameString.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 中英名混合情况
|
||||||
|
var firstName = nameString.Substring(0, idx);
|
||||||
|
if (firstName.HasChinese())
|
||||||
|
{
|
||||||
|
return firstName.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 英文名重复两次的情况
|
||||||
|
var nextIndex = nameString[idx..].IndexOf(firstName, StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (nextIndex >= 0)
|
||||||
|
{
|
||||||
|
nextIndex = idx + nextIndex;
|
||||||
|
return nameString[..nextIndex].Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 只有英文名情况
|
||||||
|
return nameString.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<DoubanCelebrity>> SearchCelebrityAsync(string keyword, CancellationToken cancellationToken)
|
public async Task<List<DoubanCelebrity>> SearchCelebrityAsync(string keyword, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var list = new List<DoubanCelebrity>();
|
var list = new List<DoubanCelebrity>();
|
||||||
|
@ -561,8 +662,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
|
|
||||||
var cacheKey = $"search_celebrity_{keyword}";
|
var cacheKey = $"search_celebrity_{keyword}";
|
||||||
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
||||||
List<DoubanCelebrity> searchResult;
|
if (_memoryCache.TryGetValue<List<DoubanCelebrity>>(cacheKey, out var searchResult))
|
||||||
if (_memoryCache.TryGetValue<List<DoubanCelebrity>>(cacheKey, out searchResult))
|
|
||||||
{
|
{
|
||||||
return searchResult;
|
return searchResult;
|
||||||
}
|
}
|
||||||
|
@ -613,8 +713,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
|
|
||||||
var cacheKey = $"photo_{sid}";
|
var cacheKey = $"photo_{sid}";
|
||||||
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
||||||
List<DoubanPhoto> photos;
|
if (_memoryCache.TryGetValue<List<DoubanPhoto>>(cacheKey, out var photos))
|
||||||
if (_memoryCache.TryGetValue<List<DoubanPhoto>>(cacheKey, out photos))
|
|
||||||
{
|
{
|
||||||
return photos;
|
return photos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
using Jellyfin.Plugin.MetaShark.Core;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
|
{
|
||||||
|
public class ImdbApi : IDisposable
|
||||||
|
{
|
||||||
|
private readonly ILogger<DoubanApi> _logger;
|
||||||
|
private readonly IMemoryCache _memoryCache;
|
||||||
|
private readonly HttpClient httpClient;
|
||||||
|
|
||||||
|
Regex regId = new Regex(@"/(tt\d+)", RegexOptions.Compiled);
|
||||||
|
Regex regPersonId = new Regex(@"/(nm\d+)", RegexOptions.Compiled);
|
||||||
|
|
||||||
|
public ImdbApi(ILoggerFactory loggerFactory)
|
||||||
|
{
|
||||||
|
_logger = loggerFactory.CreateLogger<DoubanApi>();
|
||||||
|
_memoryCache = new MemoryCache(new MemoryCacheOptions());
|
||||||
|
|
||||||
|
var handler = new HttpClientHandler()
|
||||||
|
{
|
||||||
|
AllowAutoRedirect = false
|
||||||
|
};
|
||||||
|
httpClient = new HttpClient(handler);
|
||||||
|
httpClient.Timeout = TimeSpan.FromSeconds(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过imdb获取信息(会返回最新的imdb id)
|
||||||
|
/// </summary>
|
||||||
|
public async Task<string?> CheckNewIDAsync(string id, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var cacheKey = $"CheckNewImdbID_{id}";
|
||||||
|
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
||||||
|
if (this._memoryCache.TryGetValue<string?>(cacheKey, out var item))
|
||||||
|
{
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = $"https://www.imdb.com/title/{id}/";
|
||||||
|
var resp = await this.httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (resp.Headers.TryGetValues("Location", out var values))
|
||||||
|
{
|
||||||
|
var location = values.First();
|
||||||
|
var newId = location.GetMatchGroup(this.regId);
|
||||||
|
if (!string.IsNullOrEmpty(newId))
|
||||||
|
{
|
||||||
|
item = newId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._memoryCache.Set(cacheKey, item, expiredOption);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this._logger.LogError(ex, "CheckNewImdbID error. id: {0}", id);
|
||||||
|
this._memoryCache.Set<string?>(cacheKey, null, expiredOption);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过imdb获取信息(会返回最新的imdb id)
|
||||||
|
/// </summary>
|
||||||
|
public async Task<string?> CheckPersonNewIDAsync(string id, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var cacheKey = $"CheckPersonNewImdbID_{id}";
|
||||||
|
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
||||||
|
if (this._memoryCache.TryGetValue<string?>(cacheKey, out var item))
|
||||||
|
{
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = $"https://www.imdb.com/name/{id}/";
|
||||||
|
var resp = await this.httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (resp.Headers.TryGetValues("Location", out var values))
|
||||||
|
{
|
||||||
|
var location = values.First();
|
||||||
|
var newId = location.GetMatchGroup(this.regPersonId);
|
||||||
|
if (!string.IsNullOrEmpty(newId))
|
||||||
|
{
|
||||||
|
item = newId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._memoryCache.Set(cacheKey, item, expiredOption);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this._logger.LogError(ex, "CheckPersonNewImdbID error. id: {0}", id);
|
||||||
|
this._memoryCache.Set<string?>(cacheKey, null, expiredOption);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
_memoryCache.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsEnable()
|
||||||
|
{
|
||||||
|
return Plugin.Instance?.Configuration.EnableTmdb ?? true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +1,9 @@
|
||||||
using Jellyfin.Extensions.Json;
|
using Jellyfin.Plugin.MetaShark.Model;
|
||||||
using Jellyfin.Plugin.MetaShark.Api.Http;
|
|
||||||
using Jellyfin.Plugin.MetaShark.Model;
|
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -45,8 +39,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
|
|
||||||
var cacheKey = $"GetByImdbID_{id}";
|
var cacheKey = $"GetByImdbID_{id}";
|
||||||
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
||||||
OmdbItem? item;
|
if (this._memoryCache.TryGetValue<OmdbItem?>(cacheKey, out var item))
|
||||||
if (this._memoryCache.TryGetValue(cacheKey, out item))
|
|
||||||
{
|
{
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,8 @@ namespace Jellyfin.Plugin.MetaShark.Model
|
||||||
public string Birthdate { get; set; }
|
public string Birthdate { get; set; }
|
||||||
public string Enddate { get; set; }
|
public string Enddate { get; set; }
|
||||||
public string Birthplace { get; set; }
|
public string Birthplace { get; set; }
|
||||||
public string Nickname { get; set; }
|
public string NickName { get; set; }
|
||||||
|
public string EnglishName { get; set; }
|
||||||
public string Imdb { get; set; }
|
public string Imdb { get; set; }
|
||||||
public string Site { get; set; }
|
public string Site { get; set; }
|
||||||
|
|
||||||
|
@ -143,6 +144,20 @@ namespace Jellyfin.Plugin.MetaShark.Model
|
||||||
_roleType = value;
|
_roleType = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string? DisplayOriginalName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// 外国人才显示英文名
|
||||||
|
if (Name.Contains("·") && Birthplace != null && !Birthplace.Contains("中国"))
|
||||||
|
{
|
||||||
|
return EnglishName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DoubanPhoto
|
public class DoubanPhoto
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
protected readonly DoubanApi _doubanApi;
|
protected readonly DoubanApi _doubanApi;
|
||||||
protected readonly TmdbApi _tmdbApi;
|
protected readonly TmdbApi _tmdbApi;
|
||||||
protected readonly OmdbApi _omdbApi;
|
protected readonly OmdbApi _omdbApi;
|
||||||
|
protected readonly ImdbApi _imdbApi;
|
||||||
protected readonly ILibraryManager _libraryManager;
|
protected readonly ILibraryManager _libraryManager;
|
||||||
protected readonly IHttpContextAccessor _httpContextAccessor;
|
protected readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
@ -58,43 +59,12 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string RequestDomain
|
protected BaseProvider(IHttpClientFactory httpClientFactory, ILogger logger, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_httpContextAccessor.HttpContext != null)
|
|
||||||
{
|
|
||||||
return _httpContextAccessor.HttpContext.Request.Scheme + System.Uri.SchemeDelimiter + _httpContextAccessor.HttpContext.Request.Host;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected string RequestPath
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_httpContextAccessor.HttpContext != null)
|
|
||||||
{
|
|
||||||
return _httpContextAccessor.HttpContext.Request.Path.ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BaseProvider(IHttpClientFactory httpClientFactory, ILogger logger, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
|
||||||
{
|
{
|
||||||
this._doubanApi = doubanApi;
|
this._doubanApi = doubanApi;
|
||||||
this._tmdbApi = tmdbApi;
|
this._tmdbApi = tmdbApi;
|
||||||
this._omdbApi = omdbApi;
|
this._omdbApi = omdbApi;
|
||||||
|
this._imdbApi = imdbApi;
|
||||||
this._libraryManager = libraryManager;
|
this._libraryManager = libraryManager;
|
||||||
this._logger = logger;
|
this._logger = logger;
|
||||||
this._httpClientFactory = httpClientFactory;
|
this._httpClientFactory = httpClientFactory;
|
||||||
|
|
|
@ -19,8 +19,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
{
|
{
|
||||||
public class EpisodeImageProvider : BaseProvider, IRemoteImageProvider
|
public class EpisodeImageProvider : BaseProvider, IRemoteImageProvider
|
||||||
{
|
{
|
||||||
public EpisodeImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public EpisodeImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<EpisodeImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<EpisodeImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
{
|
{
|
||||||
private readonly IMemoryCache _memoryCache;
|
private readonly IMemoryCache _memoryCache;
|
||||||
|
|
||||||
public EpisodeProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public EpisodeProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<EpisodeProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<EpisodeProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
this._memoryCache = new MemoryCache(new MemoryCacheOptions());
|
this._memoryCache = new MemoryCache(new MemoryCacheOptions());
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
{
|
{
|
||||||
public class MovieImageProvider : BaseProvider, IRemoteImageProvider
|
public class MovieImageProvider : BaseProvider, IRemoteImageProvider
|
||||||
{
|
{
|
||||||
public MovieImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public MovieImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<MovieImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<MovieImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
var res = new List<RemoteImageInfo> {
|
var res = new List<RemoteImageInfo> {
|
||||||
new RemoteImageInfo
|
new RemoteImageInfo
|
||||||
{
|
{
|
||||||
ProviderName = primary.Name,
|
ProviderName = this.Name,
|
||||||
Url = this.GetProxyImageUrl(primary.ImgMiddle),
|
Url = this.GetProxyImageUrl(primary.ImgMiddle),
|
||||||
Type = ImageType.Primary,
|
Type = ImageType.Primary,
|
||||||
},
|
},
|
||||||
|
|
|
@ -23,8 +23,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
{
|
{
|
||||||
public class MovieProvider : BaseProvider, IRemoteMetadataProvider<Movie, MovieInfo>
|
public class MovieProvider : BaseProvider, IRemoteMetadataProvider<Movie, MovieInfo>
|
||||||
{
|
{
|
||||||
public MovieProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public MovieProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<MovieProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<MovieProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ using MediaBrowser.Model.Providers;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -16,8 +15,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
{
|
{
|
||||||
public class PersonImageProvider : BaseProvider, IRemoteImageProvider
|
public class PersonImageProvider : BaseProvider, IRemoteImageProvider
|
||||||
{
|
{
|
||||||
public PersonImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public PersonImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<PersonImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<PersonImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +35,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
var list = new List<RemoteImageInfo>();
|
||||||
var cid = item.GetProviderId(DoubanProviderId);
|
var cid = item.GetProviderId(DoubanProviderId);
|
||||||
var metaSource = item.GetProviderId(Plugin.ProviderId);
|
var metaSource = item.GetProviderId(Plugin.ProviderId);
|
||||||
this.Log($"GetImages for item: {item.Name} [metaSource]: {metaSource}");
|
this.Log($"GetImages for item: {item.Name} [metaSource]: {metaSource}");
|
||||||
|
@ -44,19 +44,36 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
var celebrity = await this._doubanApi.GetCelebrityAsync(cid, cancellationToken).ConfigureAwait(false);
|
var celebrity = await this._doubanApi.GetCelebrityAsync(cid, cancellationToken).ConfigureAwait(false);
|
||||||
if (celebrity != null)
|
if (celebrity != null)
|
||||||
{
|
{
|
||||||
return new List<RemoteImageInfo> {
|
list.Add(new RemoteImageInfo
|
||||||
new RemoteImageInfo
|
|
||||||
{
|
{
|
||||||
ProviderName = celebrity.Name,
|
ProviderName = this.Name,
|
||||||
Url = this.GetProxyImageUrl(celebrity.Img),
|
Url = this.GetProxyImageUrl(celebrity.Img),
|
||||||
Type = ImageType.Primary
|
Type = ImageType.Primary,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
var photos = await this._doubanApi.GetCelebrityPhotosAsync(cid, cancellationToken).ConfigureAwait(false);
|
||||||
|
photos.ForEach(x =>
|
||||||
|
{
|
||||||
|
// 过滤不是竖图
|
||||||
|
if (x.Width < 400 || x.Height < x.Width * 1.3)
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.Add(new RemoteImageInfo
|
||||||
|
{
|
||||||
|
ProviderName = this.Name,
|
||||||
|
Url = this.GetProxyImageUrl(x.Raw),
|
||||||
|
Width = x.Width,
|
||||||
|
Height = x.Height,
|
||||||
|
Type = ImageType.Primary,
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Log($"Got images failed because the images of \"{item.Name}\" is empty!");
|
this.Log($"Got images failed because the images of \"{item.Name}\" is empty!");
|
||||||
return new List<RemoteImageInfo>();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PersonProvider : BaseProvider, IRemoteMetadataProvider<Person, PersonLookupInfo>
|
public class PersonProvider : BaseProvider, IRemoteMetadataProvider<Person, PersonLookupInfo>
|
||||||
{
|
{
|
||||||
public PersonProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public PersonProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<PersonProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<PersonProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
var item = new Person
|
var item = new Person
|
||||||
{
|
{
|
||||||
// Name = c.Name.Trim(), // 名称需保持和info.Name一致,不然会导致关联不到影片,自动被删除
|
// Name = c.Name.Trim(), // 名称需保持和info.Name一致,不然会导致关联不到影片,自动被删除
|
||||||
|
OriginalTitle = c.DisplayOriginalName, // 外国人显示英文名
|
||||||
HomePageUrl = c.Site,
|
HomePageUrl = c.Site,
|
||||||
Overview = c.Intro,
|
Overview = c.Intro,
|
||||||
};
|
};
|
||||||
|
@ -109,6 +110,11 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
item.SetProviderId(DoubanProviderId, cid);
|
item.SetProviderId(DoubanProviderId, cid);
|
||||||
if (!string.IsNullOrEmpty(c.Imdb))
|
if (!string.IsNullOrEmpty(c.Imdb))
|
||||||
{
|
{
|
||||||
|
var newImdbId = await this._imdbApi.CheckPersonNewIDAsync(c.Imdb, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (!string.IsNullOrEmpty(newImdbId))
|
||||||
|
{
|
||||||
|
c.Imdb = newImdbId;
|
||||||
|
}
|
||||||
item.SetProviderId(MetadataProvider.Imdb, c.Imdb);
|
item.SetProviderId(MetadataProvider.Imdb, c.Imdb);
|
||||||
// 通过imdb获取TMDB id
|
// 通过imdb获取TMDB id
|
||||||
var findResult = await this._tmdbApi.FindByExternalIdAsync(c.Imdb, FindExternalSource.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
var findResult = await this._tmdbApi.FindByExternalIdAsync(c.Imdb, FindExternalSource.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
|
@ -21,8 +21,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
{
|
{
|
||||||
public class SeasonImageProvider : BaseProvider, IRemoteImageProvider
|
public class SeasonImageProvider : BaseProvider, IRemoteImageProvider
|
||||||
{
|
{
|
||||||
public SeasonImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public SeasonImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<SeasonImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<SeasonImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
public class SeasonProvider : BaseProvider, IRemoteMetadataProvider<Season, SeasonInfo>
|
public class SeasonProvider : BaseProvider, IRemoteMetadataProvider<Season, SeasonInfo>
|
||||||
{
|
{
|
||||||
|
|
||||||
public SeasonProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public SeasonProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<SeasonProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<SeasonProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
{
|
{
|
||||||
public class SeriesImageProvider : BaseProvider, IRemoteImageProvider
|
public class SeriesImageProvider : BaseProvider, IRemoteImageProvider
|
||||||
{
|
{
|
||||||
public SeriesImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public SeriesImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
var res = new List<RemoteImageInfo> {
|
var res = new List<RemoteImageInfo> {
|
||||||
new RemoteImageInfo
|
new RemoteImageInfo
|
||||||
{
|
{
|
||||||
ProviderName = primary.Name,
|
ProviderName = this.Name,
|
||||||
Url = this.GetProxyImageUrl(primary.ImgMiddle),
|
Url = this.GetProxyImageUrl(primary.ImgMiddle),
|
||||||
Type = ImageType.Primary,
|
Type = ImageType.Primary,
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,8 +22,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
{
|
{
|
||||||
public class SeriesProvider : BaseProvider, IRemoteMetadataProvider<Series, SeriesInfo>
|
public class SeriesProvider : BaseProvider, IRemoteMetadataProvider<Series, SeriesInfo>
|
||||||
{
|
{
|
||||||
public SeriesProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
|
public SeriesProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
|
||||||
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi)
|
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, omdbApi, imdbApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@ namespace Jellyfin.Plugin.MetaShark
|
||||||
{
|
{
|
||||||
return new OmdbApi(ctx.GetRequiredService<ILoggerFactory>());
|
return new OmdbApi(ctx.GetRequiredService<ILoggerFactory>());
|
||||||
});
|
});
|
||||||
|
serviceCollection.AddSingleton<ImdbApi>((ctx) =>
|
||||||
|
{
|
||||||
|
return new ImdbApi(ctx.GetRequiredService<ILoggerFactory>());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue