mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-02-15 17:12:23 +00:00
Fix build
This commit is contained in:
@@ -18,7 +18,7 @@ public static class TvParserHelpers
|
||||
/// <param name="status">The status string.</param>
|
||||
/// <param name="enumValue">The <see cref="SeriesStatus"/>.</param>
|
||||
/// <returns>Returns true if parsing was successful.</returns>
|
||||
public static bool TryParseSeriesStatus(string status, out SeriesStatus? enumValue)
|
||||
public static bool TryParseSeriesStatus(string? status, out SeriesStatus? enumValue)
|
||||
{
|
||||
if (Enum.TryParse(status, true, out SeriesStatus seriesStatus))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
@@ -19,7 +18,7 @@ namespace MediaBrowser.Model.Providers
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the provider ids.
|
||||
@@ -41,13 +40,13 @@ namespace MediaBrowser.Model.Providers
|
||||
|
||||
public DateTime? PremiereDate { get; set; }
|
||||
|
||||
public string ImageUrl { get; set; }
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
public string SearchProviderName { get; set; }
|
||||
public string? SearchProviderName { get; set; }
|
||||
|
||||
public string Overview { get; set; }
|
||||
public string? Overview { get; set; }
|
||||
|
||||
public RemoteSearchResult AlbumArtist { get; set; }
|
||||
public RemoteSearchResult? AlbumArtist { get; set; }
|
||||
|
||||
public RemoteSearchResult[] Artists { get; set; }
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Api
|
||||
/// <returns>The image portion of the TMDb client configuration.</returns>
|
||||
[HttpGet("ClientConfiguration")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ConfigImageTypes> TmdbClientConfiguration()
|
||||
public async Task<ConfigImageTypes?> TmdbClientConfiguration()
|
||||
{
|
||||
return (await _tmdbClientManager.GetClientConfiguration().ConfigureAwait(false)).Images;
|
||||
}
|
||||
|
||||
@@ -75,10 +75,17 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
||||
|
||||
var posters = collection.Images.Posters;
|
||||
var backdrops = collection.Images.Backdrops;
|
||||
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count);
|
||||
var remoteImages = new List<RemoteImageInfo>(posters?.Count ?? 0 + backdrops?.Count ?? 0);
|
||||
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language));
|
||||
if (posters is not null)
|
||||
{
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language));
|
||||
}
|
||||
|
||||
if (backdrops is not null)
|
||||
{
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language));
|
||||
}
|
||||
|
||||
return remoteImages;
|
||||
}
|
||||
|
||||
@@ -67,10 +67,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
||||
|
||||
result.SetProviderId(MetadataProvider.Tmdb, collection.Id.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
return new[] { result };
|
||||
return [result];
|
||||
}
|
||||
|
||||
var collectionSearchResults = await _tmdbClientManager.SearchCollectionAsync(searchInfo.Name, language, searchInfo.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||
if (collectionSearchResults is null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var collections = new RemoteSearchResult[collectionSearchResults.Count];
|
||||
for (var i = 0; i < collectionSearchResults.Count; i++)
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
|
||||
if (movieTmdbId <= 0)
|
||||
{
|
||||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
return [];
|
||||
}
|
||||
|
||||
// TODO use image languages if All Languages isn't toggled, but there's currently no way to get that value in here
|
||||
@@ -89,17 +89,28 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
|
||||
if (movie?.Images is null)
|
||||
{
|
||||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
return [];
|
||||
}
|
||||
|
||||
var posters = movie.Images.Posters;
|
||||
var backdrops = movie.Images.Backdrops;
|
||||
var logos = movie.Images.Logos;
|
||||
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count + logos.Count);
|
||||
var remoteImages = new List<RemoteImageInfo>(posters?.Count ?? 0 + backdrops?.Count ?? 0 + logos?.Count ?? 0);
|
||||
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language));
|
||||
if (posters is not null)
|
||||
{
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language));
|
||||
}
|
||||
|
||||
if (backdrops is not null)
|
||||
{
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language));
|
||||
}
|
||||
|
||||
if (logos is not null)
|
||||
{
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language));
|
||||
}
|
||||
|
||||
return remoteImages;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using TMDbLib.Objects.Find;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Search;
|
||||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
@@ -84,7 +85,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
remoteResult.SetProviderId(MetadataProvider.Tmdb, movie.Id.ToString(CultureInfo.InvariantCulture));
|
||||
remoteResult.TrySetProviderId(MetadataProvider.Imdb, movie.ImdbId);
|
||||
|
||||
return new[] { remoteResult };
|
||||
return [remoteResult];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +119,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (movieResults is null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var len = movieResults.Count;
|
||||
var remoteSearchResults = new RemoteSearchResult[len];
|
||||
for (var i = 0; i < len; i++)
|
||||
@@ -158,7 +164,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
|
||||
var searchResults = await _tmdbClientManager.SearchMovieAsync(cleanedName, info.Year ?? parsedName.Year ?? 0, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (searchResults.Count > 0)
|
||||
if (searchResults?.Count > 0)
|
||||
{
|
||||
tmdbId = searchResults[0].Id.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
@@ -167,7 +173,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
if (string.IsNullOrEmpty(tmdbId) && !string.IsNullOrEmpty(imdbId))
|
||||
{
|
||||
var movieResultFromImdbId = await _tmdbClientManager.FindByExternalIdAsync(imdbId, FindExternalSource.Imdb, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||
if (movieResultFromImdbId?.MovieResults.Count > 0)
|
||||
if (movieResultFromImdbId?.MovieResults?.Count > 0)
|
||||
{
|
||||
tmdbId = movieResultFromImdbId.MovieResults[0].Id.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
@@ -193,7 +199,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
OriginalTitle = movieResult.OriginalTitle,
|
||||
Overview = movieResult.Overview?.Replace("\n\n", "\n", StringComparison.InvariantCulture),
|
||||
Tagline = movieResult.Tagline,
|
||||
ProductionLocations = movieResult.ProductionCountries.Select(pc => pc.Name).ToArray()
|
||||
ProductionLocations = movieResult.ProductionCountries?.Select(pc => pc.Name).ToArray() ?? Array.Empty<string>()
|
||||
};
|
||||
var metadataResult = new MetadataResult<Movie>
|
||||
{
|
||||
@@ -218,14 +224,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
|
||||
var ourRelease = releases.FirstOrDefault(c => string.Equals(c.Iso_3166_1, info.MetadataCountryCode, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (ourRelease is not null)
|
||||
if (ourRelease?.Certification is not null)
|
||||
{
|
||||
movie.OfficialRating = TmdbUtils.BuildParentalRating(ourRelease.Iso_3166_1, ourRelease.Certification);
|
||||
movie.OfficialRating = TmdbUtils.BuildParentalRating(info.MetadataCountryCode, ourRelease.Certification);
|
||||
}
|
||||
else
|
||||
{
|
||||
var usRelease = releases.FirstOrDefault(c => string.Equals(c.Iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));
|
||||
if (usRelease is not null)
|
||||
if (usRelease?.Certification is not null)
|
||||
{
|
||||
movie.OfficialRating = usRelease.Certification;
|
||||
}
|
||||
@@ -242,16 +248,23 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
|
||||
var genres = movieResult.Genres;
|
||||
|
||||
foreach (var genre in genres.Select(g => g.Name).Trimmed())
|
||||
if (genres is not null)
|
||||
{
|
||||
movie.AddGenre(genre);
|
||||
foreach (var genre in genres.Select(g => g.Name).Trimmed())
|
||||
{
|
||||
movie.AddGenre(genre);
|
||||
}
|
||||
}
|
||||
|
||||
if (movieResult.Keywords?.Keywords is not null)
|
||||
{
|
||||
for (var i = 0; i < movieResult.Keywords.Keywords.Count; i++)
|
||||
foreach (var keyword in movieResult.Keywords.Keywords)
|
||||
{
|
||||
movie.AddTag(movieResult.Keywords.Keywords[i].Name);
|
||||
var name = keyword.Name;
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
movie.AddTag(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,13 +56,17 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
||||
}
|
||||
|
||||
result.SetProviderId(MetadataProvider.Tmdb, personResult.Id.ToString(CultureInfo.InvariantCulture));
|
||||
result.TrySetProviderId(MetadataProvider.Imdb, personResult.ExternalIds.ImdbId);
|
||||
result.TrySetProviderId(MetadataProvider.Imdb, personResult.ExternalIds?.ImdbId);
|
||||
|
||||
return new[] { result };
|
||||
return [result];
|
||||
}
|
||||
}
|
||||
|
||||
var personSearchResult = await _tmdbClientManager.SearchPersonAsync(searchInfo.Name, cancellationToken).ConfigureAwait(false);
|
||||
if (personSearchResult is null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var remoteSearchResults = new RemoteSearchResult[personSearchResult.Count];
|
||||
for (var i = 0; i < personSearchResult.Count; i++)
|
||||
@@ -91,7 +95,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
||||
if (personTmdbId <= 0)
|
||||
{
|
||||
var personSearchResults = await _tmdbClientManager.SearchPersonAsync(info.Name, cancellationToken).ConfigureAwait(false);
|
||||
if (personSearchResults.Count > 0)
|
||||
if (personSearchResults?.Count > 0)
|
||||
{
|
||||
personTmdbId = personSearchResults[0].Id;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
result.Item.Name = seasonResult.Name;
|
||||
}
|
||||
|
||||
result.Item.TrySetProviderId(MetadataProvider.Tvdb, seasonResult.ExternalIds.TvdbId);
|
||||
result.Item.TrySetProviderId(MetadataProvider.Tvdb, seasonResult.ExternalIds?.TvdbId);
|
||||
|
||||
// TODO why was this disabled?
|
||||
var credits = seasonResult.Credits;
|
||||
|
||||
@@ -79,11 +79,22 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
var posters = series.Images.Posters;
|
||||
var backdrops = series.Images.Backdrops;
|
||||
var logos = series.Images.Logos;
|
||||
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count + logos.Count);
|
||||
var remoteImages = new List<RemoteImageInfo>(posters?.Count ?? 0 + backdrops?.Count ?? 0 + logos?.Count ?? 0);
|
||||
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language));
|
||||
if (posters is not null)
|
||||
{
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language));
|
||||
}
|
||||
|
||||
if (backdrops is not null)
|
||||
{
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language));
|
||||
}
|
||||
|
||||
if (logos is not null)
|
||||
{
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language));
|
||||
}
|
||||
|
||||
return remoteImages;
|
||||
}
|
||||
|
||||
@@ -112,6 +112,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
|
||||
var tvSearchResults = await _tmdbClientManager.SearchSeriesAsync(searchInfo.Name, searchInfo.MetadataLanguage, searchInfo.MetadataCountryCode, cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
if (tvSearchResults is null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var remoteResults = new RemoteSearchResult[tvSearchResults.Count];
|
||||
for (var i = 0; i < tvSearchResults.Count; i++)
|
||||
@@ -176,7 +180,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
if (string.IsNullOrEmpty(tmdbId) && info.TryGetProviderId(MetadataProvider.Imdb, out var imdbId))
|
||||
{
|
||||
var searchResult = await _tmdbClientManager.FindByExternalIdAsync(imdbId, FindExternalSource.Imdb, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||
if (searchResult?.TvResults.Count > 0)
|
||||
if (searchResult?.TvResults?.Count > 0)
|
||||
{
|
||||
tmdbId = searchResult.TvResults[0].Id.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
@@ -185,7 +189,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
if (string.IsNullOrEmpty(tmdbId) && info.TryGetProviderId(MetadataProvider.Tvdb, out var tvdbId))
|
||||
{
|
||||
var searchResult = await _tmdbClientManager.FindByExternalIdAsync(tvdbId, FindExternalSource.TvDb, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||
if (searchResult?.TvResults.Count > 0)
|
||||
if (searchResult?.TvResults?.Count > 0)
|
||||
{
|
||||
tmdbId = searchResult.TvResults[0].Id.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
@@ -200,7 +204,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
var cleanedName = TmdbUtils.CleanName(parsedName.Name);
|
||||
var searchResults = await _tmdbClientManager.SearchSeriesAsync(cleanedName, info.MetadataLanguage, info.MetadataCountryCode, info.Year ?? parsedName.Year ?? 0, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (searchResults.Count > 0)
|
||||
if (searchResults?.Count > 0)
|
||||
{
|
||||
tmdbId = searchResults[0].Id.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
@@ -264,15 +268,19 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
|
||||
if (seriesResult.Keywords?.Results is not null)
|
||||
{
|
||||
for (var i = 0; i < seriesResult.Keywords.Results.Count; i++)
|
||||
foreach (var result in seriesResult.Keywords.Results)
|
||||
{
|
||||
series.AddTag(seriesResult.Keywords.Results[i].Name);
|
||||
var name = result.Name;
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
series.AddTag(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
series.HomePageUrl = seriesResult.Homepage;
|
||||
|
||||
series.RunTimeTicks = seriesResult.EpisodeRunTime.Select(i => TimeSpan.FromMinutes(i).Ticks).FirstOrDefault();
|
||||
series.RunTimeTicks = seriesResult.EpisodeRunTime?.Select(i => TimeSpan.FromMinutes(i).Ticks).FirstOrDefault();
|
||||
|
||||
if (Emby.Naming.TV.TvParserHelpers.TryParseSeriesStatus(seriesResult.Status, out var seriesStatus))
|
||||
{
|
||||
@@ -291,21 +299,21 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
series.TrySetProviderId(MetadataProvider.Tvdb, ids.TvdbId);
|
||||
}
|
||||
|
||||
var contentRatings = seriesResult.ContentRatings.Results ?? new List<ContentRating>();
|
||||
var contentRatings = seriesResult.ContentRatings?.Results ?? new List<ContentRating>();
|
||||
|
||||
var ourRelease = contentRatings.FirstOrDefault(c => string.Equals(c.Iso_3166_1, preferredCountryCode, StringComparison.OrdinalIgnoreCase));
|
||||
var usRelease = contentRatings.FirstOrDefault(c => string.Equals(c.Iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));
|
||||
var minimumRelease = contentRatings.FirstOrDefault();
|
||||
|
||||
if (ourRelease is not null)
|
||||
if (ourRelease?.Rating is not null)
|
||||
{
|
||||
series.OfficialRating = TmdbUtils.BuildParentalRating(ourRelease.Iso_3166_1, ourRelease.Rating);
|
||||
series.OfficialRating = TmdbUtils.BuildParentalRating(preferredCountryCode, ourRelease.Rating);
|
||||
}
|
||||
else if (usRelease is not null)
|
||||
else if (usRelease?.Rating is not null)
|
||||
{
|
||||
series.OfficialRating = usRelease.Rating;
|
||||
}
|
||||
else if (minimumRelease is not null)
|
||||
else if (minimumRelease?.Rating is not null)
|
||||
{
|
||||
series.OfficialRating = minimumRelease.Rating;
|
||||
}
|
||||
@@ -350,7 +358,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
Role = actor.Character?.Trim() ?? string.Empty,
|
||||
Type = PersonKind.Actor,
|
||||
SortOrder = actor.Order,
|
||||
ImageUrl = _tmdbClientManager.GetProfileUrl(actor.ProfilePath)
|
||||
// NOTE: Null values are filtered out above
|
||||
ImageUrl = _tmdbClientManager.GetProfileUrl(actor.ProfilePath!)
|
||||
};
|
||||
|
||||
if (actor.Id > 0)
|
||||
@@ -391,7 +400,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
Name = crewMember.Name.Trim(),
|
||||
Role = crewMember.Job?.Trim() ?? string.Empty,
|
||||
Type = entry.PersonType,
|
||||
ImageUrl = _tmdbClientManager.GetProfileUrl(crewMember.ProfilePath)
|
||||
// NOTE: Null values are filtered out above
|
||||
ImageUrl = _tmdbClientManager.GetProfileUrl(crewMember.ProfilePath!)
|
||||
};
|
||||
|
||||
if (crewMember.Id > 0)
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
@@ -195,7 +194,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
await EnsureClientConfigAsync().ConfigureAwait(false);
|
||||
|
||||
var series = await GetSeriesAsync(tvShowId, language, imageLanguages, countryCode, cancellationToken).ConfigureAwait(false);
|
||||
var episodeGroupId = series?.EpisodeGroups.Results.Find(g => g.Type == groupType)?.Id;
|
||||
var episodeGroupId = series?.EpisodeGroups?.Results?.Find(g => g.Type == groupType)?.Id;
|
||||
|
||||
if (episodeGroupId is null)
|
||||
{
|
||||
@@ -263,7 +262,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="countryCode">The country code, ISO 3166-1.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The TMDb tv episode information or null if not found.</returns>
|
||||
public async Task<TvEpisode?> GetEpisodeAsync(int tvShowId, int seasonNumber, int episodeNumber, string displayOrder, string? language, string? imageLanguages, string? countryCode, CancellationToken cancellationToken)
|
||||
public async Task<TvEpisode?> GetEpisodeAsync(int tvShowId, int seasonNumber, long episodeNumber, string displayOrder, string? language, string? imageLanguages, string? countryCode, CancellationToken cancellationToken)
|
||||
{
|
||||
var key = $"episode-{tvShowId.ToString(CultureInfo.InvariantCulture)}-s{seasonNumber.ToString(CultureInfo.InvariantCulture)}e{episodeNumber.ToString(CultureInfo.InvariantCulture)}-{displayOrder}-{language}";
|
||||
if (_memoryCache.TryGetValue(key, out TvEpisode? episode))
|
||||
@@ -276,9 +275,9 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
var group = await GetSeriesGroupAsync(tvShowId, displayOrder, language, imageLanguages, countryCode, cancellationToken).ConfigureAwait(false);
|
||||
if (group is not null)
|
||||
{
|
||||
var season = group.Groups.Find(s => s.Order == seasonNumber);
|
||||
var season = group.Groups?.Find(s => s.Order == seasonNumber);
|
||||
// Episode order starts at 0
|
||||
var ep = season?.Episodes.Find(e => e.Order == episodeNumber - 1);
|
||||
var ep = season?.Episodes?.Find(e => e.Order == episodeNumber - 1);
|
||||
if (ep is not null)
|
||||
{
|
||||
seasonNumber = ep.SeasonNumber;
|
||||
@@ -382,7 +381,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="year">The year the tv show first aired.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The TMDb tv show information.</returns>
|
||||
public async Task<IReadOnlyList<SearchTv>> SearchSeriesAsync(string name, string language, string? countryCode, int year = 0, CancellationToken cancellationToken = default)
|
||||
public async Task<IReadOnlyList<SearchTv>?> SearchSeriesAsync(string name, string language, string? countryCode, int year = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var key = $"searchseries-{name}-{year.ToString(CultureInfo.InvariantCulture)}-{language}";
|
||||
if (_memoryCache.TryGetValue(key, out SearchContainer<SearchTv>? series) && series is not null)
|
||||
@@ -396,12 +395,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
.SearchTvShowAsync(name, TmdbUtils.NormalizeLanguage(language, countryCode), includeAdult: Plugin.Instance.Configuration.IncludeAdult, firstAirDateYear: year, cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (searchResults.Results.Count > 0)
|
||||
if (searchResults?.Results?.Count > 0)
|
||||
{
|
||||
_memoryCache.Set(key, searchResults, TimeSpan.FromHours(CacheDurationInHours));
|
||||
}
|
||||
|
||||
return searchResults.Results;
|
||||
return searchResults?.Results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -410,7 +409,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="name">The name of the person.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The TMDb person information.</returns>
|
||||
public async Task<IReadOnlyList<SearchPerson>> SearchPersonAsync(string name, CancellationToken cancellationToken)
|
||||
public async Task<IReadOnlyList<SearchPerson>?> SearchPersonAsync(string name, CancellationToken cancellationToken)
|
||||
{
|
||||
var key = $"searchperson-{name}";
|
||||
if (_memoryCache.TryGetValue(key, out SearchContainer<SearchPerson>? person) && person is not null)
|
||||
@@ -424,12 +423,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
.SearchPersonAsync(name, includeAdult: Plugin.Instance.Configuration.IncludeAdult, cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (searchResults.Results.Count > 0)
|
||||
if (searchResults?.Results?.Count > 0)
|
||||
{
|
||||
_memoryCache.Set(key, searchResults, TimeSpan.FromHours(CacheDurationInHours));
|
||||
}
|
||||
|
||||
return searchResults.Results;
|
||||
return searchResults?.Results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -439,7 +438,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="language">The movie's language.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The TMDb movie information.</returns>
|
||||
public Task<IReadOnlyList<SearchMovie>> SearchMovieAsync(string name, string language, CancellationToken cancellationToken)
|
||||
public Task<IReadOnlyList<SearchMovie>?> SearchMovieAsync(string name, string language, CancellationToken cancellationToken)
|
||||
{
|
||||
return SearchMovieAsync(name, 0, language, null, cancellationToken);
|
||||
}
|
||||
@@ -453,7 +452,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="countryCode">The country code, ISO 3166-1.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The TMDb movie information.</returns>
|
||||
public async Task<IReadOnlyList<SearchMovie>> SearchMovieAsync(string name, int year, string language, string? countryCode, CancellationToken cancellationToken)
|
||||
public async Task<IReadOnlyList<SearchMovie>?> SearchMovieAsync(string name, int year, string language, string? countryCode, CancellationToken cancellationToken)
|
||||
{
|
||||
var key = $"moviesearch-{name}-{year.ToString(CultureInfo.InvariantCulture)}-{language}";
|
||||
if (_memoryCache.TryGetValue(key, out SearchContainer<SearchMovie>? movies) && movies is not null)
|
||||
@@ -467,12 +466,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
.SearchMovieAsync(name, TmdbUtils.NormalizeLanguage(language, countryCode), includeAdult: Plugin.Instance.Configuration.IncludeAdult, year: year, cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (searchResults.Results.Count > 0)
|
||||
if (searchResults?.Results?.Count > 0)
|
||||
{
|
||||
_memoryCache.Set(key, searchResults, TimeSpan.FromHours(CacheDurationInHours));
|
||||
}
|
||||
|
||||
return searchResults.Results;
|
||||
return searchResults?.Results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -483,7 +482,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="countryCode">The country code, ISO 3166-1.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The TMDb collection information.</returns>
|
||||
public async Task<IReadOnlyList<SearchCollection>> SearchCollectionAsync(string name, string language, string? countryCode, CancellationToken cancellationToken)
|
||||
public async Task<IReadOnlyList<SearchCollection>?> SearchCollectionAsync(string name, string language, string? countryCode, CancellationToken cancellationToken)
|
||||
{
|
||||
var key = $"collectionsearch-{name}-{language}";
|
||||
if (_memoryCache.TryGetValue(key, out SearchContainer<SearchCollection>? collections) && collections is not null)
|
||||
@@ -497,12 +496,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
.SearchCollectionAsync(name, TmdbUtils.NormalizeLanguage(language, countryCode), cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (searchResults.Results.Count > 0)
|
||||
if (searchResults?.Results?.Count > 0)
|
||||
{
|
||||
_memoryCache.Set(key, searchResults, TimeSpan.FromHours(CacheDurationInHours));
|
||||
}
|
||||
|
||||
return searchResults.Results;
|
||||
return searchResults?.Results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -511,7 +510,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="size">The image size to fetch.</param>
|
||||
/// <param name="path">The relative URL of the image.</param>
|
||||
/// <returns>The absolute URL.</returns>
|
||||
private string? GetUrl(string? size, string path)
|
||||
private string? GetUrl(string? size, string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
@@ -529,7 +528,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// </summary>
|
||||
/// <param name="posterPath">The relative URL of the poster.</param>
|
||||
/// <returns>The absolute URL.</returns>
|
||||
public string? GetPosterUrl(string posterPath)
|
||||
public string? GetPosterUrl(string? posterPath)
|
||||
{
|
||||
return GetUrl(Plugin.Instance.Configuration.PosterSize, posterPath);
|
||||
}
|
||||
@@ -539,7 +538,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// </summary>
|
||||
/// <param name="actorProfilePath">The relative URL of the profile image.</param>
|
||||
/// <returns>The absolute URL.</returns>
|
||||
public string? GetProfileUrl(string actorProfilePath)
|
||||
public string? GetProfileUrl(string? actorProfilePath)
|
||||
{
|
||||
return GetUrl(Plugin.Instance.Configuration.ProfileSize, actorProfilePath);
|
||||
}
|
||||
@@ -642,30 +641,44 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
private static void ValidatePreferences(TMDbConfig config)
|
||||
{
|
||||
var imageConfig = config.Images;
|
||||
if (imageConfig is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var pluginConfig = Plugin.Instance.Configuration;
|
||||
|
||||
if (!imageConfig.PosterSizes.Contains(pluginConfig.PosterSize))
|
||||
if (imageConfig.PosterSizes is not null
|
||||
&& pluginConfig.PosterSize is not null
|
||||
&& !imageConfig.PosterSizes.Contains(pluginConfig.PosterSize))
|
||||
{
|
||||
pluginConfig.PosterSize = imageConfig.PosterSizes[^1];
|
||||
}
|
||||
|
||||
if (!imageConfig.BackdropSizes.Contains(pluginConfig.BackdropSize))
|
||||
if (imageConfig.BackdropSizes is not null
|
||||
&& pluginConfig.BackdropSize is not null
|
||||
&& !imageConfig.BackdropSizes.Contains(pluginConfig.BackdropSize))
|
||||
{
|
||||
pluginConfig.BackdropSize = imageConfig.BackdropSizes[^1];
|
||||
}
|
||||
|
||||
if (!imageConfig.LogoSizes.Contains(pluginConfig.LogoSize))
|
||||
if (imageConfig.LogoSizes is not null
|
||||
&& pluginConfig.LogoSize is not null
|
||||
&& !imageConfig.LogoSizes.Contains(pluginConfig.LogoSize))
|
||||
{
|
||||
pluginConfig.LogoSize = imageConfig.LogoSizes[^1];
|
||||
}
|
||||
|
||||
if (!imageConfig.ProfileSizes.Contains(pluginConfig.ProfileSize))
|
||||
if (imageConfig.ProfileSizes is not null
|
||||
&& pluginConfig.ProfileSize is not null
|
||||
&& !imageConfig.ProfileSizes.Contains(pluginConfig.ProfileSize))
|
||||
{
|
||||
pluginConfig.ProfileSize = imageConfig.ProfileSizes[^1];
|
||||
}
|
||||
|
||||
if (!imageConfig.StillSizes.Contains(pluginConfig.StillSize))
|
||||
if (imageConfig.StillSizes is not null
|
||||
&& pluginConfig.StillSize is not null
|
||||
&& !imageConfig.StillSizes.Contains(pluginConfig.StillSize))
|
||||
{
|
||||
pluginConfig.StillSize = imageConfig.StillSizes[^1];
|
||||
}
|
||||
|
||||
@@ -69,20 +69,20 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <returns>The Jellyfin person type.</returns>
|
||||
public static PersonKind MapCrewToPersonType(Crew crew)
|
||||
{
|
||||
if (crew.Department.Equals("directing", StringComparison.OrdinalIgnoreCase)
|
||||
&& crew.Job.Equals("director", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(crew.Department, "directing", StringComparison.OrdinalIgnoreCase)
|
||||
&& string.Equals(crew.Job, "director", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return PersonKind.Director;
|
||||
}
|
||||
|
||||
if (crew.Department.Equals("production", StringComparison.OrdinalIgnoreCase)
|
||||
&& crew.Job.Equals("producer", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(crew.Department, "production", StringComparison.OrdinalIgnoreCase)
|
||||
&& string.Equals(crew.Job, "producer", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return PersonKind.Producer;
|
||||
}
|
||||
|
||||
if (crew.Department.Equals("writing", StringComparison.OrdinalIgnoreCase)
|
||||
&& (crew.Job.Equals("writer", StringComparison.OrdinalIgnoreCase) || crew.Job.Equals("screenplay", StringComparison.OrdinalIgnoreCase)))
|
||||
if (string.Equals(crew.Department, "writing", StringComparison.OrdinalIgnoreCase)
|
||||
&& (string.Equals(crew.Job, "writer", StringComparison.OrdinalIgnoreCase) || string.Equals(crew.Job, "screenplay", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return PersonKind.Writer;
|
||||
}
|
||||
@@ -97,9 +97,9 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <returns>A boolean indicating whether the video is a trailer.</returns>
|
||||
public static bool IsTrailerType(Video video)
|
||||
{
|
||||
return video.Site.Equals("youtube", StringComparison.OrdinalIgnoreCase)
|
||||
&& (video.Type.Equals("trailer", StringComparison.OrdinalIgnoreCase)
|
||||
|| video.Type.Equals("teaser", StringComparison.OrdinalIgnoreCase));
|
||||
return string.Equals(video.Site, "youtube", StringComparison.OrdinalIgnoreCase)
|
||||
&& (string.Equals(video.Type, "trailer", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(video.Type, "teaser", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -177,10 +177,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="imageLanguage">The image's actual language code.</param>
|
||||
/// <param name="requestLanguage">The requested language code.</param>
|
||||
/// <returns>The language code.</returns>
|
||||
public static string AdjustImageLanguage(string imageLanguage, string requestLanguage)
|
||||
public static string AdjustImageLanguage(string? imageLanguage, string requestLanguage)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(imageLanguage)
|
||||
&& !string.IsNullOrEmpty(requestLanguage)
|
||||
if (string.IsNullOrEmpty(imageLanguage))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(requestLanguage)
|
||||
&& requestLanguage.Length > 2
|
||||
&& imageLanguage.Length == 2
|
||||
&& requestLanguage.StartsWith(imageLanguage, StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Jellyfin.Extensions
|
||||
/// </summary>
|
||||
/// <param name="values">The enumerable of strings to trim.</param>
|
||||
/// <returns>The enumeration of trimmed strings.</returns>
|
||||
public static IEnumerable<string> Trimmed(this IEnumerable<string> values)
|
||||
public static IEnumerable<string> Trimmed(this IEnumerable<string?> values)
|
||||
{
|
||||
return values.Select(i => (i ?? string.Empty).Trim());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user