fix: fix missing parts of English name. close #37

This commit is contained in:
cxfksword 2023-07-14 09:49:45 +08:00
parent 0d3aa8ce80
commit aa37dd4e99
25 changed files with 516 additions and 158 deletions

View File

@ -1,3 +1,4 @@
using System.Reflection;
using System;
using System.Collections.Generic;
using System.Linq;
@ -147,7 +148,7 @@ namespace Jellyfin.Plugin.MetaShark.Test
[TestMethod]
public void TestGetCelebritiesByCidAsync()
{
var sid = "1340364";
var cid = "1340364";
var api = new DoubanApi(loggerFactory);
@ -155,7 +156,7 @@ namespace Jellyfin.Plugin.MetaShark.Test
{
try
{
var result = await api.GetCelebrityAsync(sid, CancellationToken.None);
var result = await api.GetCelebrityAsync(cid, CancellationToken.None);
TestContext.WriteLine(result.ToJson());
}
catch (Exception ex)
@ -164,5 +165,53 @@ namespace Jellyfin.Plugin.MetaShark.Test
}
}).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, "李凡秀");
}
}
}

View File

@ -30,13 +30,15 @@ namespace Jellyfin.Plugin.MetaShark.Test
}));
[TestMethod]
public void TestGetMetadata()
{
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 libraryManagerStub = new Mock<ILibraryManager>();
var httpContextAccessorStub = new Mock<IHttpContextAccessor>();
@ -52,7 +54,7 @@ namespace Jellyfin.Plugin.MetaShark.Test
SeriesProviderIds = new Dictionary<string, string>() { { MetadataProvider.Tmdb.ToString(), "26707" } },
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);
Assert.IsNotNull(result);
@ -64,15 +66,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
[TestMethod]
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 libraryManagerStub = new Mock<ILibraryManager>();
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" });
Assert.AreEqual(parseResult.IndexNumber, 5);

View File

@ -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();
}
}
}

View File

@ -29,7 +29,6 @@ namespace Jellyfin.Plugin.MetaShark.Test
}));
[TestMethod]
public void TestGetMovieImage()
{
@ -39,16 +38,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
PreferredMetadataLanguage = "zh",
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 libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);
@ -65,16 +65,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
PreferredMetadataLanguage = "zh",
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 libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);
@ -86,16 +87,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
[TestMethod]
public void TestGetImageResponse()
{
var doubanApi = new DoubanApi(loggerFactory);
var tmdbApi = new TmdbApi(loggerFactory);
var omdbApi = new OmdbApi(loggerFactory);
var httpClientFactory = new DefaultHttpClientFactory();
var libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);

View File

@ -29,22 +29,21 @@ namespace Jellyfin.Plugin.MetaShark.Test
}));
[TestMethod]
public void TestGetMetadata()
{
var doubanApi = new DoubanApi(loggerFactory);
var tmdbApi = new TmdbApi(loggerFactory);
var omdbApi = new OmdbApi(loggerFactory);
var httpClientFactory = new DefaultHttpClientFactory();
var libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);
@ -57,16 +56,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
public void TestGetMetadataAnime()
{
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 libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);
@ -79,16 +79,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
public void TestGetMetadataByTMDB()
{
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 libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);

View File

@ -28,22 +28,21 @@ namespace Jellyfin.Plugin.MetaShark.Test
}));
[TestMethod]
public void TestGetMetadata()
{
var doubanApi = new DoubanApi(loggerFactory);
var tmdbApi = new TmdbApi(loggerFactory);
var omdbApi = new OmdbApi(loggerFactory);
var httpClientFactory = new DefaultHttpClientFactory();
var libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);
@ -55,18 +54,18 @@ namespace Jellyfin.Plugin.MetaShark.Test
[TestMethod]
public void TestGetMetadataByTmdb()
{
var doubanApi = new DoubanApi(loggerFactory);
var tmdbApi = new TmdbApi(loggerFactory);
var omdbApi = new OmdbApi(loggerFactory);
var httpClientFactory = new DefaultHttpClientFactory();
var libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);

View File

@ -28,21 +28,21 @@ namespace Jellyfin.Plugin.MetaShark.Test
}));
[TestMethod]
public void TestGetMetadata()
{
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 libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);
@ -55,14 +55,15 @@ namespace Jellyfin.Plugin.MetaShark.Test
public void TestGuessSeasonNumberByFileName()
{
var info = new SeasonInfo() { };
var doubanApi = new DoubanApi(loggerFactory);
var tmdbApi = new TmdbApi(loggerFactory);
var omdbApi = new OmdbApi(loggerFactory);
var httpClientFactory = new DefaultHttpClientFactory();
var libraryManagerStub = new Mock<ILibraryManager>();
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季");
Assert.AreEqual(result, 2);
@ -88,15 +89,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
[TestMethod]
public void TestGuestDoubanSeasonByYearAsync()
{
var doubanApi = new DoubanApi(loggerFactory);
var tmdbApi = new TmdbApi(loggerFactory);
var omdbApi = new OmdbApi(loggerFactory);
var httpClientFactory = new DefaultHttpClientFactory();
var libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.AreEqual(result, "1766564");
}).GetAwaiter().GetResult();

