C#.Net library for TheMovieDB
Go to file
2024-01-14 04:00:01 -05:00
_Imports Updating standard content files for repository 2021-03-25 19:53:37 +01:00
.github/workflows Update actions/setup-dotnet action to v4 2023-12-04 15:41:46 +00:00
TestApplication Update test projects to .NET7 and update VerifyTests 2023-09-29 12:24:29 +02:00
TMDbLib Fix for WhereGenresExclude calling WhereGenresInclude 2024-01-14 04:00:01 -05:00
TMDbLibTests Update dependency xunit to v2.6.5 2024-01-05 07:52:17 +00:00
.ci-skip-tests Updating standard content files for repository 2021-03-25 19:53:37 +01:00
.editorconfig Updating standard content files for repository 2023-08-18 17:01:11 +00:00
.gitattributes Remove old Nuget packages. 2016-11-30 20:47:47 +01:00
.gitignore Updating standard content files for repository 2023-08-18 17:01:11 +00:00
Directory.Build.props Update dependency Microsoft.SourceLink.GitHub to v8 2023-11-15 22:00:15 +00:00
LICENSE.txt Add license 2016-12-19 21:20:33 +01:00
Readme.md Link to blog on alpha packages 2021-03-28 19:01:35 +02:00
renovate.json use our own preset 2023-09-22 22:11:14 +02:00
TMDbLib.sln Updated Newtonsoft to 13.0.3 due to critical security vulnerability 2023-08-17 09:35:20 -04:00

TMDbLib Generic Build NuGet GHPackages

A near-complete wrapper for v3 of TMDb's API (TheMovieDb - https://www.themoviedb.org/).

Using alpha packages

All commits to master produce an Alpha package that can be found here. Read more on how to use these packages.

Index

Documentation

Most of the library is self-explaining, and closely follows the possibilities at the official TMDb documentation site: developers.themoviedb.org.

Examples

Simple example, getting the basic info for "A good day to die hard".

TMDbClient client = new TMDbClient("APIKey");
Movie movie = client.GetMovieAsync(47964).Result;

Console.WriteLine($"Movie name: {movie.Title}");

Using the extra features of TMDb, we can fetch more info in one go (here we fetch casts as well as trailers):

TMDbClient client = new TMDbClient("APIKey");
Movie movie = await client.GetMovieAsync(47964, MovieMethods.Credits | MovieMethods.Videos);

Console.WriteLine($"Movie title: {movie.Title}");
foreach (Cast cast in movie.Credits.Cast)
    Console.WriteLine($"{cast.Name} - {cast.Character}");

Console.WriteLine();
foreach (Video video in movie.Videos.Results)
    Console.WriteLine($"Trailer: {video.Type} ({video.Site}), {video.Name}");

It is likewise simple to search for people or movies, for example here we search for "007". This yields basically every James Bond film ever made:

TMDbClient client = new TMDbClient("APIKey");
SearchContainer<SearchMovie> results = client.SearchMovieAsync("007").Result;

Console.WriteLine($"Got {results.Results.Count:N0} of {results.TotalResults:N0} results");
foreach (SearchMovie result in results.Results)
    Console.WriteLine(result.Title);

However, another way to get all James Bond movies, is to use the collection-approach. TMDb makes collections for series of movies, such as Die Hard and James Bond. I know there is one, so I will show how to search for the collection, and then list all movies in it:

TMDbClient client = new TMDbClient("APIKey");
SearchContainer<SearchCollection> collectons = client.SearchCollectionAsync("James Bond").Result;
Console.WriteLine($"Got {collectons.Results.Count:N0} collections");

Collection jamesBonds = client.GetCollectionAsync(collectons.Results.First().Id).Result;
Console.WriteLine($"Collection: {jamesBonds.Name}");
Console.WriteLine();

Console.WriteLine($"Got {jamesBonds.Parts.Count:N0} James Bond Movies");
foreach (SearchMovie part in jamesBonds.Parts)
      Console.WriteLine(part.Title);

Tips

  • All methods are async and awaitable
  • Most methods are very straightforward, and do as they are named, GetMovie, GetPerson etc.
  • Almost all enums are of the [Flags] type. This means you can combine them: MovieMethods.Casts | MovieMethods.Trailers
  • TMDb are big fans of serving as little as possible, so most properties on primary classes like Movie are null, until you request the extra data using the enums like above.