Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
from imdb import IMDb
import random
ia = IMDb()
# IMDbPY documentation was used.
# https://imdbpy.sourceforge.io/support.html and https://github.com/alberanid/imdbpy/tree/master/docs/usage
def randomMovieTop250():
"""Returns random movie from top 250. Takes no input"""
top250 = ia.get_top250_movies() # Variable top 250 is used to store movies from top 250 from IMDBpy
r = random.randint(0, 250)
randomMovie = top250[r]
return randomMovie
def movieRating(movieName):
"""Returns rating of selected film and gives an opinion by taking the movie name"""
movielist = ia.search_movie(movieName)
firstinlist = movielist[0]
ia.update(firstinlist)
try:
if firstinlist['rating'] >= 8:
botrating = "It's excellent!"
elif 7.1 <= firstinlist['rating'] < 8:
botrating = "It's really good."
elif 6 <= firstinlist['rating'] < 7.1:
botrating = "It's okay."
elif 4 <= firstinlist['rating'] < 6:
botrating = "It's bad."
elif 2 <= firstinlist['rating'] < 4:
botrating = "It's really bad!"
else:
botrating = ("It's unwatchable! You should look for any other movie.\n" +
"Try watching " + str(randomMovieTop250()))
return ("%s is rated %s" % (firstinlist['title'], firstinlist['rating'])+ "\n" + str(botrating))
except:
return ("I don't think that there is any movie called " + movieName)