bazarr.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import requests
  2. import configparser
  3. config = configparser.RawConfigParser()
  4. config.read('config.cfg')
  5. token = config._sections['bazarr']['token']
  6. base_url = config._sections['bazarr']['url']
  7. def get_wanted_episodes():
  8. url = f"{base_url}/api/episodes/wanted"
  9. payload={}
  10. headers = {
  11. 'accept': 'application/json',
  12. 'X-API-KEY': token
  13. }
  14. response = requests.request("GET", url, headers=headers, data=payload)
  15. return response.json()
  16. def get_episode_details(episode_id: str):
  17. url = f"{base_url}/api/episodes?episodeid%5B%5D={episode_id}"
  18. payload={}
  19. headers = {
  20. 'accept': 'application/json',
  21. 'X-API-KEY': token
  22. }
  23. response = requests.request("GET", url, headers=headers, data=payload)
  24. return response.json()['data'][0]
  25. def sync_series():
  26. url = f"{base_url}/api/system/tasks?taskid=update_series"
  27. payload={}
  28. headers = {
  29. 'accept': 'application/json',
  30. 'X-API-KEY': token
  31. }
  32. response = requests.request("POST", url, headers=headers, data=payload)
  33. if response.status_code == 204:
  34. print('Updated Bazarr')