Aggiunta Generi Film

master
MickSlash 2020-04-23 13:56:48 +00:00
parent f362265f9d
commit 54a372159c
1 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,6 @@
import requests import requests
def get_film(endpoint,film,api_key,config_data): def get_film(endpoint,film,api_key,config_data,genre_data):
language = "it-IT" language = "it-IT"
payloads = {"api_key":api_key,"language":language,"query":film} payloads = {"api_key":api_key,"language":language,"query":film}
response = requests.get(endpoint, params=payloads) response = requests.get(endpoint, params=payloads)
@ -22,7 +22,12 @@ def get_film(endpoint,film,api_key,config_data):
poster_image = img_base_secure_url + poster_size + poster_path poster_image = img_base_secure_url + poster_size + poster_path
# print(data) # print(data)
print(f"{nome_film}\n{descrizione_film}") print(f"{nome_film}\n{descrizione_film}")
print(genres) for generi in genre_data['genres']:
# print(generi['name'])
id_generi = generi['id']
if id_generi in genres:
print(generi['name'])
# print(genres)
print(f"Immagine Poster : {poster_image} ") print(f"Immagine Poster : {poster_image} ")
return data return data
else: else:
@ -57,4 +62,4 @@ if __name__ == "__main__":
film = input("Inserisci un Film da Cercare : ") film = input("Inserisci un Film da Cercare : ")
config_data = get_configuration(configuration_url,api_key) config_data = get_configuration(configuration_url,api_key)
genre_data = get_genre(genre_url,api_key) genre_data = get_genre(genre_url,api_key)
get_film(endpoint,film,api_key,config_data) get_film(endpoint,film,api_key,config_data,genre_data)