diff --git a/lib/streaming_providers/providers/hrti/constants.py b/lib/streaming_providers/providers/hrti/constants.py index 69c7cb4..c687474 100644 --- a/lib/streaming_providers/providers/hrti/constants.py +++ b/lib/streaming_providers/providers/hrti/constants.py @@ -35,9 +35,6 @@ class HRTiDefaults: "profiles": f"{HSAPI_BASE_URL}/ProfilesGet", } - # DRM and License endpoints - LICENSE_URL = "https://lic.drmtoday.com/license-proxy-widevine/cenc/" - # Device information DEVICE_REFERENCE_ID = "6" # String '6' as required by headers OPERATOR_REFERENCE_ID = "hrt" @@ -73,9 +70,6 @@ class HRTiConfig: # API endpoints configuration self.api_endpoints = config.get("api_endpoints", HRTiDefaults.API_ENDPOINTS.copy()) - # DRM and License - self.license_url = config.get("license_url", HRTiDefaults.LICENSE_URL) - # Device configuration self.device_reference_id = config.get( "device_reference_id", HRTiDefaults.DEVICE_REFERENCE_ID diff --git a/lib/streaming_providers/providers/hrti/provider.py b/lib/streaming_providers/providers/hrti/provider.py index fd70154..b5fa70f 100644 --- a/lib/streaming_providers/providers/hrti/provider.py +++ b/lib/streaming_providers/providers/hrti/provider.py @@ -5,7 +5,7 @@ from typing import ClassVar, Dict, List, Optional import requests -from ...base.models import DRMConfig, DRMSystem, LicenseConfig, LicenseUnwrapperParams, StreamingChannel, Event +from ...base.models import DRMConfig, DRMSystem, StreamingChannel, Event from ...base.models.proxy_models import ProxyConfig from ...base.provider import AuthType, StreamingProvider from ...base.utils import logger @@ -460,39 +460,29 @@ class HRTiProvider(StreamingProvider): logger.debug(f"Generated license data for session {session_id}") - # Build the license request headers in the format expected by inputstream.adaptive - # Format: Key1=Value1&Key2=Value2 - license_headers = "&".join( - [ - f"User-Agent={self.hrti_config.user_agent}", - f"origin={self.hrti_config.base_website}", - f"referer={self.hrti_config.base_website}/", - f"dt-custom-data={license_data}", - ] + # Use DRMToday helper with HRTi-specific header name + from ..lib_drmtoday import create_drmtoday_widevine_config + + # Create Widevine config using DRMToday helper + # HRTi uses 'dt-custom-data' header instead of 'x-dt-auth-token' + drm_config = create_drmtoday_widevine_config( + upfront_token=license_data, + origin=self.hrti_config.base_website, + referer=f"{self.hrti_config.base_website}/", + user_agent=self.hrti_config.user_agent, + auth_header_name="dt-custom-data", # HRTi-specific header name ) - # Create the license configuration - # Use the class method to create LicenseConfig with base64 encoded req_data - license_config = LicenseConfig.create_with_req_data( - req_data_template="{CHA-RAW}", # The placeholder string - server_url=self.hrti_config.license_url, - use_http_get_request=False, - req_headers=license_headers, - wrapper=None, - unwrapper="json,base64", - unwrapper_params=LicenseUnwrapperParams(path_data="license"), - ) - - # Create the DRM configuration - drm_config = DRMConfig(system=DRMSystem.WIDEVINE, priority=1, license=license_config) - - logger.debug(f"Created DRM config for channel {content_id} with DrmId {drm_id}") - return [drm_config] + if drm_config: + logger.debug(f"Created DRM config for channel {content_id} with DrmId {drm_id}") + return [drm_config] + else: + logger.error("Failed to create DRM config") + return [] except Exception as e: logger.error(f"Error getting DRM config for channel {content_id}: {e}") import traceback - logger.error(f"Traceback: {traceback.format_exc()}") return [] diff --git a/lib/streaming_providers/providers/lib_drmtoday.py b/lib/streaming_providers/providers/lib_drmtoday.py index f788fcf..f6026ed 100644 --- a/lib/streaming_providers/providers/lib_drmtoday.py +++ b/lib/streaming_providers/providers/lib_drmtoday.py @@ -36,20 +36,19 @@ def create_drmtoday_widevine_config( user_agent: str, license_url: Optional[str] = None, priority: int = 3, + auth_header_name: str = "x-dt-auth-token", # NEW parameter ) -> DRMConfig: """ Create Widevine DRM configuration for DRMToday. Args: - upfront_token: DRMToday upfront token (x-dt-auth-token) - origin: Origin header value (e.g., "https://plus.rtl.de") + upfront_token: DRMToday upfront token + origin: Origin header value referer: Referer header value user_agent: User-Agent string - license_url: Optional custom license URL (uses default if not provided) - priority: DRM priority (default 3) - - Returns: - DRMConfig ready for use in ISA + license_url: Optional custom license URL + priority: DRM priority + auth_header_name: Header name for the token (default: x-dt-auth-token) """ license_url = license_url or DRMTodayConfig.DEFAULT_WIDEVINE_URL @@ -57,12 +56,12 @@ def create_drmtoday_widevine_config( "user-agent": user_agent, "origin": origin, "referer": referer, - "x-dt-auth-token": upfront_token, + auth_header_name: upfront_token, # Use dynamic header name } license_config = LicenseConfig( server_url=license_url, - req_headers=headers, # LicenseConfig will normalize this to URL-encoded + req_headers=headers, req_data="{CHA-RAW}", use_http_get_request=False, unwrapper=DRMTodayConfig.UNWRAPPER,