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