Skip to content

Commit

Permalink
add getRatingCount to get number of votes (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingofnull authored and FabianBeiner committed Jul 9, 2019
1 parent f37985d commit e7fc37a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions imdb.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class IMDB
const IMDB_PLOT_KEYWORDS = '~<td[^>]*>Plot\s*Keywords</td>\s*<td>(.+)(?:<a\s*href="/title/[^>]*>[^<]*</a>\s*</li>\s*</ul>\s*)?</td>~Ui';
const IMDB_POSTER = '~<link\s*rel=\'image_src\'\s*href="(.*)">~Ui';
const IMDB_RATING = '~class="ipl-rating-star__rating">(.*)<~Ui';
const IMDB_RATING_COUNT = '~class="ipl-rating-star__total-votes">\((.*)\)<~Ui';
const IMDB_RELEASE_DATE = '~href="/title/[t0-9]*/releaseinfo">(.*)<~Ui';
const IMDB_RUNTIME = '~<td[^>]*>\s*Runtime\s*</td>\s*<td>(.+)</td>~Ui';
const IMDB_SEARCH = '~<td class="result_text"> <a href="\/title\/(tt\d{6,})\/(?:.*)"(?:\s*)>(?:.*)<\/a>~Ui';
Expand Down Expand Up @@ -1167,6 +1168,21 @@ public function getRating()

return self::$sNotFound;
}

/**
* @return string The rating count of the movie or $sNotFound.
*/
public function getRatingCount()
{
if (true === $this->isReady) {
$sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_RATING_COUNT, 1);
if (false !== $sMatch) {
return str_replace(',','',IMDBHelper::cleanString($sMatch));
}
}

return self::$sNotFound;
}

/**
* Release date doesn't contain all the information we need to create a media and
Expand Down

0 comments on commit e7fc37a

Please sign in to comment.