TMDB#

Usage#

To access TMDB data points, first ensure you have loaded the TMDB source through:

await phylm.load_source("tmdb")

Alternatively you can instantiate the TMDB source class directly through:

from phylm.sources import Tmdb

tmdb = Tmdb(raw_title="The Matrix", raw_year=1999)  # raw_year is optional
await tmdb.load_source()

Movie ID#

If you know the TMDB movie ID you can instantiate the Phylm class with a tmdb_id property:

from phylm import Phylm

tmdb = Phylm(title="The Matrix", tmdb_id="609")

Then, when running load_source for tmdb, phylm will first perform a search based on the ID. If the ID is valid the result will be selected, if not then it will fall back to a title search.

Alternatively, you can pass it to load_source with "tmdb" as the first argument:

await phylm.load_source("tmdb", tmdb_id="609")

Or instantiate the TMDB source class with the ID:

from phylm.sources import Tmdb

tmdb = Tmdb(movie_id="0133093")

Warning

If instantiating the class directly you must supply at least one of movie_id or raw_title, otherwise a ValueError will be raised.

Note that TMDB doesn’t provide any fuzzy search for title, only exact matches are returned.

Reference#

class phylm.sources.tmdb.Tmdb(raw_title=None, movie_id=None, raw_year=None, api_key=None, session=None)#

Class to abstract a TMDB result.

Parameters:
  • raw_title (str | None) –

  • movie_id (str | None) –

  • raw_year (int | None) –

  • api_key (str | None) –

  • session (ClientSession | None) –

genres(limit=3)#

Return the genres.

Parameters:

limit (int) – an optional number of genres to return

Returns:

a list of the movie’s genres

Return type:

List[str]

property id: str | None#

Return the TMDB id.

Returns:

the id of the movie

property imdb_id: str | None#

Return the IMDb id.

Returns:

the IMDb id of the movie

async load_source(session=None)#

Asynchronously load the data for from the source.

Parameters:

session (ClientSession | None) – an optional aiohttp.ClientSession instance

Return type:

None

property plot: str | None#

Return the plot.

Returns:

the plot of the movie

property rating: float | None#

Return the TMDB rating.

Returns:

the rating of the movie

property release_date: str | None#

Return the movie’s release_date.

Returns:

the release date of the movie

property runtime: int | None#

Return the runtime.

Returns:

the runtime of the movie

property title: str | None#

Return the TMDB title.

Returns:

the title of the movie

property year: int | None#

Return the movie’s year.

Returns:

the year the movie was made