View File

@ -29,8 +29,6 @@ namespace Jellyfin.Plugin.MetaShark.Test
}));
[TestMethod]
public void TestGetMovieImageFromTMDB()
{
@ -39,16 +37,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
PreferredMetadataLanguage = "zh",
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 libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);

View File

@ -27,21 +27,21 @@ namespace Jellyfin.Plugin.MetaShark.Test
}));
[TestMethod]
public void TestGetMetadata()
{
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 libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.IsNotNull(result);
@ -54,16 +54,17 @@ namespace Jellyfin.Plugin.MetaShark.Test
public void TestGetAnimeMetadata()
{
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 libraryManagerStub = new Mock<ILibraryManager>();
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 () =>
{
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);
Assert.AreEqual(result.Item.Name, "命运/冠位指定嘉年华 公元2020奥林匹亚英灵限界大祭");
Assert.AreEqual(result.Item.OriginalTitle, "Fate/Grand Carnival");

View File

@ -67,6 +67,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
Regex regImgHost = new Regex(@"\/\/(img\d+?)\.", RegexOptions.Compiled);
// 匹配除了换行符之外所有空白
Regex regOverviewSpace = new Regex(@"\n[^\S\n]+", RegexOptions.Compiled);
Regex regPhotoId = new Regex(@"/photo/(\d+?)/", RegexOptions.Compiled);
// 默认200毫秒请求1次
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 celebrityImg = celebrityImgStr.GetMatchGroup(this.regBackgroundImage);
var celebrityNameStr = node.GetText("div.info a.name") ?? string.Empty;
var arr = celebrityNameStr.Split(" ");
var celebrityName = arr.Length > 1 ? arr[0].Trim() : celebrityNameStr;
var celebrityName = this.ParseCelebrityName(celebrityNameStr);
// 有时存在演员信息缺少名字的
if (string.IsNullOrEmpty(celebrityName))
{
@ -502,8 +502,8 @@ namespace Jellyfin.Plugin.MetaShark.Api
{
var img = contentNode.GetAttr("#headline .nbg img", "src") ?? string.Empty;
var nameStr = contentNode.GetText("h1") ?? string.Empty;
var arr = nameStr.Split(" ");
var name = arr.Length > 1 ? arr[0] : nameStr;
var name = this.ParseCelebrityName(nameStr);
var englishName = nameStr.Replace(name, "").Trim();
var intro = contentNode.GetText("#intro span.all") ?? string.Empty;
if (string.IsNullOrEmpty(intro))
@ -534,7 +534,8 @@ namespace Jellyfin.Plugin.MetaShark.Api
celebrity.Gender = gender;
celebrity.Birthdate = birthdate;
celebrity.Enddate = enddate;
celebrity.Nickname = nickname;
celebrity.NickName = nickname;
celebrity.EnglishName = englishName;
celebrity.Imdb = imdb;
celebrity.Birthplace = birthplace;
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)
{
var list = new List<DoubanCelebrity>();
@ -561,8 +662,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
var cacheKey = $"search_celebrity_{keyword}";
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
List<DoubanCelebrity> searchResult;
if (_memoryCache.TryGetValue<List<DoubanCelebrity>>(cacheKey, out searchResult))
if (_memoryCache.TryGetValue<List<DoubanCelebrity>>(cacheKey, out var searchResult))
{
return searchResult;
}
@ -613,8 +713,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
var cacheKey = $"photo_{sid}";
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
List<DoubanPhoto> photos;
if (_memoryCache.TryGetValue<List<DoubanPhoto>>(cacheKey, out photos))
if (_memoryCache.TryGetValue<List<DoubanPhoto>>(cacheKey, out var photos))
{
return photos;
}

View File

@ -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;
}
}
}

View File

@ -1,15 +1,9 @@
using Jellyfin.Extensions.Json;
using Jellyfin.Plugin.MetaShark.Api.Http;
using Jellyfin.Plugin.MetaShark.Model;
using Jellyfin.Plugin.MetaShark.Model;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
@ -45,8 +39,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
var cacheKey = $"GetByImdbID_{id}";
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
OmdbItem? item;
if (this._memoryCache.TryGetValue(cacheKey, out item))
if (this._memoryCache.TryGetValue<OmdbItem?>(cacheKey, out var item))
{
return item;
}

View File

@ -122,7 +122,8 @@ namespace Jellyfin.Plugin.MetaShark.Model
public string Birthdate { get; set; }
public string Enddate { 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 Site { get; set; }
@ -143,6 +144,20 @@ namespace Jellyfin.Plugin.MetaShark.Model
_roleType = value;
}
}
public string? DisplayOriginalName
{
get
{
// 外国人才显示英文名
if (Name.Contains("·") && Birthplace != null && !Birthplace.Contains("中国"))
{
return EnglishName;
}
return null;
}
}
}
public class DoubanPhoto

View File

