🥅 Error codes
This commit is contained in:
@ -9,26 +9,38 @@ def movieFunc():
|
||||
logThis("Creating IMDb object")
|
||||
ia = imdb.IMDb()
|
||||
|
||||
logThis("Picking a movie")
|
||||
movs = open("resources/movies.txt", "r")
|
||||
movlist = movs.read().split("\n")
|
||||
mov = random.choice(movlist)
|
||||
movs.close()
|
||||
try:
|
||||
logThis("Picking a movie")
|
||||
movs = open("resources/movies.txt", "r")
|
||||
movlist = movs.read().split("\n")
|
||||
mov = random.choice(movlist)
|
||||
movs.close()
|
||||
except:
|
||||
logThis("Problem picking the movie (error code 801)")
|
||||
return("error","801","","")
|
||||
|
||||
logThis("Searching for "+mov)
|
||||
s_result = ia.search_movie(mov)
|
||||
try:
|
||||
logThis("Searching for "+mov)
|
||||
s_result = ia.search_movie(mov)
|
||||
except:
|
||||
logThis("Couldn't find on imdb (error code 802)")
|
||||
return("error","802","","")
|
||||
|
||||
logThis("Getting the data")
|
||||
movie = s_result[0]
|
||||
ia.update(movie)
|
||||
cast = movie['cast']
|
||||
pcast = ""
|
||||
for x in range(3):
|
||||
if cast[x]:
|
||||
pcast += cast[x]['name']+", "
|
||||
try:
|
||||
logThis("Getting the data")
|
||||
movie = s_result[0]
|
||||
ia.update(movie)
|
||||
cast = movie['cast']
|
||||
pcast = ""
|
||||
for x in range(3):
|
||||
if cast[x]:
|
||||
pcast += cast[x]['name']+", "
|
||||
except:
|
||||
logThis("Couldn't extract data (error code 803)")
|
||||
return("error","803","","")
|
||||
|
||||
logThis("Successfully ran !movie")
|
||||
return(movie['title'], movie['plot'][0].split("::")[0], movie['cover url'].replace("150","600").replace("101","404"), pcast[:-2])
|
||||
except:
|
||||
logThis("Something bad happened...")
|
||||
return("error","","","")
|
||||
logThis("Something bad happened... (error code 800)")
|
||||
return("error","800","","")
|
||||
|
Reference in New Issue
Block a user