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