packaging and testing
This commit is contained in:
2
funcs/other/__init__.py
Normal file
2
funcs/other/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from .generators import nameGen, tavernGen
|
||||
from .movie import movieFunc
|
@ -36,7 +36,7 @@ def nameGen():
|
||||
if new_letter == "\n":
|
||||
done = True
|
||||
genName = "".join(chain)
|
||||
print("Generated "+genName+"\n")
|
||||
print("Generated "+genName)
|
||||
return(genName)
|
||||
|
||||
def tavernGen():
|
||||
|
@ -2,27 +2,30 @@ import imdb
|
||||
import random
|
||||
|
||||
def movieFunc():
|
||||
print("Running !movie")
|
||||
print("Creating IMDb object")
|
||||
ia = imdb.IMDb()
|
||||
try:
|
||||
print("Creating IMDb object")
|
||||
ia = imdb.IMDb()
|
||||
|
||||
print("Picking a movie")
|
||||
movs = open("movies.txt", "r")
|
||||
movlist = movs.read().split("\n")
|
||||
mov = random.choice(movlist)
|
||||
movs.close()
|
||||
print("Picking a movie")
|
||||
movs = open("funcs/other/movies.txt", "r")
|
||||
movlist = movs.read().split("\n")
|
||||
mov = random.choice(movlist)
|
||||
movs.close()
|
||||
|
||||
print("Searching")
|
||||
s_result = ia.search_movie(mov)
|
||||
print("Searching for "+mov)
|
||||
s_result = ia.search_movie(mov)
|
||||
|
||||
print("Picking the movie")
|
||||
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])
|
||||
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","","","")
|
||||
|
Reference in New Issue
Block a user