mirror of
https://github.com/nirvana-7777/script.service.ultimate.git
synced 2026-10-12 19:02:33 +02:00
Add discovery
This commit is contained in:
@@ -42,7 +42,7 @@ class CatchupOperations:
|
||||
|
||||
try:
|
||||
return provider.get_catchup_manifest(
|
||||
channel_id=channel_id,
|
||||
content_id=channel_id,
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
epg_id=epg_id,
|
||||
@@ -73,7 +73,7 @@ class CatchupOperations:
|
||||
|
||||
try:
|
||||
return provider.get_catchup_drm(
|
||||
channel_id=channel_id,
|
||||
content_id=channel_id,
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
epg_id=epg_id,
|
||||
|
||||
@@ -45,7 +45,7 @@ class ChannelOperations:
|
||||
if not provider:
|
||||
raise ValueError(f"Provider '{provider_name}' not found or disabled")
|
||||
|
||||
manifest_url = provider.get_manifest(channel_id, **kwargs)
|
||||
manifest_url = provider.get_manifest(content_id=channel_id, **kwargs)
|
||||
if manifest_url:
|
||||
logger.debug(f"Retrieved manifest for '{channel_id}' from '{provider_name}'")
|
||||
return manifest_url
|
||||
|
||||
@@ -329,7 +329,7 @@ class DRMOperations:
|
||||
# ------------------------------------------------------------------
|
||||
# Step 0a: Fetch manifest and short-circuit for unencrypted streams
|
||||
# ------------------------------------------------------------------
|
||||
manifest_url = provider.get_manifest(channel_id, **kwargs)
|
||||
manifest_url = provider.get_manifest(content_id=channel_id, **kwargs)
|
||||
if manifest_url and manifest_url.startswith(('http://', 'https://')):
|
||||
try:
|
||||
from .network import HTTPManager
|
||||
@@ -409,7 +409,7 @@ class DRMOperations:
|
||||
# ------------------------------------------------------------------
|
||||
# Step 3: PHASE 2 — Get provider's DRM configs
|
||||
# ------------------------------------------------------------------
|
||||
provider_drm_configs = provider.get_drm(channel_id, **kwargs)
|
||||
provider_drm_configs = provider.get_drm(content_id=channel_id, **kwargs)
|
||||
|
||||
# Secondary unencrypted check (in case manifest fetch failed earlier)
|
||||
if not provider_drm_configs:
|
||||
@@ -434,7 +434,7 @@ class DRMOperations:
|
||||
|
||||
if not pssh_data_list:
|
||||
logger.debug(f"Phase 2: PSSH cache miss for {cache_key}, fetching manifest")
|
||||
manifest_url = provider.get_manifest(channel_id, **kwargs)
|
||||
manifest_url = provider.get_manifest(content_id=channel_id, **kwargs)
|
||||
if manifest_url:
|
||||
pssh_data_list = self._extract_pssh_from_manifest(manifest_url, provider_name)
|
||||
if pssh_data_list:
|
||||
@@ -549,7 +549,7 @@ class DRMOperations:
|
||||
logger.warning(f"Provider '{provider_name}' not found for GENERIC plugin")
|
||||
return None, None
|
||||
|
||||
manifest_url = provider.get_manifest(channel_id, **kwargs)
|
||||
manifest_url = provider.get_manifest(content_id=channel_id, **kwargs)
|
||||
if manifest_url:
|
||||
pssh_data_list = self._extract_pssh_from_manifest(manifest_url, provider_name)
|
||||
if pssh_data_list:
|
||||
@@ -570,7 +570,7 @@ class DRMOperations:
|
||||
logger.error(f"Cannot extract real PSSH: provider '{provider_name}' not found")
|
||||
return None, pssh_data_list
|
||||
|
||||
manifest_url = provider.get_manifest(channel_id, **kwargs)
|
||||
manifest_url = provider.get_manifest(content_id=channel_id, **kwargs)
|
||||
if manifest_url:
|
||||
real_pssh = self._extract_pssh_from_manifest(manifest_url, provider_name)
|
||||
|
||||
|
||||
@@ -55,4 +55,44 @@ class EventOperations:
|
||||
result[name] = []
|
||||
|
||||
logger.info(f"Retrieved {total} total events")
|
||||
return result
|
||||
return result
|
||||
|
||||
def get_event_manifest(
|
||||
self, provider_name: str, event_id: str, **kwargs
|
||||
) -> Optional[str]:
|
||||
"""
|
||||
Get manifest URL for a specific event.
|
||||
|
||||
Delegates to provider.get_manifest() — the same method used for
|
||||
channels — because manifest resolution is content-type-agnostic.
|
||||
"""
|
||||
provider = self.registry.get_provider(provider_name)
|
||||
if not provider:
|
||||
raise ValueError(f"Provider '{provider_name}' not found or disabled")
|
||||
|
||||
manifest_url = provider.get_manifest(content_id=event_id, **kwargs)
|
||||
if manifest_url:
|
||||
logger.debug(
|
||||
f"Retrieved manifest for event '{event_id}' from '{provider_name}'"
|
||||
)
|
||||
return manifest_url
|
||||
|
||||
def get_event_drm_configs(
|
||||
self, provider_name: str, event_id: str, **kwargs
|
||||
) -> List:
|
||||
"""
|
||||
Get DRM configurations for a specific event.
|
||||
|
||||
Delegates to provider.get_drm() — the same method used for
|
||||
channels — because DRM resolution is content-type-agnostic.
|
||||
"""
|
||||
provider = self.registry.get_provider(provider_name)
|
||||
if not provider:
|
||||
raise ValueError(f"Provider '{provider_name}' not found or disabled")
|
||||
|
||||
drm_configs = provider.get_drm(content_id=event_id, **kwargs)
|
||||
logger.debug(
|
||||
f"Retrieved {len(drm_configs)} DRM config(s) for event '{event_id}' "
|
||||
f"from '{provider_name}'"
|
||||
)
|
||||
return drm_configs
|
||||
@@ -224,6 +224,12 @@ class ProviderManager:
|
||||
def get_all_events(self, start_time=None, end_time=None):
|
||||
return self.event_ops.get_all_events(start_time, end_time)
|
||||
|
||||
def get_event_manifest(self, provider_name: str, event_id: str, **kwargs) -> Optional[str]:
|
||||
return self.event_ops.get_event_manifest(provider_name, event_id, **kwargs)
|
||||
|
||||
def get_event_drm_configs(self, provider_name: str, event_id: str, **kwargs) -> List:
|
||||
return self.event_ops.get_event_drm_configs(provider_name, event_id, **kwargs)
|
||||
|
||||
# ==========================================================================
|
||||
# SUBSCRIPTION OPERATIONS (delegate to SubscriptionOperations)
|
||||
# ==========================================================================
|
||||
|
||||
@@ -233,7 +233,7 @@ class StreamingProvider(ABC):
|
||||
return []
|
||||
|
||||
@abstractmethod
|
||||
def get_drm(self, channel_id: str, **kwargs) -> List[DRMConfig]:
|
||||
def get_drm(self, content_id: str, **kwargs) -> List[DRMConfig]:
|
||||
"""Get all DRM configurations for a channel by ID"""
|
||||
return []
|
||||
|
||||
@@ -280,7 +280,7 @@ class StreamingProvider(ABC):
|
||||
return None
|
||||
|
||||
@abstractmethod
|
||||
def get_manifest(self, channel_id: str, **kwargs) -> Optional[str]:
|
||||
def get_manifest(self, content_id: str, **kwargs) -> Optional[str]:
|
||||
"""Get manifest URL for a specific channel by ID"""
|
||||
return None
|
||||
|
||||
@@ -660,7 +660,7 @@ class StreamingProvider(ABC):
|
||||
|
||||
def get_catchup_manifest(
|
||||
self,
|
||||
channel_id: str,
|
||||
content_id: str,
|
||||
start_time: int,
|
||||
end_time: int,
|
||||
epg_id: Optional[str] = None,
|
||||
@@ -686,17 +686,17 @@ class StreamingProvider(ABC):
|
||||
logger.debug(
|
||||
f"{self.provider_name}: Catchup not supported, falling back to live manifest"
|
||||
)
|
||||
return self.get_manifest(channel_id, **kwargs)
|
||||
return self.get_manifest(content_id, **kwargs)
|
||||
|
||||
logger.warning(
|
||||
f"{self.provider_name}: get_catchup_manifest not implemented, "
|
||||
f"falling back to live manifest"
|
||||
)
|
||||
return self.get_manifest(channel_id, **kwargs)
|
||||
return self.get_manifest(content_id, **kwargs)
|
||||
|
||||
def get_catchup_drm(
|
||||
self,
|
||||
channel_id: str,
|
||||
content_id: str,
|
||||
start_time: int,
|
||||
end_time: int,
|
||||
epg_id: Optional[str] = None,
|
||||
@@ -706,7 +706,7 @@ class StreamingProvider(ABC):
|
||||
Get DRM configurations for catchup content.
|
||||
|
||||
Args:
|
||||
channel_id: Channel identifier
|
||||
content_id: Channel identifier
|
||||
start_time: Start time as Unix timestamp
|
||||
end_time: End time as Unix timestamp
|
||||
epg_id: Optional EPG event ID (might be needed for DRM licensing)
|
||||
@@ -720,24 +720,24 @@ class StreamingProvider(ABC):
|
||||
"""
|
||||
if not self.supports_catchup:
|
||||
logger.debug(f"{self.provider_name}: Catchup not supported, falling back to live DRM")
|
||||
return self.get_drm(channel_id, **kwargs)
|
||||
return self.get_drm(content_id, **kwargs)
|
||||
|
||||
logger.debug(
|
||||
f"{self.provider_name}: get_catchup_drm not implemented, "
|
||||
f"using live DRM configuration"
|
||||
)
|
||||
return self.get_drm(channel_id, **kwargs)
|
||||
return self.get_drm(content_id, **kwargs)
|
||||
|
||||
# ============================================================================
|
||||
# CATCHUP HELPER METHODS
|
||||
# ============================================================================
|
||||
|
||||
def get_catchup_window_for_channel(self, channel_id: str) -> int:
|
||||
def get_catchup_window_for_channel(self, content_id: str) -> int:
|
||||
"""
|
||||
Get catchup window for a specific channel in HOURS.
|
||||
|
||||
Args:
|
||||
channel_id: Channel identifier
|
||||
content_id: Channel identifier
|
||||
|
||||
Returns:
|
||||
int: Catchup window in hours for this channel
|
||||
|
||||
Reference in New Issue
Block a user