Skip to content

Commit

Permalink
Optimize season meta fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
cxfksword committed Oct 30, 2022
1 parent 02db679 commit be91a0a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class EpisodeImageProvider : BaseProvider, IRemoteImageProvider
/// <param name="logger">Instance of the <see cref="ILogger{OddbImageProvider}"/> interface.</param>
/// <param name="doubanApi">Instance of <see cref="DoubanApi"/>.</param>
public EpisodeImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<EpisodeImageProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
{
}

Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.MetaShark/Providers/MovieImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MovieImageProvider : BaseProvider, IRemoteImageProvider
/// <param name="logger">Instance of the <see cref="ILogger{OddbImageProvider}"/> interface.</param>
/// <param name="doubanApi">Instance of <see cref="DoubanApi"/>.</param>
public MovieImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<MovieImageProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
{
}

Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.MetaShark/Providers/MovieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
public class MovieProvider : BaseProvider, IRemoteMetadataProvider<Movie, MovieInfo>
{
public MovieProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<MovieProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
{
}

Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.MetaShark/Providers/SeasonImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SeasonImageProvider : BaseProvider, IRemoteImageProvider
/// <param name="logger">Instance of the <see cref="ILogger{OddbImageProvider}"/> interface.</param>
/// <param name="doubanApi">Instance of <see cref="DoubanApi"/>.</param>
public SeasonImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeasonImageProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
{
}

Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.MetaShark/Providers/SeriesImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class SeriesImageProvider : BaseProvider, IRemoteImageProvider
/// <param name="logger">Instance of the <see cref="ILogger{OddbImageProvider}"/> interface.</param>
/// <param name="doubanApi">Instance of <see cref="DoubanApi"/>.</param>
public SeriesImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, ILibraryManager libraryManager, DoubanApi doubanApi, TmdbApi tmdbApi, OmdbApi omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
: base(httpClientFactory, loggerFactory.CreateLogger<SeriesImageProvider>(), libraryManager, doubanApi, tmdbApi, omdbApi)
{
}

Expand Down
17 changes: 15 additions & 2 deletions Jellyfin.Plugin.MetaShark/Providers/SeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, Cancellat
// ProductionLocations = [x?.Country],
PremiereDate = subject.ScreenTime,
};

// 通过imdb获取tmdbId
if (!string.IsNullOrEmpty(subject.Imdb))
{
item.SetProviderId(MetadataProvider.Imdb, subject.Imdb);
Expand All @@ -131,13 +133,24 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, Cancellat
var findResult = await this._tmdbApi.FindByExternalIdAsync(omdbItem.ImdbID, FindExternalSource.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
if (findResult?.TvResults != null && findResult.TvResults.Count > 0)
{
this.Log($"GetSeriesMetadata found tmdb [id]: {findResult.TvResults[0].Id} by imdb id: {subject.Imdb}");
item.SetProviderId(MetadataProvider.Tmdb, $"{findResult.TvResults[0].Id}");
tmdbId = $"{findResult.TvResults[0].Id}";
this.Log($"GetSeriesMetadata found tmdb [id]: {tmdbId} by imdb id: {subject.Imdb}");
item.SetProviderId(MetadataProvider.Tmdb, tmdbId);
}
}
}
}

// 尝试通过搜索匹配获取tmdbId
if (string.IsNullOrEmpty(tmdbId))
{
tmdbId = await this.GuestByTmdbAsync(info, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(tmdbId))
{
item.SetProviderId(MetadataProvider.Tmdb, tmdbId);
}
}


result.Item = item;
result.QueriedById = true;
Expand Down

0 comments on commit be91a0a

Please sign in to comment.