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