GithubHelp home page GithubHelp logo

tmdblib's Introduction

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.

tmdblib's People

Contributors

angyanmark avatar bjornorri avatar bluebery avatar bond-009 avatar crobibero avatar cvium avatar cxfksword avatar danilobbezerra avatar danimart1991 avatar dependabot[bot] avatar electroflame avatar frederikbolding avatar jakelandau avatar jchannon avatar lersouza avatar lordmike avatar mpfc75 avatar mschuepbach avatar naliath avatar podsyha avatar renovate[bot] avatar revam avatar shadowghost avatar sirsparkles avatar sl1mboy avatar srathan1 avatar stevethoms avatar syscafedevelopment avatar szajkop avatar voiddaek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmdblib's Issues

Add Account namespace

Read Actions

  • /3/account
  • /3/account/{id}/lists
  • /3/account/{id}/favorite_movies
  • /3/account/{id}/rated_movies
  • /3/account/{id}/movie_watchlist

Write Actions

  • /3/account/{id}/favorite
  • /3/account/{id}/movie_watchlist

Documentation for API's and a guide to get started

By far of all the librariries for tmdb .net I've seen that you guys are doing a great job. specifically because you're responsive and are taking a genuine interest in making this widely available and easy to use and keeping it upto date. I'll be happy to spread the word (and make a donation if you guys accept it).

I would really love to see some documentation of the library API's, what the API's do, what parameters they accept and mean (e.g. what does page = -1 do). Also would love to see a guide to getting started with the API's, you've put 10 lines I see but it isn't enough to get started, possibly a list of all API's (atleast the high level, collectins, movies etc) that way we don't need to go hunting around to see what's available and which namespaces to include and importantly you keep us away from looking at the tmdb website trying to reverse engineer what you've done by looing at what they return and how their api's work (whcih I assume is the primary goal of this library).

Thanks and keep up the great work.

Discover Error with sort by release date

danielvelasquez commented 3 days ago
Hello, I can't seem to use the Discover functionality, am I missing something? there is no Discover method in the client class...
Naliath
Collaborator
Naliath commented 3 days ago
Please use the source from here, the nuget package is out of date and will not be updated until the movie db tvshow api comes out of beta
danielvelasquez

danielvelasquez commented 2 days ago
Thanks, now I got the extra methods:) Although I found a small error there, when trying to sort by release date the argument taken by the DiscoverMovies method is a DiscoverTvShowSortBy Enum instead of DiscoverMovieSortBy.

Split TvSeason object in two

We might need a TvSeasonLight object which only contains the information given by the GetTvShow() call. The only information given is: AirDate, Season and PosterPath.

The GetTvSeason() method returns a TvSeason object, which contains all the fields populated (as the API provides the data).

See #42 for core issue.

Expand the lists namespace

Add the following missing lists actions:

  • /3/list/{id}/item_status
  • /3/list
  • /3/list/{id}/add_item
  • /3/list/{id}/remove_item
  • /3/list/{id}

Portable Class Library

Dear LordMike,

Just an idea, but isn't it possible to convert the (excellent) TMDbLib project to a Portable Class Library (PCL). You would have to drop the RestSharp reference, but a PCL can make use of the ASP.NET Web API client to collect and parse JSON data.

Like I said... It's just an idea, but after the conversion the TMDbLib can be referenced by another PCL and be used in several project types (Win8, WinPhone8, etc).

Dave

resp.Data is null (case id film avatar french : 19995)

the origin of the error in the case of research the movie Avatar (Id: 19995) is due to the large value of the field "revenue" (in the response), Your class define an int, and the int value exceeds. A long type, is a solution.

