diff --git a/Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs b/Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs index 608c18e..6c53662 100644 --- a/Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs +++ b/Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -36,12 +37,13 @@ public MovieProvider(Plugin plugin, BangumiApi api, ILogger logge public async Task> GetMetadata(MovieInfo info, CancellationToken token) { token.ThrowIfCancellationRequested(); + var baseName = Path.GetFileName(info.Path); var result = new MetadataResult { ResultLanguage = Constants.Language }; var subjectId = info.ProviderIds.GetOrDefault(Constants.ProviderName); if (string.IsNullOrEmpty(subjectId)) { - var searchName = Configuration.AlwaysGetTitleByAnitomySharp ? Anitomy.ExtractAnimeTitle(info.Path) ?? info.Name : info.Name; + var searchName = Configuration.AlwaysGetTitleByAnitomySharp ? Anitomy.ExtractAnimeTitle(baseName) ?? info.Name : info.Name; _log.LogInformation("Searching {Name} in bgm.tv", searchName); var searchResult = await _api.SearchSubject(searchName, token); searchResult = Subject.SortBySimilarity(searchResult, searchName); @@ -54,7 +56,7 @@ public async Task> GetMetadata(MovieInfo info, Cancellatio // try search OriginalTitle if (string.IsNullOrEmpty(subjectId) && info.OriginalTitle != null && !string.Equals(info.OriginalTitle, info.Name, StringComparison.Ordinal)) { - var searchName = Configuration.AlwaysGetTitleByAnitomySharp ? Anitomy.ExtractAnimeTitle(info.Path) ?? info.OriginalTitle : info.OriginalTitle; + var searchName = Configuration.AlwaysGetTitleByAnitomySharp ? Anitomy.ExtractAnimeTitle(baseName) ?? info.OriginalTitle : info.OriginalTitle; _log.LogInformation("Searching {Name} in bgm.tv", searchName); var searchResult = await _api.SearchSubject(searchName, token); searchResult = Subject.SortBySimilarity(searchResult, searchName); diff --git a/Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs b/Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs index 33e0102..bdf6e04 100644 --- a/Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs +++ b/Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -35,12 +36,13 @@ public SeriesProvider(Plugin plugin, BangumiApi api, ILogger log public async Task> GetMetadata(SeriesInfo info, CancellationToken token) { token.ThrowIfCancellationRequested(); + var baseName = Path.GetFileName(info.Path); var result = new MetadataResult { ResultLanguage = Constants.Language }; var subjectId = info.ProviderIds.GetOrDefault(Constants.ProviderName); if (string.IsNullOrEmpty(subjectId)) { - var searchName = Configuration.AlwaysGetTitleByAnitomySharp ? Anitomy.ExtractAnimeTitle(info.Path) ?? info.Name : info.Name; + var searchName = Configuration.AlwaysGetTitleByAnitomySharp ? Anitomy.ExtractAnimeTitle(baseName) ?? info.Name : info.Name; _log.LogInformation("Searching {Name} in bgm.tv", searchName); var searchResult = await _api.SearchSubject(searchName, token); searchResult = Subject.SortBySimilarity(searchResult, searchName); @@ -53,7 +55,7 @@ public async Task> GetMetadata(SeriesInfo info, Cancellat // try search OriginalTitle if (string.IsNullOrEmpty(subjectId) && info.OriginalTitle != null && !string.Equals(info.OriginalTitle, info.Name, StringComparison.Ordinal)) { - var searchName = Configuration.AlwaysGetTitleByAnitomySharp ? Anitomy.ExtractAnimeTitle(info.Path) ?? info.OriginalTitle : info.OriginalTitle; + var searchName = Configuration.AlwaysGetTitleByAnitomySharp ? Anitomy.ExtractAnimeTitle(baseName) ?? info.OriginalTitle : info.OriginalTitle; _log.LogInformation("Searching {Name} in bgm.tv", searchName); var searchResult = await _api.SearchSubject(searchName, token); searchResult = Subject.SortBySimilarity(searchResult, searchName);