mirror of
https://github.com/nirvana-7777/script.service.ultimate.git
synced 2026-09-30 04:52:38 +02:00
Add hrti
This commit is contained in:
@@ -30,6 +30,7 @@ Currently supported:
|
||||
- 🇩🇪 **Magenta TV 2.0**
|
||||
- 🇦🇹 **Magenta TV (AT)**
|
||||
- 🇭🇷 **Max TV (HR)**
|
||||
- 🇭🇷 **HRTi (HR)**
|
||||
- 🇵🇱 **Magenta TV (PL)**
|
||||
- 🇲🇪 **Magenta TV (ME)**
|
||||
- 🇭🇺 **Magenta TV (HU)**
|
||||
|
||||
@@ -406,6 +406,39 @@ class KodiSettingsBridge:
|
||||
logger.info(f"Synced proxy config from Kodi to file for {provider}")
|
||||
return success
|
||||
|
||||
def read_ip_address_from_kodi(self, provider: str, country: Optional[str] = None) -> Optional[str]:
|
||||
"""
|
||||
Read IP address from Kodi settings for a provider.
|
||||
Uses convention: {provider}_{country}_ipaddress or {provider}_ipaddress
|
||||
|
||||
Args:
|
||||
provider: Provider name (e.g., 'hrti')
|
||||
country: Optional country code
|
||||
|
||||
Returns:
|
||||
Configured IP address or None if not set
|
||||
"""
|
||||
if not self.is_kodi_environment():
|
||||
return None
|
||||
|
||||
country_suffix = f"_{country}" if country else ""
|
||||
|
||||
try:
|
||||
ip_address = self.addon.getSetting(f'{provider}{country_suffix}_ipaddress')
|
||||
|
||||
logger.debug(f"IP address setting for {provider}{country_suffix}: '{ip_address}'")
|
||||
|
||||
if ip_address and ip_address.strip():
|
||||
logger.info(f"Found configured IP address for {provider}{country_suffix}: {ip_address}")
|
||||
return ip_address.strip()
|
||||
|
||||
logger.debug(f"No IP address configured for {provider}{country_suffix}")
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error reading IP address from Kodi for {provider}: {e}")
|
||||
return None
|
||||
|
||||
# ============= Comparison Helpers =============
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -231,25 +231,63 @@ class HRTiAuthenticator(BaseAuthenticator):
|
||||
return token
|
||||
|
||||
def _get_ip_address(self) -> str:
|
||||
"""Get public IP address"""
|
||||
"""Get public IP address - prefer configured IP from settings, fallback to API"""
|
||||
if self._ip_address:
|
||||
return self._ip_address
|
||||
|
||||
# Priority 1: Try to get configured IP from Kodi settings
|
||||
try:
|
||||
# Use the http_manager that's guaranteed to be available
|
||||
configured_ip = self._get_configured_ip_from_settings()
|
||||
if configured_ip:
|
||||
self._ip_address = configured_ip
|
||||
logger.info(f"Using configured IP address from Kodi settings: {self._ip_address}")
|
||||
return self._ip_address
|
||||
except Exception as e:
|
||||
logger.debug(f"Could not read configured IP from settings: {e}")
|
||||
|
||||
# Priority 2: Fall back to API fetch if no configured IP
|
||||
try:
|
||||
logger.debug("No configured IP found, fetching from API...")
|
||||
response = self.http_manager.get(
|
||||
self.config.api_endpoints['get_ip'],
|
||||
operation='api'
|
||||
)
|
||||
response.raise_for_status()
|
||||
self._ip_address = response.text.strip().strip('"') # Remove quotes if present
|
||||
logger.debug(f"Retrieved IP address: {self._ip_address}")
|
||||
logger.info(f"Retrieved IP address from API: {self._ip_address}")
|
||||
return self._ip_address
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting IP address: {e}")
|
||||
logger.error(f"Error getting IP address from API: {e}")
|
||||
self._ip_address = "0.0.0.0" # Fallback
|
||||
return self._ip_address
|
||||
|
||||
def _get_configured_ip_from_settings(self) -> Optional[str]:
|
||||
"""
|
||||
Get configured IP address from Kodi settings via settings_manager
|
||||
|
||||
Returns:
|
||||
Configured IP address or None if not available
|
||||
"""
|
||||
# Access settings_manager through parent class
|
||||
if not hasattr(self, 'settings_manager') or not self.settings_manager:
|
||||
logger.debug("Settings manager not available for IP configuration")
|
||||
return None
|
||||
|
||||
kodi_bridge = self.settings_manager.kodi_bridge
|
||||
if not kodi_bridge or not kodi_bridge.is_kodi_environment():
|
||||
logger.debug("Kodi bridge not available or not in Kodi environment")
|
||||
return None
|
||||
|
||||
# Try to read IP from Kodi settings
|
||||
# HRTi doesn't use country in this implementation, pass None
|
||||
configured_ip = kodi_bridge.read_ip_address_from_kodi('hrti', None)
|
||||
|
||||
if configured_ip:
|
||||
logger.debug(f"Found configured IP in Kodi settings: {configured_ip}")
|
||||
return configured_ip
|
||||
|
||||
return None
|
||||
|
||||
def _get_environment_config(self):
|
||||
"""Get HRTi environment configuration"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user