Skip to content
Alireza Kamali edited this page Oct 17, 2024 · 1 revision

Chart Class Documentation

The Chart class is used to retrieve IMDb box office summaries and top lists from IMDb. It provides two main functionalities:

  • Fetching the USA weekend box-office summary.
  • Fetching various top lists such as IMDb's Top 250 Movies or specific regional film lists.

Methods

getBoxOffice()

Fetches the USA Weekend Box-Office Summary, including weekend earnings, total gross earnings, and weeks of release for each movie.

Return:

  • array: An array of associative arrays, each representing a movie in the weekend box-office summary with the following fields:
    • id (string): IMDb ID of the movie.
    • title (string): Title of the movie.
    • weeks (string): The number of weeks the movie has been released.
    • weekend (float): Weekend gross in millions.
    • gross (float): Total gross in millions.

Example:

$chart = new Chart();
$boxOfficeSummary = $chart->getBoxOffice();

Output Example:

[
    [
        'id' => 'tt1234567',
        'title' => 'Movie Title',
        'weeks' => '4',
        'weekend' => 12.3,   // Weekend gross in millions
        'gross' => 100.5     // Total gross in millions
    ],
    // More entries...
]

getList(string $listType = "TOP_250")

Fetches IMDb top lists, such as the Top 250 Movies, TV shows, or regional-specific lists. The listType parameter defines the type of list to fetch.

Parameters:

  • $listType (string, optional): The type of IMDb top list to retrieve. Possible values:
    • TOP_250: Overall IMDb Top 250 Feature Films.
    • TOP_250_TV: Overall IMDb Top 250 TV Shows.
    • TOP_250_ENGLISH: Top 250 English Feature Films.
    • TOP_250_INDIA: Top 250 Indian Feature Films.
    • TOP_50_TELUGU: Top 50 Telugu Feature Films.
    • TOP_50_TAMIL: Top 50 Tamil Feature Films.
    • TOP_50_MALAYALAM: Top 50 Malayalam Feature Films.
    • TOP_50_BENGALI: Top 50 Bengali Feature Films.
    • BOTTOM_100: Overall IMDb Bottom 100 Feature Films.

Return:

  • array: An array of associative arrays, each representing a movie or TV show from the list with the following fields:
    • rank (int): The rank of the movie/TV show.
    • id (string): IMDb ID of the movie/TV show.
    • title (string): Title of the movie/TV show.
    • type (string): Type of the item (Movie, TV, etc.).
    • imageUrl (string): URL of the movie/TV show's poster image.
    • year (int): Release year of the movie/TV show.
    • rating (float): IMDb rating.
    • votes (int): Number of votes.

Example:

$chart = new Chart();
$top250Movies = $chart->getList('TOP_250');

Output Example:

[
    [
        'rank' => 1,
        'id' => 'tt0111161',
        'title' => 'The Shawshank Redemption',
        'type' => 'Movie',
        'imageUrl' => [
                        'original' => 'https://image.url'
                      ],
        'year' => 1994,
        'rating' => 9.3,
        'votes' => 2400000
    ],
    // More entries...
]

Usage

To use this class, you first need to create an instance of Chart, and then call the desired method based on whether you want to retrieve the weekend box-office summary or a specific IMDb list.

$chart = new Chart();

// Fetch weekend box-office summary
$boxOfficeData = $chart->getBoxOffice();

// Fetch IMDb Top 250 Movies
$topMovies = $chart->getList('TOP_250');

Notes

  • The listType must be one of the predefined types. Any invalid list type will return an empty array.
  • Gross and weekend earnings are handled in millions, and are converted to float values for easier manipulation.