Phylm#

This is the main entrypoint class.

First instantiate the class with a title property:

from phylm import Phylm

p = Phylm(title="The Matrix")

You can also provide a year property for improved matching:

from phylm import Phylm

p = Phylm(title="The Matrix", year=1999)

Next, asynchronously load a source through either load_sources or load_source:

await p.load_sources(["imdb", "rt"])
await p.load_source("mtc")

The available sources are:

"imdb" # IMDb
"rt" # Rotten Tomatoes
"mtc" # Metacritic
"tmdb" # TMDB

Now the source will be available through a property of the same name and datapoints on that source can be accessed:

>>> p.imdb
<phylm.sources.imdb.Imdb object at 0x108a94810>
>>> p.imdb.rating
8.8

Low Confidence#

phylm will try to match the given title with the results through an exact match on the title. If phylm can’t find an exact match then it will select the first result and set a low_confidence flag to True. This and the year method on a source can be helpful for validating that the result is the desired one:

from phylm import Phylm
p = Phylm("Ambiguous Movie")  # suppose this movie was released in 1999
await p.load_source("imdb")
if p.imdb.low_confidence and p.imdb.year != 1999:
    # it's unlikely we're dealing with the right "Ambiguous Movie"

See the docs for a source for a full list of the available data points.

Reference#

class phylm.Phylm(title, imdb_id=None, year=None, tmdb_id=None)#

Main Phylm entrypoint.

Parameters:
  • title (str) –

  • imdb_id (str | None) –

  • year (int | None) –

  • tmdb_id (str | None) –

property imdb: Imdb#

Return the IMDb data.

Returns:

The IMDb data

Raises:

SourceNotLoadedError – if the source is not loaded

async load_source(source, imdb_id=None, session=None, tmdb_id=None)#

Asynchronously load the film data for a source.

Parameters:
  • source (str) – the desired source

  • imdb_id (str | None) – an optional IMDb id which will be used to load the imdb data instead of a basic search on the title

  • session (ClientSession | None) – an optional instance of aiohttp.ClientSession in which to run the request

  • tmdb_id (str | None) – an optional TMDB id which will be used to load the TMDB data instead of a basic search on the title

Returns:

the instance

Raises:

UnrecognizedSourceError – if the source is not recognized

Return type:

Phylm

async load_sources(sources)#

Asynchronously load multiple sources.

Parameters:

sources (List[str]) – a list of the desired sources

Returns:

the instance

Return type:

Phylm

property mtc: Mtc#

Return the Metacritic data.

Returns:

The Metacritic data

Raises:

SourceNotLoadedError – if the source is not loaded

property rt: Rt#

Return the Rotten Tomatoes data.

Returns:

The Rotten Tomatoes data

Raises:

SourceNotLoadedError – if the source is not loaded

property tmdb: Tmdb#

Return the TMDB data.

Returns:

The TMDB data

Raises:

SourceNotLoadedError – if the source is not loaded