Skip to content

IMDb

Usage

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

await phylm.load_source("imdb")

Alternatively you can instantiate the IMDb source class directly through:

from phylm.sources import Imdb

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

Movie ID

If you know the IMDb movie ID you can instantiate the Phylm class with an imdb_id property:

from phylm.sources import Imdb

imdb = Imdb(raw_title="The Matrix", imdb_id="0133093")

Then, when running load_source for imdb, 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 "imdb" as the first argument:

await phylm.load_source("imdb", imdb_id="0133093")

Or instantiate the IMDb source class with the ID:

from phylm.sources import Imdb

imdb = Imdb(movie_id="0133093")

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

Reference

Class to abstract an IMDb movie object.

id: Optional[str] property

Return the IMDb id.

Returns:

Type Description
Optional[str]

the id of the movie

plot: Optional[str] property

Return the plot.

Returns:

Type Description
Optional[str]

the plot of the movie

rating: Optional[float] property

Return the IMDb rating.

Returns:

Type Description
Optional[float]

the rating of the movie

runtime: Optional[str] property

Return the runtime.

Returns:

Type Description
Optional[str]

the runtime of the movie

title: Optional[str] property

Return the IMDb title.

Returns:

Type Description
Optional[str]

the title of the movie

year: Optional[int] property

Return the movie's year.

Returns:

Type Description
Optional[int]

the year the movie was made

__init__(raw_title: Optional[str] = None, movie_id: Optional[str] = None, raw_year: Optional[int] = None) -> None

Initialize the object.

Note that at least one of raw_title or movie_id must be given to be used as a search term. movie_id is preferred over raw_title.

Parameters:

Name Type Description Default
raw_title Optional[str]

the title of the movie

None
movie_id Optional[str]

the IMDb id of the movie

None
raw_year Optional[int]

an optional year for improved matching if only title is given

None

Raises:

Type Description
ValueError

if neither raw_title nor movie_id is supplied

cast(limit: int = 5) -> List[str]

Return the cast.

Parameters:

Name Type Description Default
limit int

an optional number of cast members to return

5

Returns:

Type Description
List[str]

a list of the movie's cast members

directors(limit: int = 3) -> List[str]

Return the director(s).

Parameters:

Name Type Description Default
limit int

an optional number of director to return

3

Returns:

Type Description
List[str]

a list of the movie's directors

genres(limit: int = 3) -> List[str]

Return the genres.

Parameters:

Name Type Description Default
limit int

an optional number of genres to return

3

Returns:

Type Description
List[str]

a list of the movie's genres

load_source() -> None async

Asynchronously load the data for from the source.


Last update: 2023-10-18