Here is some lines of the Json file returned by the req:
{

"adult": false,
"backdrop_path": "/5XPPB44RQGfkBrbJxmtdndKz05n.jpg",
"belongs_to_collection": {
"id": 87096,
"name": "Avatar Collection",
"poster_path": "/oexAr649CHHdS0akKEDiHQT1qIk.jpg",
"backdrop_path": null
},
"budget": 237000000,
"genres": [
{
"id": 28,
"name": "Action"
},
{
"id": 12,
"name": "Aventure"
},
{
"id": 14,
"name": "Fantastique"
},
{
"id": 878,
"name": "Science-Fiction"
}
],
"homepage": "",
"id": 19995,
"imdb_id": "tt0499549",
"original_title": "Avatar",
"overview": "............................................................",
"popularity": 38499434.905,
"poster_path": "/nzN40Eck9q6YbdaNQs4pZbMKsfP.jpg",
"production_companies": [
{
"name": "20th Century Fox",
"id": 25
},
{
"name": "Dune Entertainment",
"id": 444
},
{
"name": "Ingenious Film Partners",
"id": 289
},
{
"name": "Lightstorm Entertainment",
"id": 574}
],
"production_countries": [
{"iso_3166_1": "US",
"name": "United States of America"},
{"iso_3166_1": "GB",
"name": "United Kingdom" }
],
"release_date": "2009-12-15",
"revenue": 2 781 505 847, <-------------------------------------------------
"runtime": 166,

Congratulations and thank you for your work.

Config

I love the fact that you have a get imageurl option which is helpful (again the lack of documentation what options to pass to size made me go back to imdb), but the first I ran into an exception and tehn realized after trying to debug it that I needed to call GetConfig.

Now my question - why should I have to call GetConfig? Logically when I create a new client it should automatically call get config right? there' nothing special about the parameters here.

Trailer in Differnt languges

Hi,
I have an issue with getting trailer in different languages. I tried

client.DefaultLanguage = "de";
var trailers = client.GetMovieTrailers(Id);

But I am only getting the English language trailer.

The Trailer itself are empty when requesting the movie in another language via

client.DefaultLanguage = "de";
Movie myMovie = client.GetMovie(Id);

Do I do something wrong? I looked it up in the code but I couldn't find the correct position.

Thanks in advance!

Missing imdb id get

Hio,

Nice implementation of the API, I'm just porting my application over from V2 to your V3 implementation.

Could you possibly add an extra overload to the GetMovie method allowing us to provide a string (imdbID)?
It works exactly like the existing GetMovie method call, the API is smart enough to see that you are providing an imdb id and not an internal id.

Thanks!

imdb call example: http://api.themoviedb.org/3/movie/tt0105236?api_key=###
same call with internal id: http://api.themoviedb.org/3/movie/500?api_key=###

Search by Recent Deaths

Is there a way to search tmdb by recent deaths? As an example, get a collection of people who have passed away in the last week.

Getting image from Uri

Hi,

As I say, It would be great to retrieve image from Uri.

If you want I can help you. I can make a pull request and if it's good for you, you can integrate my job to yours.

I will make Unit Test of course.

Thank you,

Howto get backdrop or poster pictures?

Could you please provide an example howto get a picture from TMDb?

I get back an example value like "/6z0X6AAebEx4SOMikbqHvenFUN2.jpg" for PosterPath, but how can I create the needed full path to download this picture?

Add grouped season fetching

Based on the following comment in the forums we could add something that wraps this functionality.

Is it possible to fetch all episodes with a single query?

If I understand correctly, currently /3/tv/:id returns only the available season numbers, and I'd have to send a request for each season to /3/tv/:id/season/:num in order to fetch all episodes. This would be
undesirable in some cases, where there are just way too many seasons.

Thank you for your response in advance.

EDIT: Nevermind, I've figured it out. Solution in case anyone else is bothered by this: /3/tv/:id?api_key=:key&append_to_response=season/1,season/2[,etc]

Missing original_language /movie/{id}

IMDB's API get results have it as shown in JSON as:

"imdb_id": "tt0137523",
"original_language": "en",
"original_title": "Fight Club"

Any change it can be added to the wrapper available from Nuget. I don't code in C or I'd have a go myself. I'm a bit old school and code in VB/VB.net. I looked at your source movie objects and see not reference to "original_language". Did I miss something?
thx
Joe

Input string was not in a correct format

Use:

var tvshow = client.GetTvShow(1399);

to replicate.

I haven't determined which property it is that's causing it, but it's an integer (stacktrace mentions Convert.ToInt32).

Implement error handling

Interpret the errors that TMDb produces, and handle them accordingly.
Possibly throw exceptions (and implement Try- methods for 'performance').

A few comments on recent code changes

Token / Guest Session
Expire at should be UTC (always work in UTC - much easier for everyone)

Tests expecting exceptions
Always assert fail. Otherwise if no exception is thrown, the test succeeds. (already done)

RestSharp invalid version

Hi !

In the last release, apparently the RestSharp dependency does not specify which version to use. RestSharp was updated, and therefore I have an error :

Could not load file or assembly 'RestSharp, Version=104.4.0.0, Culture=neutral, PublicKeyToken=null'

I would recomment either to specify the verison in the nuspec file, or setting the "Specific version" settings to false

Regards,

Async support

Hi !

Would be great if it was possible to support async request with the client, or having a second TMDBClient that does async handling.

Added Support for regular User sessions (code below)

I did not find code for authentication of regular user sessions, so I added it.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TMDbLib.Objects.Authentication
{
public class TokenLight
{
public string RequestToken { get; set; }
public bool Success { get; set; }
}
}

and

public TokenLight AuthenticationValidateWithLogin(string initialRequestToken, string username, string password)
{
RestRequest request = new RestRequest("authentication/token/validate_with_login");
request.AddParameter("request_token", initialRequestToken);
request.AddParameter("username", username);
request.AddParameter("password", password);

        IRestResponse<TokenLight> response = _client.Get<TokenLight>(request);
        return response.Data;
    }

SearchContainer and Movie

Hi
I'm trying to search the movies by NAME using ;
SearchContainer results = client.SearchMovie("movie name");

however when I check the returned result, I couldn't seem to find the "movie overview".

On the other hand if I search it by "id", Movie class has the "movie overview" and a lot more.

Movie movie = client.GetMovie(ID);
string test = movie.overview;

The only solution I found is making 2 different requests one for getting the id and than using the GetMovie method to retrieve the "movie overview"

SearchContainer results = client.SearchMovie(TextBox.Text);

foreach (SearchMovie result in results.Results)
{
int ID = result.Id;
Movie movie = client.GetMovie(ID);
}

Am I missing something or is this the way it should be?

Thanks

resp.Data is null (case id film avatar french : 19995)

Class TMDbClientMovies.cs

the line : if (resp.Data.Trailers != null) has a exception
position of this line:
// Patch up data, so that the end user won't notice that we share objects between request-types.
if (resp.Data.Trailers != null)
resp.Data.Trailers.Id = resp.Data.Id;

Observation : resp.Data is null

IMDB id's don't return SimilarMovies, TMDb counterparts do.

Movie item1 = client.GetMovie("tt1979320", MovieMethods.SimilarMovies);
Movie item2 = client.GetMovie(96721, MovieMethods.SimilarMovies);

The above code will have the SimilarMovies property populated when using TMDb Id's, but not while using IMDB Id's

Search by TV title

Do you have support to search TV show by title. I noticed that the TMDB Api supports that, but I couldn't find any method in your wrapper.

Great job BTW!

String was not recognized as a valid DateTime.

getting the following error with request
model.Person = MovieDataClient.GetPerson(18918, extraMethods:
Enum.GetValues(typeof (PersonMethods))
.OfType()
.Aggregate((methods, personMethods) => personMethods | methods));
--------------STACK --------------------------
at TMDbLib.TMDbRestClient.Execute[T](IRestRequest request) in c:\tfs\PrimeMovies\TMDbLib\TMDbRestClient.cs:line 55
at RestSharp.RestClientExtensions.Get[T](IRestClient client, IRestRequest request)
at TMDbLib.Client.TMDbClient.GetPerson(Int32 id, PersonMethods extraMethods) in c:\tfs\PrimeMovies\TMDbLib\Client\TMDbClientPeople.cs:line 30
at PrimeMoviesWebUI.Controllers.HomeController.PersonDetail(Int32 id) in c:\tfs\PrimeMovies\PrimeMoviesWebUI\Controllers\HomeController.cs:line 80
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass81.b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.b__33()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.b__49()

Add missing movie methods

  • /3/movie/{id}/account_states
  • /3/movie/{id}/rating

These both require the newly implemented session id's

Search TV Show by ID

I am searching for a TV show by Title, then I select a show and search it by the ID it returned. For some shows this works just fine, but for others it doesn't.

For example, if I search for Game of Thrones I get the ID 1399. And when I search it by this ID I just get the error "Input string was not in a correct format."

This only happens with certain shows. Other shows like Lost and Friends work fine. By doing it manually with TMDB API, Game of Thrones returns the correct information, so I can't figure out if it is a problem with my code or this wrapper.

I must say that this is the only issue I've been having, everything has worked like a charm and that is if this is not my mistake! Thanks

TvShow missing data

When one calls client.GetTvShow and one looks at the Seasons and Seasons.Episodes properties, it'll all nulls. As in I see 10 season objects, but full of nulls.

should it get and automatically populate those?

Reported issue by mail to me

First of all let me thank you for all the great software you have made available to the general public! It is much appreciated! I am sorry to bother you but theMovieDb just pushed out a new URL that broke the TMDbLib.dll that you created and as I am not a C# programmer not sure where to start to fix. Do you have any plans to update or is there a possibility that you could send me a ‘patch’ or fix? This is for a program for my personal use and not commercial.

Any help here would be appreciated. I have developed a workaround but it is far from ‘perfect’

Thanking you in advance!!

Regards,

TV Show content_ratings

Maybe I am missing something, but I think we are missing /tv/{id}/content_ratings.
I ultimately want the tv shows rating (ex. TV-MA)
Do we need another MovieMethod?
Thank you for your work!

Windows 8 Metro App

Hi,
I am building my first Windows 8 Metro App. I have just tried to add the NuGet-Package. Those wont work tho. It works fine for any other application type, but on metro i get the following error:
RestSharp 104.1 couldn´t be installed. No assembly information for .NETCore, Version=v.4.5

Do you have any idea how to fix this?

Greets

Constructor for TMDbClient allows invalid URL format

When using this library retrieved from NUGET yesterday I found that when constructing the library with an http:// in the URL parameter that it allowed this, however when calling the getConfig with this parameter the call failed.

The root cause was that I had prepended http:// to my URL parameter.

My suggestion is to add parameter verification to the base url parameter. The API Key cannot be verified easily because the TBDB might change their api keys one day and then the verification would be broken, but the URL parameter could be verified so as to prevent the module from crashing out with an error that would not lead easily to finding the issue.

Thanks for a great library. I have only literally scratched the surface. I was writing my own library when I decided to have a go at using this one. Having tried the WAT library and not really being impressed I did not have high hopes, but so far I have to say I am pleased. Of course, I have only made two calls to the library... :) ...

TMDBLib does not have a strong name

When I try to compile the project using the nuget downloaded reference assembly I get an error saying referenced assembly does not have a strong name. I don't face this issue with other nuget reference assemblies I download

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.