Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
from tmdbv3api import TMDb #importing our api module
import requests #requests module is used to get data from api
import json
TMDb.api_key = 'ecc93b355b92e11d7c214bbf1385b82d' #authorization for our api
#normal greetings
name = input("What is your name ?"+"\n")
welcoming = "Hello "+ name +"\n"+ "My name in MovieBot. I will give information for the movie you searched."
print(welcoming)
#setting up url and requesting data from api
base_url = "https://api.themoviedb.org/3/search/movie?"
api_key = "api_key=ecc93b355b92e11d7c214bbf1385b82d&query="
print ("Please Enter Name Of The Movie")
mov = input(">>")
api_call = base_url + api_key + mov
req=requests.get(api_call).json()
#function to search movies
def movieSearch():
movie_list = "1 : "+req["results"][0]["original_title"] + "\n" + "2 : " + req["results"][1]["original_title"] + "\n" + "3 : " + req["results"][2]["original_title"] + "\n" + "4 : Exit"
print (movie_list)
choice= input()
option_1 = "Title => "+ req["results"][0]["original_title"] + "\n" + "Release Date => "+ req["results"][0]["release_date"] + "\n" + "Adult => "+ str(req["results"][0]["adult"]) + "\n" + "Language => "+ req["results"][0]["original_language"] + "\n" + "Ratings => "+ str(req["results"][0]["vote_average"])+ "\n" + "Overview => "+ req["results"][0]["overview"]
option_2 = "Title => "+ req["results"][1]["original_title"] + "\n" + "Release Date => "+ req["results"][1]["release_date"] + "\n" + "Adult => "+ str(req["results"][1]["adult"]) + "\n" + "Language => "+ req["results"][1]["original_language"] + "\n" + "Ratings => "+ str(req["results"][1]["vote_average"])+ "\n" + "Overview => "+ req["results"][1]["overview"]
option_3 = "Title => "+ req["results"][2]["original_title"] + "\n" + "Release Date => "+ req["results"][2]["release_date"] + "\n" + "Adult => "+ str(req["results"][2]["adult"]) + "\n" + "Language => "+ req["results"][2]["original_language"] + "\n" + "Ratings => "+ str(req["results"][2]["vote_average"])+ "\n" + "Overview => "+ req["results"][2]["overview"]
option_4 = "Bye Bye... \nHave a wonderful time :)"
if choice == "1":
print(option_1)
elif choice == "2":
print(option_2)
elif choice == "3":
print(option_3)
elif choice == "4":
print(option_4)
else:
print("Sorry I cannot understand what are you talking about.")
movieSearch()
# We took inspiration from this video https://www.youtube.com/watch?v=TRaXgtTauuE that how can we get better results with what we have.