IAmSalvaMartini

Untitled

Oct 11th, 2021 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. import pprint
  2. import pandas as pd
  3. import requests
  4.  
  5. api_key = "a7641fe569c0edb889f3c8ac311e78a2"
  6. api_key_v4 = "eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJhNzY0MWZlNTY5YzBlZGI4ODlmM2M4YWMzMTFlNzhhMiIsInN1YiI6IjYxNjNkMDg1NjJmY2QzMDAyYjQ4NDQ5MiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.8OxnnysYBvGV_ZH1HIhfSZhZIqeigYEmVDPufuer0fg"
  7.  
  8. #endpoint
  9. """
  10. ENDPOINT
  11. GET
  12. /movie/{movie_id}
  13. https://api.themoviedb.org/3/movie/550?api_key=a7641fe569c0edb889f3c8ac311e78a2
  14. """
  15. movie_id = 501
  16. api_version = 3
  17. api_base_url = f"https://api.themoviedb.org/{api_version}"
  18. search_query = input("Enter Movie Name : ")
  19. endpoint_path = f"/search/movie"
  20. endpoint = f"{api_base_url}{endpoint_path}?api_key={api_key}&query={search_query}"
  21.  
  22.  
  23. # print(endpoint)
  24. r = requests.get(endpoint)
  25. # pprint.pprint(r.json())
  26. if r.status_code in range(200, 299):
  27.     data=r.json()
  28.     results = data['results']
  29.     if len(results) > 0:
  30.         # print(results[0].keys())
  31.         movie_ids = set()
  32.         for result in results:
  33.             _id = result['id']
  34.             # print(result['title'], _id)
  35.             movie_ids.add(_id)
  36.         # print(list(movie_ids))
  37.         pprint.pprint(r.json())
Add Comment
Please, Sign In to add comment