from google_images_search import GoogleImagesSearch
from imgonimg import collagemake
import time
import os
import glob

gis = GoogleImagesSearch(' AIzaSyAQIokiEqsF8CcjKHK0H8UQqu_zL3eUogs ', 'b93a4d05151dc7d5b')

dream_setting = input("What was the setting of your dream? ")
whoask = input("Were there people there? (y/n) ")
if whoask == 'y':
    who1 = input("who? ")
    who2 = input("And who else? ")
toolask = input("Were you using a tool? (y/n) ")
if toolask == 'y':
    tool = input("What was it? ")

gis.search(search_params={'q': dream_setting, 'num': 1, 'fileType': 'png'}, path_to_dir='C:/Users/Ainarikiaz/Documents/Year 2 BA DESIGN/2.2/collagedream/images', custom_image_name='background')
time.sleep(1)
if whoask == "y":
    gis.search(search_params={'q': who1, 'num': 1, 'fileType': 'png'}, path_to_dir='C:/Users/Ainarikiaz/Documents/Year 2 BA DESIGN/2.2/collagedream/images', custom_image_name='character1')
    time.sleep(1)
    gis.search(search_params={'q': who2, 'num': 1, 'fileType': 'png'}, path_to_dir='C:/Users/Ainarikiaz/Documents/Year 2 BA DESIGN/2.2/collagedream/images', custom_image_name='character2')
    time.sleep(1)
if toolask == "y":
    gis.search(search_params={'q': tool, 'num': 1, 'fileType': 'png'}, path_to_dir='C:/Users/Ainarikiaz/Documents/Year 2 BA DESIGN/2.2/collagedream/images', custom_image_name='thing1')
    time.sleep(1)

# n = ""
# pic_count = 1
# while n != 'y':
#     dreamthing = input("What else was in your dream? ")
#     filename = ("dreamthing" + str(pic_count))
#     gis.search(search_params={'q': dreamthing, 'num': 1, 'fileType': 'png'}, path_to_dir='C:/Users/Ainarikiaz/Documents/Year 2 BA DESIGN/2.2/collagedream/images', custom_image_name= filename)
#     if pic_count == 10:
#         break
#     n = input("Is that everything? (y/n) ")
#     if n == "y":
#         break
#     pic_count = pic_count + 1
   

collagemake(dream_setting)
#collagemake(dream_setting, pic_count)

#files = glob.glob('C:/Users/Ainarikiaz/Documents/Year 2 BA DESIGN/2.2/collagedream/images/*')
#for f in files:
#    os.remove(f)