Advertisement
AyanUpadhaya

Get Tv Show Data Using Python and API/ JSON Data

Aug 3rd, 2021
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. # Get tv show data using python and api
  2. # site - tvmaze.com/api
  3. # script by - Ayan Upadahya
  4. # contact -> ayanU881@gmail.com
  5. # twitter -> https://twitter.com/ayanupadhaya96
  6. # GitHub  -> github.com/AyanUpadhaya
  7. # Youtube -> Code Tech :https://www.youtube.com/channel/UCsjnvE4i5Z-VR-lWhODX99w
  8.  
  9. import requests
  10. import json
  11.  
  12. print('Enter your Search:')
  13. search=input()
  14.  
  15. url="https://api.tvmaze.com/singlesearch/shows?q="+search
  16.  
  17. response = requests.get(url,timeout=6)
  18.  
  19. if response.status_code==200:
  20.     data= json.loads(response.text)
  21.    
  22.     print('Show Name: '+data['name'])
  23.     print('Language: '+data['language'])
  24.     print('Genres: '+str(data['genres']))
  25.     print('Status: '+data['status'])
  26.     print("Premiered: "+data['premiered'])
  27.     print("Rating: "+str(data['rating']['average']))
  28.     print('Summary: '+data["summary"])
  29.  
  30.     with open('moviedata.json','w') as f:
  31.         json.dump(data,f)
  32. else:
  33.     print(f"Error {response.status_code}")
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement