Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kookxiang committed Jul 17, 2022
1 parent c9a8d9f commit 1c006dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -36,12 +37,13 @@ public MovieProvider(Plugin plugin, BangumiApi api, ILogger<MovieProvider> logge
public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, CancellationToken token)
{
token.ThrowIfCancellationRequested();
var baseName = Path.GetFileName(info.Path);
var result = new MetadataResult<Movie> { 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);
Expand All @@ -54,7 +56,7 @@ public async Task<MetadataResult<Movie>> 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);
Expand Down
6 changes: 4 additions & 2 deletions Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -35,12 +36,13 @@ public SeriesProvider(Plugin plugin, BangumiApi api, ILogger<SeriesProvider> log
public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, CancellationToken token)
{
token.ThrowIfCancellationRequested();
var baseName = Path.GetFileName(info.Path);
var result = new MetadataResult<Series> { 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);
Expand All @@ -53,7 +55,7 @@ public async Task<MetadataResult<Series>> 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);
Expand Down

0 comments on commit 1c006dc

Please sign in to comment.