mirror of
https://github.com/nirvana-7777/script.service.ultimate.git
synced 2026-09-17 06:32:30 +02:00
Fix base provider class
This commit is contained in:
@@ -60,7 +60,7 @@ class StreamingProvider(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def fetch_channels(self, **kwargs) -> List[StreamingChannel]:
|
||||
def get_channels(self, **kwargs) -> List[StreamingChannel]:
|
||||
"""
|
||||
Fetch channels from the provider
|
||||
|
||||
@@ -82,7 +82,8 @@ class StreamingProvider(ABC):
|
||||
# """
|
||||
# return []
|
||||
|
||||
def get_drm_configs_by_id(self, channel_id: str, **kwargs) -> List[DRMConfig]:
|
||||
@abstractmethod
|
||||
def get_drm(self, channel_id: str, **kwargs) -> List[DRMConfig]:
|
||||
"""
|
||||
Get all DRM configurations for a channel by ID
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ class JoynProvider(StreamingProvider):
|
||||
self.bearer_token = self.authenticator.get_bearer_token(force_refresh=True)
|
||||
return self.bearer_token
|
||||
|
||||
def fetch_channels(self,
|
||||
def get_channels(self,
|
||||
time_window_hours: int = DEFAULT_EPG_WINDOW_HOURS,
|
||||
fetch_manifests: bool = False,
|
||||
populate_streaming_data: bool = True,
|
||||
@@ -632,11 +632,11 @@ class JoynProvider(StreamingProvider):
|
||||
logger.error(f"Error getting manifest for channel {channel_id}: {e}")
|
||||
return None
|
||||
|
||||
def get_drm_configs_by_id(self,
|
||||
channel_id: str,
|
||||
content_type: str = CONTENT_TYPE_LIVE,
|
||||
video_config: Optional[Dict] = None,
|
||||
**kwargs) -> List[DRMConfig]:
|
||||
def get_drm(self,
|
||||
channel_id: str,
|
||||
content_type: str = CONTENT_TYPE_LIVE,
|
||||
video_config: Optional[Dict] = None,
|
||||
**kwargs) -> List[DRMConfig]:
|
||||
"""
|
||||
Get all DRM configurations for a channel by ID
|
||||
|
||||
|
||||
@@ -680,7 +680,7 @@ class Magenta2Provider(StreamingProvider):
|
||||
logger.warning(f"Error creating channel from entry: {e}")
|
||||
return None
|
||||
|
||||
def fetch_channels(self,
|
||||
def get_channels(self,
|
||||
time_window_hours: int = DEFAULT_EPG_WINDOW_HOURS,
|
||||
fetch_manifests: bool = False,
|
||||
populate_streaming_data: bool = True,
|
||||
@@ -1350,8 +1350,8 @@ class Magenta2Provider(StreamingProvider):
|
||||
logger.error(f"Error extracting persona JWT token: {e}")
|
||||
return None
|
||||
|
||||
def get_drm_configs_by_id(self, channel_id: str, content_type: str = CONTENT_TYPE_LIVE,
|
||||
**kwargs) -> List[DRMConfig]:
|
||||
def get_drm(self, channel_id: str, content_type: str = CONTENT_TYPE_LIVE,
|
||||
**kwargs) -> List[DRMConfig]:
|
||||
"""Get DRM configuration using unified SMIL data"""
|
||||
try:
|
||||
smil_data = self._get_smil_data(channel_id)
|
||||
|
||||
@@ -14,7 +14,8 @@ from ...base.network import HTTPManager
|
||||
from ...base.utils.logger import logger
|
||||
from ...base.ui import NotificationFactory, NotificationInterface, NotificationResult
|
||||
from .constants import (
|
||||
SSO_USER_AGENT,
|
||||
MAGENTA2_PLATFORMS,
|
||||
DEFAULT_PLATFORM,
|
||||
DEFAULT_REQUEST_TIMEOUT,
|
||||
GRANT_TYPES,
|
||||
)
|
||||
@@ -64,6 +65,8 @@ class RemoteLoginHandler:
|
||||
self.backchannel_start_url = backchannel_start_url
|
||||
self.token_endpoint = token_endpoint
|
||||
self.qr_code_url_template = qr_code_url_template
|
||||
self.platform_config = MAGENTA2_PLATFORMS.get(MAGENTA2_PLATFORMS[DEFAULT_PLATFORM])
|
||||
self.user_agent = self.platform_config['user_agent']
|
||||
|
||||
# Get or create notifier with http_manager
|
||||
if notifier:
|
||||
@@ -103,7 +106,7 @@ class RemoteLoginHandler:
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': SSO_USER_AGENT
|
||||
'User-Agent': self.user_agent
|
||||
}
|
||||
|
||||
logger.debug(f"Backchannel auth request:")
|
||||
@@ -252,7 +255,7 @@ class RemoteLoginHandler:
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': SSO_USER_AGENT
|
||||
'User-Agent': self.user_agent
|
||||
}
|
||||
|
||||
payload = {
|
||||
@@ -268,7 +271,7 @@ class RemoteLoginHandler:
|
||||
while True:
|
||||
current_time = time.time()
|
||||
elapsed = current_time - start_time
|
||||
remaining = max(0, session.expires_in - elapsed)
|
||||
remaining = max(0, int(session.expires_in - elapsed))
|
||||
|
||||
# Check if session expired
|
||||
if elapsed >= session.expires_in:
|
||||
@@ -440,7 +443,7 @@ class RemoteLoginHandler:
|
||||
|
||||
session = self._current_session
|
||||
elapsed = time.time() - session.started_at
|
||||
remaining = max(0, session.expires_in - elapsed)
|
||||
remaining = max(0, int(session.expires_in - elapsed))
|
||||
|
||||
return {
|
||||
'login_code': session.initial_login_code,
|
||||
|
||||
@@ -115,7 +115,7 @@ class MagentaProvider(StreamingProvider):
|
||||
self.bearer_token = self.authenticator.get_bearer_token(force_refresh=True)
|
||||
return self.bearer_token
|
||||
|
||||
def fetch_channels(self, **kwargs) -> List[StreamingChannel]:
|
||||
def get_channels(self, **kwargs) -> List[StreamingChannel]:
|
||||
"""Fetch available channels from Magenta TV - no authentication required"""
|
||||
try:
|
||||
# USE AUTHENTICATOR'S SESSION IDs (single source of truth)
|
||||
@@ -248,7 +248,7 @@ class MagentaProvider(StreamingProvider):
|
||||
return channel.manifest
|
||||
return None
|
||||
|
||||
def get_drm_configs_by_id(self, channel_id: str, **kwargs) -> List[DRMConfig]:
|
||||
def get_drm(self, channel_id: str, **kwargs) -> List[DRMConfig]:
|
||||
"""Get DRM configurations for channel by ID"""
|
||||
logger.info(f"=== get_drm_configs_by_id CALLED for channel_id: {channel_id} ===")
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class RTLPlusProvider(StreamingProvider):
|
||||
bearer_token = self.auth.get_bearer_token(force_upgrade=True)
|
||||
return self.rtl_config.get_api_headers(access_token=bearer_token)
|
||||
|
||||
def fetch_channels(self, **kwargs) -> List[StreamingChannel]:
|
||||
def get_channels(self, **kwargs) -> List[StreamingChannel]:
|
||||
"""
|
||||
Fetch channels from RTL+ GraphQL API with authentication
|
||||
"""
|
||||
@@ -200,7 +200,7 @@ class RTLPlusProvider(StreamingProvider):
|
||||
channel.set_static_manifest(manifest_url)
|
||||
|
||||
# Check if this channel has DRM
|
||||
drm_configs = self.get_drm_configs_by_id(channel.channel_id, **kwargs)
|
||||
drm_configs = self.get_drm(channel.channel_id, **kwargs)
|
||||
if drm_configs:
|
||||
# Set DRM configuration
|
||||
channel.use_cdm = True
|
||||
@@ -309,7 +309,7 @@ class RTLPlusProvider(StreamingProvider):
|
||||
except Exception:
|
||||
return manifest_data
|
||||
|
||||
def get_drm_configs_by_id(self, channel_id: str, **kwargs) -> List[DRMConfig]:
|
||||
def get_drm(self, channel_id: str, **kwargs) -> List[DRMConfig]:
|
||||
"""
|
||||
Get DRM configurations for a channel from RTL+ streaming API
|
||||
"""
|
||||
@@ -415,7 +415,7 @@ class RTLPlusProvider(StreamingProvider):
|
||||
"""
|
||||
Get license URL for a DRM-protected channel
|
||||
"""
|
||||
drm_configs = self.get_drm_configs_by_id(channel.channel_id, **kwargs)
|
||||
drm_configs = self.get_drm(channel.channel_id, **kwargs)
|
||||
if drm_configs:
|
||||
# Return the first license URL found
|
||||
return drm_configs[0].license.server_url
|
||||
|
||||
Reference in New Issue
Block a user