Fix taa_client

This commit is contained in:
Nirvana
2025-11-15 14:15:07 +01:00
parent bfad68ccae
commit 9113f032b9
2 changed files with 14 additions and 7 deletions
@@ -24,7 +24,7 @@ MAGENTA2_PLATFORMS = {
'android-tv': {
'device_name': 'Android TV',
'firmware': 'Android 11',
'user_agent': 'Mozilla/5.0 (Linux; Android 11; Android TV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
'user_agent': 'Dalvik/2.1.0 (Linux; U; Android 11; SHIELD Android TV Build/RQ1A.210105.003) ((2.00T_ATV::3.134.4462::mdarcy::))',
'terminal_type': 'ATV_ANDROIDTV',
# TAA-specific device identification (API level format required)
'taa_device_model': 'SHIELD Android TV',
@@ -133,8 +133,8 @@ class TaaClient:
except Exception as e:
logger.error(f"TAA authentication failed: {e}")
# Try to extract error details if available
if hasattr(e, 'response') and e.response is not None:
# Try to extract error details if available (for requests.HTTPError)
if hasattr(e, 'response') and hasattr(e.response, 'text'):
try:
error_body = e.response.text
logger.error(f"TAA error response body: {error_body}")
@@ -271,7 +271,8 @@ class TaaClient:
return result
def _parse_taa_jwt_complete(self, jwt_token: str) -> Dict[str, Any]:
@staticmethod
def _parse_taa_jwt_complete(jwt_token: str) -> Dict[str, Any]:
"""
Complete JWT parsing extracting ALL required fields from TAA token
"""
@@ -375,11 +376,17 @@ class TaaClient:
return {}
def _get_taa_headers(self, sam3_token: str) -> Dict[str, str]:
"""Get headers for TAA requests"""
"""Get headers for TAA requests with required requestId"""
import uuid
# Use TAA-specific user agent if available, otherwise fallback to platform user agent
user_agent = self.platform_config.get('taa_user_agent') or self.platform_config['user_agent']
headers = {
'User-Agent': self.platform_config['user_agent'],
'requestId': str(uuid.uuid4()), # Required by TAA endpoint!
'User-Agent': user_agent,
'Accept': 'application/json',
'Content-Type': 'application/json'
'Content-Type': 'application/json; charset=UTF-8'
}
# Only add Authorization header if we have a token