This commit is contained in:
NikolajDanger
2020-04-01 00:59:02 +02:00
parent 9088aaf932
commit eb8fb0c2c2
11 changed files with 254 additions and 185 deletions

View File

@ -1,8 +1,7 @@
import numpy as np
import random
import logging
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
from funcs import logThis
# Returns a list of all letter pairs in the text
def make_pairs(corpus):
@ -47,8 +46,7 @@ def nameGen():
if new_letter == "\n":
done = True
genName = "".join(chain)
print("Generated "+genName)
logging.info("Generated "+genName)
logThis("Generated "+genName)
# Returns the name
return(genName)
@ -61,8 +59,7 @@ def tavernGen():
# Picks one of each
genTav = random.choice(fp)+" "+random.choice(sp)+random.choice(tp)
print("Generated "+genTav)
logging.info("Generated "+genTav)
logThis("Generated "+genTav)
# Return the name
return(genTav)

View File

@ -1,29 +1,24 @@
import imdb
import random
import logging
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
from funcs import logThis
# Picks a random movie and returns information about it
def movieFunc():
try:
print("Creating IMDb object")
logging.info("Creating IMDb object")
logThis("Creating IMDb object")
ia = imdb.IMDb()
print("Picking a movie")
logging.info("Picking a movie")
logThis("Picking a movie")
movs = open("resources/movies.txt", "r")
movlist = movs.read().split("\n")
mov = random.choice(movlist)
movs.close()
print("Searching for "+mov)
logging.info("Searching for "+mov)
logThis("Searching for "+mov)
s_result = ia.search_movie(mov)
print("Getting the data")
logging.info("Getting the data")
logThis("Getting the data")
movie = s_result[0]
ia.update(movie)
cast = movie['cast']
@ -31,10 +26,9 @@ def movieFunc():
for x in range(3):
if cast[x]:
pcast += cast[x]['name']+", "
print("Successfully ran !movie")
logging.info("Successfully ran !movie")
logThis("Successfully ran !movie")
return(movie['title'], movie['plot'][0].split("::")[0], movie['cover url'].replace("150","600").replace("101","404"), pcast[:-2])
except:
print("Something bad happened...")
logging.info("Something bad happened...")
logThis("Something bad happened...")
return("error","","","")