|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
from urllib.parse import urljoin
|
|
|
|
|
|
|
|
|
|
import backoff
|
|
|
|
|
import requests
|
|
|
|
|
import os.path
|
|
|
|
|
|
|
|
|
|
from misc import helpers
|
|
|
|
|
from misc.log import logger
|
|
|
|
@ -26,7 +25,7 @@ class Sonarr:
|
|
|
|
|
def validate_api_key(self):
|
|
|
|
|
try:
|
|
|
|
|
# request system status to validate api_key
|
|
|
|
|
req = requests.get(urljoin(self.server_url, 'api/system/status'), headers=self.headers, timeout=60)
|
|
|
|
|
req = requests.get(os.path.join(self.server_url, 'api/system/status'), headers=self.headers, timeout=60)
|
|
|
|
|
log.debug("Request Response: %d", req.status_code)
|
|
|
|
|
|
|
|
|
|
if req.status_code == 200 and 'version' in req.json():
|
|
|
|
@ -40,7 +39,11 @@ class Sonarr:
|
|
|
|
|
def get_series(self):
|
|
|
|
|
try:
|
|
|
|
|
# make request
|
|
|
|
|
req = requests.get(urljoin(self.server_url, 'api/series'), headers=self.headers, timeout=60)
|
|
|
|
|
req = requests.get(
|
|
|
|
|
os.path.join(self.server_url, 'api/series'),
|
|
|
|
|
headers=self.headers,
|
|
|
|
|
timeout=60
|
|
|
|
|
)
|
|
|
|
|
log.debug("Request URL: %s", req.url)
|
|
|
|
|
log.debug("Request Response: %d", req.status_code)
|
|
|
|
|
|
|
|
|
@ -58,7 +61,11 @@ class Sonarr:
|
|
|
|
|
def get_profile_id(self, profile_name):
|
|
|
|
|
try:
|
|
|
|
|
# make request
|
|
|
|
|
req = requests.get(urljoin(self.server_url, 'api/profile'), headers=self.headers, timeout=60)
|
|
|
|
|
req = requests.get(
|
|
|
|
|
os.path.join(self.server_url, 'api/profile'),
|
|
|
|
|
headers=self.headers,
|
|
|
|
|
timeout=60
|
|
|
|
|
)
|
|
|
|
|
log.debug("Request URL: %s", req.url)
|
|
|
|
|
log.debug("Request Response: %d", req.status_code)
|
|
|
|
|
|
|
|
|
@ -80,7 +87,11 @@ class Sonarr:
|
|
|
|
|
def get_tag_id(self, tag_name):
|
|
|
|
|
try:
|
|
|
|
|
# make request
|
|
|
|
|
req = requests.get(urljoin(self.server_url, 'api/tag'), headers=self.headers, timeout=60)
|
|
|
|
|
req = requests.get(
|
|
|
|
|
os.path.join(self.server_url, 'api/tag'),
|
|
|
|
|
headers=self.headers,
|
|
|
|
|
timeout=60
|
|
|
|
|
)
|
|
|
|
|
log.debug("Request URL: %s", req.url)
|
|
|
|
|
log.debug("Request Response: %d", req.status_code)
|
|
|
|
|
|
|
|
|
@ -103,7 +114,11 @@ class Sonarr:
|
|
|
|
|
tags = {}
|
|
|
|
|
try:
|
|
|
|
|
# make request
|
|
|
|
|
req = requests.get(urljoin(self.server_url, 'api/tag'), headers=self.headers, timeout=60)
|
|
|
|
|
req = requests.get(
|
|
|
|
|
os.path.join(self.server_url, 'api/tag'),
|
|
|
|
|
headers=self.headers,
|
|
|
|
|
timeout=60
|
|
|
|
|
)
|
|
|
|
|
log.debug("Request URL: %s", req.url)
|
|
|
|
|
log.debug("Request Response: %d", req.status_code)
|
|
|
|
|
|
|
|
|
@ -144,7 +159,7 @@ class Sonarr:
|
|
|
|
|
|
|
|
|
|
# make request
|
|
|
|
|
req = requests.post(
|
|
|
|
|
urljoin(self.server_url, 'api/series'),
|
|
|
|
|
os.path.join(self.server_url, 'api/series'),
|
|
|
|
|
headers=self.headers,
|
|
|
|
|
json=payload,
|
|
|
|
|
timeout=60
|
|
|
|
|