packaging and testing

This commit is contained in:
Nikolaj Danger
2020-03-24 15:30:45 +01:00
parent de6ee115e7
commit 5394046aeb
10 changed files with 145 additions and 72 deletions

2
funcs/other/__init__.py Normal file
View File

@ -0,0 +1,2 @@
from .generators import nameGen, tavernGen
from .movie import movieFunc

View File

@ -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():

View File

@ -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","","","")