preritdas / rottentomatoes-python

Fetch scores, genres, and movie data from Rotten Tomatoes without their (inaccessible) official API.
https://rotten-tomatoes-api.ue.r.appspot.com/docs
14 stars 11 forks source link

Some queries fail on soup.find('rt-text',{'slot':'ratingsCode'}).text #43

Closed ajkessel closed 1 month ago

ajkessel commented 1 month ago

Many queries work fine, some fail with the latest git code, e.g.:

>>> print(rt.tomatometer("rebel ridge"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/adam/.venv/lib/python3.11/site-packages/rottentomatoes/standalone.py", line 184, in tomatometer
    value = _get_score_details(content)['tomatometerScore']
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.venv/lib/python3.11/site-packages/rottentomatoes/standalone.py", line 86, in _get_score_details
    rating = soup.find('rt-text', {'slot': 'ratingsCode'}).text
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'text'
preritdas commented 1 month ago

I wonder if this is because the movie isn't found. 🤷‍♂️ Will look into this, thanks @ajkessel.

ajkessel commented 1 month ago

I've seen this error with several movies that are definitely in RT -- this one, for example, is just https://www.rottentomatoes.com/m/rebel_ridge which is the first result from https://www.rottentomatoes.com/search?search=rebel%20ridge

ajkessel commented 1 month ago

Suggested fix in #44