32 lines
827 B
Python
32 lines
827 B
Python
import imdb
|
|
import random
|
|
|
|
def movieFunc():
|
|
try:
|
|
print("Creating IMDb object")
|
|
ia = imdb.IMDb()
|
|
|
|
print("Picking a movie")
|
|
movs = open("funcs/other/movies.txt", "r")
|
|
movlist = movs.read().split("\n")
|
|
mov = random.choice(movlist)
|
|
movs.close()
|
|
|
|
print("Searching for "+mov)
|
|
s_result = ia.search_movie(mov)
|
|
|
|
print("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']+", "
|
|
print("Successfully ran !movie")
|
|
print("")
|
|
return(movie['title'], movie['plot'][0].split("::")[0], movie['cover url'].replace("150","600").replace("101","404"), pcast[:-2])
|
|
except:
|
|
print("Something bad happened...")
|
|
return("error","","","")
|