|
|
|
@ -14,7 +14,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|
|
|
|
private static readonly Regex _nonWords = new(@"[\W_]+", RegexOptions.Compiled);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// URL of the TMDB instance to use.
|
|
|
|
|
/// URL of the TMDb instance to use.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string BaseTmdbUrl = "https://www.themoviedb.org/";
|
|
|
|
|
|
|
|
|
@ -50,7 +50,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Maps the TMDB provided roles for crew members to Jellyfin roles.
|
|
|
|
|
/// Maps the TMDb provided roles for crew members to Jellyfin roles.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="crew">Crew member to map against the Jellyfin person types.</param>
|
|
|
|
|
/// <returns>The Jellyfin person type.</returns>
|
|
|
|
@ -103,9 +103,9 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|
|
|
|
|
|
|
|
|
languages.Add(preferredLanguage);
|
|
|
|
|
|
|
|
|
|
if (preferredLanguage.Length == 5) // like en-US
|
|
|
|
|
if (preferredLanguage.Length == 5) // Like en-US
|
|
|
|
|
{
|
|
|
|
|
// Currently, TMDB supports 2-letter language codes only
|
|
|
|
|
// Currently, TMDb supports 2-letter language codes only.
|
|
|
|
|
// They are planning to change this in the future, thus we're
|
|
|
|
|
// supplying both codes if we're having a 5-letter code.
|
|
|
|
|
languages.Add(preferredLanguage.Substring(0, 2));
|
|
|
|
@ -114,6 +114,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|
|
|
|
|
|
|
|
|
languages.Add("null");
|
|
|
|
|
|
|
|
|
|
// Always add English as fallback language
|
|
|
|
|
if (!string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
languages.Add("en");
|
|
|
|
@ -134,14 +135,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|
|
|
|
return language;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// They require this to be uppercase
|
|
|
|
|
// Everything after the hyphen must be written in uppercase due to a way TMDB wrote their api.
|
|
|
|
|
// TMDb requires this to be uppercase
|
|
|
|
|
// Everything after the hyphen must be written in uppercase due to a way TMDb wrote their API.
|
|
|
|
|
// See here: https://www.themoviedb.org/talk/5119221d760ee36c642af4ad?page=3#56e372a0c3a3685a9e0019ab
|
|
|
|
|
var parts = language.Split('-');
|
|
|
|
|
|
|
|
|
|
if (parts.Length == 2)
|
|
|
|
|
{
|
|
|
|
|
// TMDB doesn't support Switzerland (de-CH, it-CH or fr-CH) so use the language (de, it or fr) without country code
|
|
|
|
|
// TMDb doesn't support Switzerland (de-CH, it-CH or fr-CH) so use the language (de, it or fr) without country code
|
|
|
|
|
if (string.Equals(parts[1], "CH", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return parts[0];
|
|
|
|
@ -174,14 +175,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Combines the metadata country code and the parental rating from the Api into the value we store in our database.
|
|
|
|
|
/// Combines the metadata country code and the parental rating from the API into the value we store in our database.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="countryCode">The Iso 3166-1 country code of the rating country.</param>
|
|
|
|
|
/// <param name="ratingValue">The rating value returned by the Tmdb Api.</param>
|
|
|
|
|
/// <param name="countryCode">The ISO 3166-1 country code of the rating country.</param>
|
|
|
|
|
/// <param name="ratingValue">The rating value returned by the TMDb API.</param>
|
|
|
|
|
/// <returns>The combined parental rating of country code+rating value.</returns>
|
|
|
|
|
public static string BuildParentalRating(string countryCode, string ratingValue)
|
|
|
|
|
{
|
|
|
|
|
// exclude US because we store us values as TV-14 without the country code.
|
|
|
|
|
// Exclude US because we store US values as TV-14 without the country code.
|
|
|
|
|
var ratingPrefix = string.Equals(countryCode, "US", StringComparison.OrdinalIgnoreCase) ? string.Empty : countryCode + "-";
|
|
|
|
|
var newRating = ratingPrefix + ratingValue;
|
|
|
|
|
|
|
|
|
|