Mozzo1000 / movielst

:movie_camera: Everything about your movies within the command line.
Other
0 stars 1 forks source link

List index out of range rotten tomatoes #6

Closed Mozzo1000 closed 6 years ago

Mozzo1000 commented 6 years ago

Crashes when running movielst after index, clean installation.

Traceback (most recent call last):
  File "c:\program files (x86)\python36-32\scripts\movielst-script.py", line 11, in <module>
    load_entry_point('movielst', 'console_scripts', 'movielst')()
  File "c:\users\REDACTED\documents\github\movielst\movielst\movielst.py", line 48, in main
    util(parser.parse_args())
  File "c:\users\REDACTED\documents\github\movielst\movielst\movielst.py", line 191, in util
    get_rotten_score(item), item["Year"]])
  File "c:\users\REDACTED\documents\github\movielst\movielst\movielst.py", line 196, in get_rotten_score
    if item['Ratings'][1]['Source'] == "Rotten Tomatoes":
IndexError: list index out of range

PLATFORM : Windows10 PYTHON VERSION : Python 3.6.3

Mozzo1000 commented 6 years ago

This issue happens because the OMDb response for Rotten tomato score among others except IMDB is returned in an array. If Rotten Tomato score exists then it will (so far) always be in position 1 hence item['Ratings'][1]['Source']. But if there is less than one in the array then I can't choose position 1(count from 0) to be selected.

OMDb response that fails in this manner - {"Title":"Der Bär ist los! Die Geschichte von Bruno","Year":"2009","Rated":"N/A","Released":"25 Feb 2009","Runtime":"N/A","Genre":"Drama","Director":"Xaver Schwarzenberger","Writer":"Felix Mitterer (screenplay)","Actors":"Harald Krassnitzer, Fritz Karl, Nadeshda Brennicke, Erwin Steinhauer","Plot":"N/A","Language":"German","Country":"Germany, Austria","Awards":"N/A","Poster":"https://ia.media-imdb.com/images/M/MV5BY2ZmMjkwZGUtMzViNy00NTY5LTk1NDMtMGYyMjI1MDFkMmFjXkEyXkFqcGdeQXVyMzA3Njg4MzY@._V1_SX300.jpg","Ratings":[{"Source":"Internet Movie Database","Value":"4.9/10"}],"Metascore":"N/A","imdbRating":"4.9","imdbVotes":"36","imdbID":"tt1249295","Type":"movie","DVD":"N/A","BoxOffice":"N/A","Production":"N/A","Website":"N/A","Response":"True"}