mirror of
https://github.com/cxfksword/jellyfin-plugin-danmu.git
synced 2026-04-23 18:12:00 +08:00
Optimize bilibili match
This commit is contained in:
@@ -73,7 +73,7 @@ namespace Jellyfin.Plugin.Danmu.Test
|
||||
|
||||
var item = new Movie
|
||||
{
|
||||
Name = "异邦人:无皇刃谭"
|
||||
Name = "扬名立万"
|
||||
};
|
||||
|
||||
var list = new List<LibraryEvent>();
|
||||
@@ -162,5 +162,40 @@ namespace Jellyfin.Plugin.Danmu.Test
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void TestAddSeason()
|
||||
{
|
||||
var scraperManager = new ScraperManager(loggerFactory);
|
||||
scraperManager.register(new Bilibili(loggerFactory));
|
||||
|
||||
var fileSystemStub = new Mock<Jellyfin.Plugin.Danmu.Core.IFileSystem>();
|
||||
var directoryServiceStub = new Mock<IDirectoryService>();
|
||||
var libraryManagerStub = new Mock<ILibraryManager>();
|
||||
var libraryManagerEventsHelper = new LibraryManagerEventsHelper(libraryManagerStub.Object, loggerFactory, fileSystemStub.Object, scraperManager);
|
||||
|
||||
var item = new Season
|
||||
{
|
||||
Name = "逃避虽可耻但有用",
|
||||
ProductionYear = 2016,
|
||||
};
|
||||
|
||||
var list = new List<LibraryEvent>();
|
||||
list.Add(new LibraryEvent { Item = item, EventType = EventType.Add });
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await libraryManagerEventsHelper.ProcessQueuedSeasonEvents(list, EventType.Add);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}).GetAwaiter().GetResult();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,6 +351,7 @@ public class Bilibili : AbstractScraper
|
||||
{
|
||||
try
|
||||
{
|
||||
var isMovieItemType = item is MediaBrowser.Controller.Entities.Movies.Movie;
|
||||
var searchResult = await _api.SearchAsync(searchName, CancellationToken.None).ConfigureAwait(false);
|
||||
if (searchResult != null && searchResult.Result != null)
|
||||
{
|
||||
@@ -364,6 +365,16 @@ public class Bilibili : AbstractScraper
|
||||
var title = media.Title;
|
||||
var pubYear = Jellyfin.Plugin.Danmu.Core.Utils.UnixTimeStampToDateTime(media.PublishTime).Year;
|
||||
|
||||
if (isMovieItemType && media.SeasonTypeName != "电影")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isMovieItemType && media.SeasonTypeName == "电影")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检测标题是否相似(越大越相似)
|
||||
var score = searchName.Distance(title);
|
||||
if (score < 0.7)
|
||||
|
||||
Reference in New Issue
Block a user