extract jellyfin utils
This commit is contained in:
3
changelog/0.1.2.md
Normal file
3
changelog/0.1.2.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# 0.1.2
|
||||||
|
|
||||||
|
- Extracted utility functions from JellyfinApiClient to JellyfinUtils
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
from settings import settings
|
from settings import settings
|
||||||
from jellyfin_apiclient_python import JellyfinClient
|
from jellyfin_apiclient_python import JellyfinClient
|
||||||
from getmac import get_mac_address
|
|
||||||
from jellyfin.models import JellyfinMediaItem, JellyfinMediaType, JellyfinMusicMediaMetadata, JellyfinMovieMediaMetadata, JellyfinEpisodeMediaMetadata
|
from jellyfin.models import JellyfinMediaItem, JellyfinMediaType, JellyfinMusicMediaMetadata, JellyfinMovieMediaMetadata, JellyfinEpisodeMediaMetadata
|
||||||
|
from jellyfin.utils import JellyfinUtils
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
class JellyfinApiClient:
|
class JellyfinApiClient:
|
||||||
"""
|
"""
|
||||||
@@ -18,14 +16,11 @@ class JellyfinApiClient:
|
|||||||
"""
|
"""
|
||||||
Initializes the Jellyfin API client and authenticates with the server.
|
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 = logging.getLogger('JellyfinApiClient')
|
||||||
|
|
||||||
self.logger.info("Connecting to Jellyfin server...")
|
self.logger.info("Connecting to Jellyfin server...")
|
||||||
self.client = JellyfinClient()
|
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(
|
self.client.config.data['auth.ssl'] = settings.jellyfin_server_url.startswith(
|
||||||
'https://')
|
'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