This commit is contained in:
Nirvana
2025-11-29 17:45:03 +01:00
parent 478f50898f
commit 99fa11212c
2 changed files with 20 additions and 4 deletions
+18 -2
View File
@@ -298,11 +298,17 @@ class HRTiAuthenticator(BaseAuthenticator):
raise e
def _register_device(self):
"""Register device with HRTi using API headers"""
"""Register device with HRTi using API headers with proper authorization"""
try:
# Get the bearer token from current token
bearer_token = self._current_token.access_token if self._current_token else ''
# Use API headers with proper authorization and referer
headers = self._get_api_headers(bearer_token)
# Update the referer to root path for device registration
headers['referer'] = f'{self.config.base_website}/'
payload = {
"DeviceSerial": self._device_id,
"DeviceReferenceId": self.config.device_reference_id,
@@ -314,6 +320,13 @@ class HRTiAuthenticator(BaseAuthenticator):
"ClientType": self.config.client_type
}
# Log the request for debugging
safe_headers = headers.copy()
if 'authorization' in safe_headers:
safe_headers['authorization'] = f"{safe_headers['authorization'][:20]}..."
logger.debug(f"HRTi Device Registration Headers: {safe_headers}")
logger.debug(f"HRTi Device Registration Payload: {payload}")
response = self.http_manager.post(
self.config.api_endpoints['register_device'],
operation='api',
@@ -327,11 +340,14 @@ class HRTiAuthenticator(BaseAuthenticator):
logger.warning(f"HRTi device registration failed: {e}")
def _get_initial_data(self):
"""Get initial content rating and profiles using API headers"""
"""Get initial content rating and profiles using API headers with proper authorization"""
try:
bearer_token = self._current_token.access_token if self._current_token else ''
headers = self._get_api_headers(bearer_token)
# Update the referer to root path for these API calls
headers['referer'] = f'{self.config.base_website}/'
# Get content ratings
content_response = self.http_manager.post(
self.config.api_endpoints['content_ratings'],
@@ -42,9 +42,9 @@ class HRTiDefaults:
OPERATOR_REFERENCE_ID = 'hrt'
MERCHANT = 'aviion2'
CONNECTION_TYPE = 'LAN/WiFi'
APPLICATION_VERSION = '5.62.5'
APPLICATION_VERSION = '5.97.6'
OS_VERSION = 'Linux'
CLIENT_TYPE = 'Chrome 96'
CLIENT_TYPE = 'Chrome 142'
# User Agent
USER_AGENT = 'kodi plugin for hrti.hrt.hr (python)'