Skip to content

Commit

Permalink
Fixing IMDB targeting
Browse files Browse the repository at this point in the history
  • Loading branch information
sjlu committed Apr 1, 2023
1 parent 5c77cde commit c7e3463
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/imdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,22 @@ module.exports = function (imdbId) {
}

const $ = cheerio.load(resp.body)
const rating = $('.ratingTable .bigcell').first().text().trim()
const count = $('.ratingTable .smallcell').first().text().trim()
let rating = $('.ratingTable .bigcell').first().text().trim()
let count = $('.ratingTable .smallcell').first().text().trim()

// 4/1/23 IMDB is running A/B tests on their ratings page
if (!rating) {
const ratingText = $('[data-testid=rating-button__aggregate-rating]')
.first()
.text()
.trim()
.match(/IMDb Rating(.+)\/10(.+)/i)

rating = ratingText[1]
count = ratingText[2]

count = count.replace(/K$/, '000')
}

return {
imdb_rating: parseNumber(rating),
Expand Down

0 comments on commit c7e3463

Please sign in to comment.