extract jellyfin utils
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
from settings import settings
|
||||
from jellyfin_apiclient_python import JellyfinClient
|
||||
from getmac import get_mac_address
|
||||
from jellyfin.models import JellyfinMediaItem, JellyfinMediaType, JellyfinMusicMediaMetadata, JellyfinMovieMediaMetadata, JellyfinEpisodeMediaMetadata
|
||||
from jellyfin.utils import JellyfinUtils
|
||||
from datetime import datetime
|
||||
from typing import Optional, Tuple
|
||||
import logging
|
||||
import time
|
||||
import os
|
||||
|
||||
|
||||
class JellyfinApiClient:
|
||||
"""
|
||||
@@ -18,14 +16,11 @@ class JellyfinApiClient:
|
||||
"""
|
||||
Initializes the Jellyfin API client and authenticates with the server.
|
||||
"""
|
||||
machine_name = os.uname().nodename
|
||||
unique_id = get_mac_address(hostname="localhost")
|
||||
|
||||
self.logger = logging.getLogger('JellyfinApiClient')
|
||||
|
||||
self.logger.info("Connecting to Jellyfin server...")
|
||||
self.client = JellyfinClient()
|
||||
self.client.config.app('jellydisc', '0.1.1', machine_name, unique_id)
|
||||
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://')
|
||||
|
||||
|
||||
23
jellyfin/utils.py
Normal file
23
jellyfin/utils.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from getmac import get_mac_address
|
||||
import os
|
||||
|
||||
class JellyfinUtils:
|
||||
@staticmethod
|
||||
def get_machine_name() -> str:
|
||||
"""
|
||||
Retrieves the machine name of the current host.
|
||||
|
||||
Returns:
|
||||
str: The machine name.
|
||||
"""
|
||||
return os.uname().nodename
|
||||
|
||||
@staticmethod
|
||||
def get_unique_id() -> str:
|
||||
"""
|
||||
Retrieves the MAC address of the localhost as a unique identifier.
|
||||
|
||||
Returns:
|
||||
str: The MAC address.
|
||||
"""
|
||||
return get_mac_address(hostname="localhost")
|
||||
Reference in New Issue
Block a user