sonarr.py 602 B

12345678910111213141516171819202122232425
  1. import requests
  2. import json
  3. import configparser
  4. config = configparser.RawConfigParser()
  5. config.read('config.cfg')
  6. token = config._sections['sonarr']['token']
  7. base_url = config._sections['sonarr']['url']
  8. def update_show_in_soarr(show_id):
  9. url = f"{base_url}/api/v3/command"
  10. payload = json.dumps({
  11. "name": "RefreshSeries",
  12. "seriesId": show_id
  13. })
  14. headers = {
  15. 'Content-Type': 'application/json',
  16. 'X-Api-Key': token,
  17. }
  18. response = requests.request("POST", url, headers=headers, data=payload)
  19. if response.status_code != 404:
  20. print("Updated show in Sonarr")