Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pprint
- import pandas as pd
- import requests
- api_key = "a7641fe569c0edb889f3c8ac311e78a2"
- api_key_v4 = "eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJhNzY0MWZlNTY5YzBlZGI4ODlmM2M4YWMzMTFlNzhhMiIsInN1YiI6IjYxNjNkMDg1NjJmY2QzMDAyYjQ4NDQ5MiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.8OxnnysYBvGV_ZH1HIhfSZhZIqeigYEmVDPufuer0fg"
- #endpoint
- """
- ENDPOINT
- GET
- /movie/{movie_id}
- https://api.themoviedb.org/3/movie/550?api_key=a7641fe569c0edb889f3c8ac311e78a2
- """
- movie_id = 501
- api_version = 3
- api_base_url = f"https://api.themoviedb.org/{api_version}"
- search_query = input("Enter Movie Name : ")
- endpoint_path = f"/search/movie"
- endpoint = f"{api_base_url}{endpoint_path}?api_key={api_key}&query={search_query}"
- # print(endpoint)
- r = requests.get(endpoint)
- # pprint.pprint(r.json())
- if r.status_code in range(200, 299):
- data=r.json()
- results = data['results']
- if len(results) > 0:
- # print(results[0].keys())
- movie_ids = set()
- for result in results:
- _id = result['id']
- # print(result['title'], _id)
- movie_ids.add(_id)
- # print(list(movie_ids))
- pprint.pprint(r.json())
Add Comment
Please, Sign In to add comment