configure client in utils method
This commit is contained in:
@@ -10,23 +10,24 @@ import time
|
||||
class JellyfinApiClient:
|
||||
"""
|
||||
Client for interacting with the Jellyfin server API.
|
||||
|
||||
Attributes:
|
||||
last_auth_time (Optional[float]): Timestamp of the last authentication.
|
||||
logger (logging.Logger): Logger instance for logging messages.
|
||||
"""
|
||||
last_auth_time: Optional[float] = None
|
||||
logger: logging.Logger = logging.getLogger('JellyfinApiClient')
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Initializes the Jellyfin API client and authenticates with the server.
|
||||
"""
|
||||
self.logger = logging.getLogger('JellyfinApiClient')
|
||||
|
||||
self.logger.info("Connecting to Jellyfin server...")
|
||||
|
||||
self.client = JellyfinClient()
|
||||
self.client.config.app('jellydisc', '0.1.2', JellyfinUtils.get_machine_name(), JellyfinUtils.get_unique_id())
|
||||
self.client.config.data['auth.ssl'] = settings.jellyfin_server_url.startswith(
|
||||
'https://')
|
||||
JellyfinUtils.configure_client(self.client)
|
||||
|
||||
self.last_auth_time = None
|
||||
self.authenticate()
|
||||
|
||||
self.logger.info("Connected to Jellyfin server.")
|
||||
|
||||
def authenticate(self):
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
from jellyfin_apiclient_python import JellyfinClient
|
||||
from getmac import get_mac_address
|
||||
from settings import settings
|
||||
import os
|
||||
|
||||
class JellyfinUtils:
|
||||
@staticmethod
|
||||
def configure_client(client: JellyfinClient):
|
||||
client.config.app(
|
||||
settings.app_name,
|
||||
settings.app_version,
|
||||
JellyfinUtils.get_machine_name(),
|
||||
JellyfinUtils.get_unique_id()
|
||||
)
|
||||
client.config.data['auth.ssl'] = settings.jellyfin_server_url.startswith('https://')
|
||||
|
||||
@staticmethod
|
||||
def get_machine_name() -> str:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user