Skip to content

Commit

Permalink
Support movie collections
Browse files Browse the repository at this point in the history
  • Loading branch information
cxfksword committed Feb 17, 2023
1 parent 885217f commit e982ea1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
39 changes: 19 additions & 20 deletions Jellyfin.Plugin.MetaShark/Providers/MovieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,26 @@ public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, Cancellatio
movie.SetProviderId(MetadataProvider.Imdb, subject.Imdb);

// 通过imdb获取TMDB id
if (string.IsNullOrEmpty(tmdbId))
tmdbId = await this.GetTmdbIdByImdbAsync(subject.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(tmdbId))
{
tmdbId = await this.GetTmdbIdByImdbAsync(subject.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(tmdbId))
{
movie.SetProviderId(MetadataProvider.Tmdb, tmdbId);

// 获取电影系列信息
if (this.config.EnableTmdbCollection)
{
var movieResult = await _tmdbApi
.GetMovieAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), info.MetadataLanguage, info.MetadataLanguage, cancellationToken)
.ConfigureAwait(false);
if (movieResult != null && movieResult.BelongsToCollection != null)
{
movie.CollectionName = movieResult.BelongsToCollection.Name;
}
}
}
movie.SetProviderId(MetadataProvider.Tmdb, tmdbId);
}
}

// 通过imdb获取电影系列信息
if (this.config.EnableTmdbCollection && !string.IsNullOrEmpty(tmdbId))
{
var movieResult = await _tmdbApi
.GetMovieAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), info.MetadataLanguage, info.MetadataLanguage, cancellationToken)
.ConfigureAwait(false);
if (movieResult != null && movieResult.BelongsToCollection != null)
{
movie.CollectionName = movieResult.BelongsToCollection.Name;
}
}


result.Item = movie;
result.QueriedById = true;
result.HasMetadata = true;
Expand All @@ -175,8 +174,8 @@ public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, Cancellatio
{
this.Log($"GetMovieMetadata of tmdb [id]: \"{tmdbId}\"");
var movieResult = await _tmdbApi
.GetMovieAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), info.MetadataLanguage, info.MetadataLanguage, cancellationToken)
.ConfigureAwait(false);
.GetMovieAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), info.MetadataLanguage, info.MetadataLanguage, cancellationToken)
.ConfigureAwait(false);

if (movieResult == null)
{
Expand Down
12 changes: 5 additions & 7 deletions Jellyfin.Plugin.MetaShark/Providers/SeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,15 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, Cancellat
PremiereDate = subject.ScreenTime,
};

// 通过imdb获取tmdbId
if (!string.IsNullOrEmpty(subject.Imdb))
{
item.SetProviderId(MetadataProvider.Imdb, subject.Imdb);
if (string.IsNullOrEmpty(tmdbId))

// 通过imdb获取TMDB id
tmdbId = await this.GetTmdbIdByImdbAsync(subject.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(tmdbId))
{
tmdbId = await this.GetTmdbIdByImdbAsync(subject.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(tmdbId))
{
item.SetProviderId(MetadataProvider.Tmdb, tmdbId);
}
item.SetProviderId(MetadataProvider.Tmdb, tmdbId);
}
}

Expand Down

0 comments on commit e982ea1

Please sign in to comment.