Update DirectoryGetter
This commit is contained in:
parent
4f7b6de5a6
commit
aeafc2db41
|
@ -15,7 +15,7 @@ class DirectoryGetter(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def CheckAvailability(self) -> bool:
|
def validation(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks if the directory parsing method is available
|
Checks if the directory parsing method is available
|
||||||
:return: boolean check result
|
:return: boolean check result
|
||||||
|
@ -26,12 +26,14 @@ class Jellyfin(DirectoryGetter):
|
||||||
def __init__(self, url: str, api_key: str) -> None:
|
def __init__(self, url: str, api_key: str) -> None:
|
||||||
self.url = url
|
self.url = url
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
|
if self.url[-1] == "/":
|
||||||
|
self.url = self.url[:-1]
|
||||||
|
if not (self.validation()):
|
||||||
|
raise Exception("Error connecting to JellyfinAPI")
|
||||||
|
|
||||||
def CheckAvailability(self) -> bool:
|
def validation(self) -> bool:
|
||||||
if self.__get("Library/VirtualFolders").status_code == 200:
|
if self.__get("Library/VirtualFolders").status_code == 200:
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
raise Exception("Error connecting to JellyfinAPI")
|
|
||||||
|
|
||||||
def __get(self, api_path: str) -> Response:
|
def __get(self, api_path: str) -> Response:
|
||||||
request = req_get(f"{self.url}/{api_path}?api_key={self.api_key}")
|
request = req_get(f"{self.url}/{api_path}?api_key={self.api_key}")
|
||||||
|
@ -40,7 +42,7 @@ class Jellyfin(DirectoryGetter):
|
||||||
case 200:
|
case 200:
|
||||||
return request
|
return request
|
||||||
case 401:
|
case 401:
|
||||||
raise Exception("Error 401: Authorization error, check api key")
|
raise Exception("Error 401: Authorization error, check API key")
|
||||||
case 403:
|
case 403:
|
||||||
raise Exception("Error 403: Forbidden")
|
raise Exception("Error 403: Forbidden")
|
||||||
case 404:
|
case 404:
|
||||||
|
|
Reference in New Issue