From aeafc2db412fcfc4ba53910f83a796fc9c04dcb5 Mon Sep 17 00:00:00 2001 From: trueold89 Date: Sat, 4 May 2024 04:08:21 +0300 Subject: [PATCH] Update DirectoryGetter --- DirectoryGetter.py | 12 +++++++----- TYPES.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/DirectoryGetter.py b/DirectoryGetter.py index 0fe863f..32eac5c 100644 --- a/DirectoryGetter.py +++ b/DirectoryGetter.py @@ -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: diff --git a/TYPES.py b/TYPES.py index 40a96af..fed91d6 100644 --- a/TYPES.py +++ b/TYPES.py @@ -1 +1,12 @@ # -*- coding: utf-8 -*- +from enum import Enum + + +class DirParserTypes(Enum): + Jellyfin = "Jellyfin" + + +class LogTypes(Enum): + LOG = "Log" + ERROR = "Error" + WARN = "Warning"