jellyfin/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs

66 lines
2.2 KiB
C#
Raw Normal View History

using System;
2020-08-17 21:59:29 +02:00
using System.Net.Mime;
using MediaBrowser.Model.Entities;
2020-05-31 08:23:09 +02:00
using MediaBrowser.Providers.Plugins.Tmdb.Models.General;
2020-05-31 08:23:09 +02:00
namespace MediaBrowser.Providers.Plugins.Tmdb
{
2020-05-12 15:05:58 +02:00
/// <summary>
2020-05-31 08:28:01 +02:00
/// Utilities for the TMDb provider.
2020-05-12 15:05:58 +02:00
/// </summary>
public static class TmdbUtils
{
2020-05-12 15:05:58 +02:00
/// <summary>
/// URL of the TMDB instance to use.
/// </summary>
2019-08-18 13:34:44 +02:00
public const string BaseTmdbUrl = "https://www.themoviedb.org/";
2020-05-12 15:05:58 +02:00
/// <summary>
/// URL of the TMDB API instance to use.
/// </summary>
2019-08-18 13:34:44 +02:00
public const string BaseTmdbApiUrl = "https://api.themoviedb.org/";
2020-05-12 15:05:58 +02:00
/// <summary>
/// Name of the provider.
/// </summary>
public const string ProviderName = "TheMovieDb";
2020-05-12 15:05:58 +02:00
/// <summary>
/// API key to use when performing an API call.
/// </summary>
public const string ApiKey = "4219e299c89411838049ab0dab19ebd5";
2020-05-12 15:05:58 +02:00
/// <summary>
/// Value of the Accept header for requests to the provider.
/// </summary>
2020-08-17 21:59:29 +02:00
public static readonly string[] AcceptHeaders = { MediaTypeNames.Application.Json, "image/*" };
2020-05-12 15:05:58 +02:00
/// <summary>
/// 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>
public static string MapCrewToPersonType(Crew crew)
{
2020-05-10 15:16:19 +02:00
if (crew.Department.Equals("production", StringComparison.InvariantCultureIgnoreCase)
2020-05-12 15:05:58 +02:00
&& crew.Job.Contains("director", StringComparison.InvariantCultureIgnoreCase))
2020-05-10 15:16:19 +02:00
{
return PersonType.Director;
}
2019-08-18 14:44:13 +02:00
if (crew.Department.Equals("production", StringComparison.InvariantCultureIgnoreCase)
2020-05-12 15:05:58 +02:00
&& crew.Job.Contains("producer", StringComparison.InvariantCultureIgnoreCase))
{
return PersonType.Producer;
}
2019-08-18 14:44:13 +02:00
if (crew.Department.Equals("writing", StringComparison.InvariantCultureIgnoreCase))
{
return PersonType.Writer;
}
return null;
}
}
}