fix: fix find tmdb id by season imdb

This commit is contained in:
cxfksword 2024-04-13 15:25:54 +08:00
parent 23d10b94ed
commit 2eca5c9a22
3 changed files with 37 additions and 1 deletions

View File

@ -8,6 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using TMDbLib.Objects.Find;
using TMDbLib.Objects.Languages;
namespace Jellyfin.Plugin.MetaShark.Test
@ -124,5 +125,27 @@ namespace Jellyfin.Plugin.MetaShark.Test
}).GetAwaiter().GetResult();
}
[TestMethod]
public void TestFindByExternalId()
{
var api = new TmdbApi(loggerFactory);
Task.Run(async () =>
{
try
{
var result = await api.FindByExternalIdAsync("tt5924366", FindExternalSource.Imdb, "zh", CancellationToken.None)
.ConfigureAwait(false);
Assert.IsNotNull(result);
TestContext.WriteLine(result.ToJson());
}
catch (Exception ex)
{
TestContext.WriteLine(ex.Message);
}
}).GetAwaiter().GetResult();
}
}
}

View File

@ -25,7 +25,7 @@
<PackageReference Include="Jellyfin.Controller" Version="10.8.0" />
<PackageReference Include="Jellyfin.Model" Version="10.8.0" />
<PackageReference Include="RateLimiter" Version="2.2.0" />
<PackageReference Include="TMDbLib" Version="2.0.0" />
<PackageReference Include="TMDbLib" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />

View File

@ -351,6 +351,18 @@ namespace Jellyfin.Plugin.MetaShark.Providers
this.Log($"Found tmdb [id]: {tmdbId} by imdb id: {imdb}");
return $"{tmdbId}";
}
if (findResult?.TvEpisode != null && findResult.TvEpisode.Count > 0)
{
var tmdbId = findResult.TvEpisode[0].ShowId;
this.Log($"Found tmdb [id]: {tmdbId} by imdb id: {imdb}");
return $"{tmdbId}";
}
if (findResult?.TvSeason != null && findResult.TvSeason.Count > 0)
{
var tmdbId = findResult.TvSeason[0].ShowId;
this.Log($"Found tmdb [id]: {tmdbId} by imdb id: {imdb}");
return $"{tmdbId}";
}
break;
default:
break;
@ -386,6 +398,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
// 当没有season级目录时path为空直接返回
if (string.IsNullOrEmpty(path))
{
this.Log($"Season path is empty!");
return null;
}