@ -44,6 +44,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
protected readonly DoubanApi _doubanApi;
protected readonly TmdbApi _tmdbApi;
protected readonly OmdbApi _omdbApi;
protected readonly ImdbApi _imdbApi;
protected readonly ILibraryManager _libraryManager;
protected readonly IHttpContextAccessor _httpContextAccessor;
@ -58,43 +59,12 @@ namespace Jellyfin.Plugin.MetaShark.Providers
}
}
protected string RequestDomain
{
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)
protected BaseProvider(IHttpClientFactory httpClientFactory, ILogger logger, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi, ImdbApi imdbApi)
{
this._doubanApi = doubanApi;
this._tmdbApi = tmdbApi;
this._omdbApi = omdbApi;
this._imdbApi = imdbApi;
this._libraryManager = libraryManager;
this._logger = logger;
this._httpClientFactory = httpClientFactory;

View File

@ -19,8 +19,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
{
public class EpisodeImageProvider : BaseProvider, IRemoteImageProvider
{
public EpisodeImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<EpisodeImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
}

View File

@ -22,8 +22,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
{
private readonly IMemoryCache _memoryCache;
public EpisodeProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<EpisodeProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
this._memoryCache = new MemoryCache(new MemoryCacheOptions());
}

View File

@ -21,8 +21,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
{
public class MovieImageProvider : BaseProvider, IRemoteImageProvider
{
public MovieImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<MovieImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
}
@ -57,7 +57,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
var res = new List<RemoteImageInfo> {
new RemoteImageInfo
{
ProviderName = primary.Name,
ProviderName = this.Name,
Url = this.GetProxyImageUrl(primary.ImgMiddle),
Type = ImageType.Primary,
},

View File

@ -23,8 +23,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
{
public class MovieProvider : BaseProvider, IRemoteMetadataProvider<Movie, MovieInfo>
{
public MovieProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<MovieProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
}

View File

@ -7,7 +7,6 @@ using MediaBrowser.Model.Providers;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@ -16,8 +15,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
{
public class PersonImageProvider : BaseProvider, IRemoteImageProvider
{
public PersonImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<PersonImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
}
@ -36,6 +35,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
/// <inheritdoc />
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
{
var list = new List<RemoteImageInfo>();
var cid = item.GetProviderId(DoubanProviderId);
var metaSource = item.GetProviderId(Plugin.ProviderId);
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);
if (celebrity != null)
{
return new List<RemoteImageInfo> {
new RemoteImageInfo
{
ProviderName = celebrity.Name,
Url = this.GetProxyImageUrl(celebrity.Img),
Type = ImageType.Primary
}
};
list.Add(new RemoteImageInfo
{
ProviderName = this.Name,
Url = this.GetProxyImageUrl(celebrity.Img),
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!");
return new List<RemoteImageInfo>();
return list;
}
}

View File

@ -23,8 +23,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
/// </summary>
public class PersonProvider : BaseProvider, IRemoteMetadataProvider<Person, PersonLookupInfo>
{
public PersonProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<PersonProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
}
@ -89,6 +89,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
var item = new Person
{
// Name = c.Name.Trim(), // 名称需保持和info.Name一致不然会导致关联不到影片自动被删除
OriginalTitle = c.DisplayOriginalName, // 外国人显示英文名
HomePageUrl = c.Site,
Overview = c.Intro,
};
@ -109,6 +110,11 @@ namespace Jellyfin.Plugin.MetaShark.Providers
item.SetProviderId(DoubanProviderId, cid);
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);
// 通过imdb获取TMDB id
var findResult = await this._tmdbApi.FindByExternalIdAsync(c.Imdb, FindExternalSource.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);

View File

@ -21,8 +21,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
{
public class SeasonImageProvider : BaseProvider, IRemoteImageProvider
{
public SeasonImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeasonImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
}

View File

@ -20,8 +20,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
public class SeasonProvider : BaseProvider, IRemoteMetadataProvider<Season, SeasonInfo>
{
public SeasonProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeasonProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
}

View File

@ -21,8 +21,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
{
public class SeriesImageProvider : BaseProvider, IRemoteImageProvider
{
public SeriesImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesImageProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
}
@ -57,7 +57,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
var res = new List<RemoteImageInfo> {
new RemoteImageInfo
{
ProviderName = primary.Name,
ProviderName = this.Name,
Url = this.GetProxyImageUrl(primary.ImgMiddle),
Type = ImageType.Primary,
},

View File

@ -22,8 +22,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
{
public class SeriesProvider : BaseProvider, IRemoteMetadataProvider<Series, SeriesInfo>
{
public SeriesProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, IHttpContextAccessor httpContextAccessor, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesProvider>(), libraryManager, httpContextAccessor, doubanApi, tmdbApi, 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, imdbApi)
{
}

View File

@ -34,6 +34,10 @@ namespace Jellyfin.Plugin.MetaShark
{
return new OmdbApi(ctx.GetRequiredService<ILoggerFactory>());
});
serviceCollection.AddSingleton<ImdbApi>((ctx) =>
{
return new ImdbApi(ctx.GetRequiredService<ILoggerFactory>());
});
}
}
}