Skip to content

Commit

Permalink
Fixed additional slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
nickheyer committed Dec 1, 2024
1 parent 26521fc commit eac46b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions DiscoFlixBot/lib/api/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, host_url=None, api_key=None):
host_url (str): Host url to sonarr/radarr.
api_key: API key from sonarr/radarr.
"""
self.host_url = host_url
self.host_url = host_url.rstrip('/')
self.api_key = api_key
self.session = requests.Session()
self.auth = None
Expand Down Expand Up @@ -41,7 +41,7 @@ def request_get(self, path: str, **data) -> dict:
"""

headers = {"X-Api-Key": self.api_key}
request_url = f"{self.host_url}{path}"
request_url = f"{self.host_url}/{path.lstrip('/')}"

try:
response = self.session.get(
Expand All @@ -62,7 +62,7 @@ def request_post(self, path: str, data: dict) -> dict:
dict: Response JSON data.
"""
headers = {"X-Api-Key": self.api_key}
request_url = f"{self.host_url}{path}"
request_url = f"{self.host_url}/{path.lstrip('/')}"
try:
response = self.session.post(
request_url, headers=headers, json=data, auth=self.auth
Expand All @@ -82,7 +82,7 @@ def request_put(self, path: str, data: dict) -> dict:
dict: Response JSON data.
"""
headers = {"X-Api-Key": self.api_key}
request_url = f"{self.host_url}{path}"
request_url = f"{self.host_url}/{path.lstrip('/')}"
try:
response = self.session.put(
request_url, headers=headers, json=data, auth=self.auth
Expand All @@ -102,7 +102,7 @@ def request_delete(self, path: str, data: dict) -> dict:
dict: Response JSON data.
"""
headers = {"X-Api-Key": self.api_key}
request_url = f"{self.host_url}{path}"
request_url = f"{self.host_url}/{path.lstrip('/')}"
try:
response = self.session.delete(
request_url, headers=headers, json=data, auth=self.auth
Expand All @@ -115,3 +115,4 @@ def request_delete(self, path: str, data: dict) -> dict:
except ValueError:
# Catch JSON decode error in case the response has no body
return {}

3 changes: 2 additions & 1 deletion DiscoFlixBot/lib/api/sonarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,5 @@ def get_or_create_tag(self, tag_name="DF"):
return existing
else:
new = self.create_tag(label=tag_name)
return new.get('id', -1)
return new.get('id', -1)

0 comments on commit eac46b0

Please sign in to comment.