Skip to content

Commit

Permalink
Merge branch 'theotherp-fix_critics_reviews'
Browse files Browse the repository at this point in the history
* theotherp-fix_critics_reviews:
  add test for metascore
  update changelog and version
  #470 add test
  Extract StarList
  fix 475: series episodes parser
  minor flake8 fixes
  update version and changelog
  #476: add unit test
  Update movieParser.py
  #439: fix parsing of critics reviews page
  • Loading branch information
alberanid committed Sep 23, 2023
2 parents bcc4229 + 81a5f55 commit 86483a7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- #358: access the "actress" key with "actor"
- #467: fix movies trivia parser (courtesy of Anthony Lipphardt)
- #470: add parser for movie stars (courtesy of Jesús Cea)
- #472: fix for metascore on critic reviews (courtesy of theotherp)

* What's new in release 2023.05.01 (1922)

Expand Down
5 changes: 3 additions & 2 deletions imdb/parser/http/movieParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1642,11 +1642,12 @@ class DOMHTMLCriticReviewsParser(DOMParserBase):
rules = [
Rule(
key='metascore',
extractor=Path('//div[@class="metascore_wrap"]/div/span//text()')
extractor=Path('//*[@data-testid="critic-reviews-title"]/div/text()',
transform=lambda x: int(x.strip()))
),
Rule(
key='metacritic url',
extractor=Path('//div[@class="article"]/div[@class="see-more"]/a/@href')
extractor=Path('//*[@data-testid="critic-reviews-title"]/div[2]/div[2]/a/@href')
)
]

Expand Down
5 changes: 5 additions & 0 deletions tests/test_http_movie_reviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ def test_movie_reviews_should_be_a_list(ia):
def test_movie_reviews_if_none_should_be_excluded(ia):
movie = ia.get_movie('1863157', info=['reviews']) # Ates Parcasi
assert 'reviews' not in movie

def test_movie_critic_reviews_metascore(ia):
movie = ia.get_movie('0133093', info=['critic reviews']) # The Matrix
assert 65 < movie.get('metascore') < 80
assert 'metacritic.com' in movie.get('metacritic url', '')

0 comments on commit 86483a7

Please sign in to comment.