TmdbUtils.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Net.Mime;
  3. using MediaBrowser.Model.Entities;
  4. using MediaBrowser.Providers.Plugins.Tmdb.Models.General;
  5. namespace MediaBrowser.Providers.Plugins.Tmdb
  6. {
  7. /// <summary>
  8. /// Utilities for the TMDb provider.
  9. /// </summary>
  10. public static class TmdbUtils
  11. {
  12. /// <summary>
  13. /// URL of the TMDB instance to use.
  14. /// </summary>
  15. public const string BaseTmdbUrl = "https://www.themoviedb.org/";
  16. /// <summary>
  17. /// URL of the TMDB API instance to use.
  18. /// </summary>
  19. public const string BaseTmdbApiUrl = "https://api.themoviedb.org/";
  20. /// <summary>
  21. /// Name of the provider.
  22. /// </summary>
  23. public const string ProviderName = "TheMovieDb";
  24. /// <summary>
  25. /// API key to use when performing an API call.
  26. /// </summary>
  27. public const string ApiKey = "4219e299c89411838049ab0dab19ebd5";
  28. /// <summary>
  29. /// Value of the Accept header for requests to the provider.
  30. /// </summary>
  31. public static readonly string[] AcceptHeaders = { MediaTypeNames.Application.Json, "image/*" };
  32. /// <summary>
  33. /// Maps the TMDB provided roles for crew members to Jellyfin roles.
  34. /// </summary>
  35. /// <param name="crew">Crew member to map against the Jellyfin person types.</param>
  36. /// <returns>The Jellyfin person type.</returns>
  37. public static string MapCrewToPersonType(Crew crew)
  38. {
  39. if (crew.Department.Equals("production", StringComparison.InvariantCultureIgnoreCase)
  40. && crew.Job.Contains("director", StringComparison.InvariantCultureIgnoreCase))
  41. {
  42. return PersonType.Director;
  43. }
  44. if (crew.Department.Equals("production", StringComparison.InvariantCultureIgnoreCase)
  45. && crew.Job.Contains("producer", StringComparison.InvariantCultureIgnoreCase))
  46. {
  47. return PersonType.Producer;
  48. }
  49. if (crew.Department.Equals("writing", StringComparison.InvariantCultureIgnoreCase))
  50. {
  51. return PersonType.Writer;
  52. }
  53. return null;
  54. }
  55. }
  56. }