Fix partial url paths join

pull/8/head
Filipe Santos 7 years ago
parent 1c52bbbcd1
commit a9283fdd1b
No known key found for this signature in database
GPG Key ID: 76BB130DA5573A4E

@ -1,7 +1,6 @@
from urllib.parse import urljoin
import backoff import backoff
import requests import requests
import os.path
from misc.log import logger from misc.log import logger
from misc import helpers from misc import helpers
@ -27,7 +26,11 @@ class Radarr:
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():
@ -41,7 +44,11 @@ class Radarr:
def get_movies(self): def get_movies(self):
try: try:
# make request # make request
req = requests.get(urljoin(self.server_url, 'api/movie'), headers=self.headers, timeout=60) req = requests.get(
os.path.join(self.server_url, 'api/movie'),
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)
@ -59,7 +66,11 @@ class Radarr:
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)
@ -100,7 +111,7 @@ class Radarr:
# make request # make request
req = requests.post( req = requests.post(
urljoin(self.server_url, 'api/movie'), os.path.join(self.server_url, 'api/movie'),
headers=self.headers, headers=self.headers,
json=payload, json=payload,
timeout=60 timeout=60

@ -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

Loading…
Cancel
Save