Add m3u playlists

This commit is contained in:
Nirvana
2026-02-13 17:07:25 +01:00
parent 0b6a9bc2c0
commit 48b6f5f210
3 changed files with 30 additions and 37 deletions
@@ -2,7 +2,7 @@
from abc import ABC, abstractmethod
from typing import Optional
from ..models.drm_models import DRMConfig, DRMSystem, PSSHData
from ..models.drm import DRMConfig, DRMSystem, PSSHData
class DRMPlugin(ABC):
@@ -7,7 +7,7 @@ Handles plugin registration, discovery, and processing of DRM configs with PSSH
import traceback
from typing import Dict, List, Optional
from ..models.drm_models import DRMConfig, DRMSystem, PSSHData
from ..models.drm import DRMConfig, DRMSystem, PSSHData
from ..utils.logger import logger
from .drm_plugin import DRMPlugin
@@ -311,24 +311,15 @@ class DRMPluginManager:
) -> List[DRMConfig]:
"""
PHASE 2: Process through system-specific plugins (EXCLUDE GENERIC).
System-specific plugins TRANSFORM existing configs from the provider.
GENERIC plugins are explicitly excluded from this phase.
Args:
drm_configs: DRM configs from the provider
pssh_data_list: PSSH data extracted from manifest
**kwargs: Additional context
Returns:
List of transformed DRM configs
"""
if not drm_configs:
logger.debug("Phase 2: No DRM configs to process")
return []
# Get system-specific plugins only (exclude GENERIC)
system_plugins = {
# ✅ Add explicit type annotation
from typing import Any # or import your DRMPlugin type
system_plugins: dict[DRMSystem, Any] = {
sys: plugin for sys, plugin in self.plugins.items()
if sys != DRMSystem.GENERIC
}
@@ -343,12 +334,14 @@ class DRMPluginManager:
)
# Create a mapping of DRM system to PSSH data for quick lookup
pssh_by_system = {}
# ✅ Add explicit type annotation
pssh_by_system: dict[DRMSystem, PSSHData] = {}
for pssh_data in pssh_data_list:
if pssh_data.drm_system:
pssh_by_system[pssh_data.drm_system] = pssh_data
drm_sys = pssh_data.drm_system
if drm_sys is not None:
pssh_by_system[drm_sys] = pssh_data
logger.debug(
f"Phase 2: Mapped PSSH data for DRM system: {pssh_data.drm_system}"
f"Phase 2: Mapped PSSH data for DRM system: {drm_sys}"
)
processed_configs = []
@@ -45,7 +45,7 @@ class DRMConfig:
if self.license:
self.license.validate()
def to_dict(self) -> dict:
def to_dict(self) -> dict[str, dict]:
"""
Convert to dictionary format expected by players.
@@ -58,7 +58,7 @@ class DRMConfig:
}
}
"""
result = {
result: dict[str, dict] = {
self.system.value: {
"priority": self.priority
}
@@ -73,10 +73,10 @@ class DRMConfig:
@classmethod
def create_widevine(
cls,
server_url: str,
priority: int = 1,
**license_kwargs
cls,
server_url: str,
priority: int = 1,
**license_kwargs
) -> "DRMConfig":
"""
Helper to create Widevine DRM configuration.
@@ -94,10 +94,10 @@ class DRMConfig:
@classmethod
def create_playready(
cls,
server_url: str,
priority: int = 1,
**license_kwargs
cls,
server_url: str,
priority: int = 1,
**license_kwargs
) -> "DRMConfig":
"""
Helper to create PlayReady DRM configuration.
@@ -115,10 +115,10 @@ class DRMConfig:
@classmethod
def create_clearkey(
cls,
keyids: dict[str, str],
priority: int = 0,
**license_kwargs
cls,
keyids: dict[str, str],
priority: int = 0,
**license_kwargs
) -> "DRMConfig":
"""
Helper to create ClearKey DRM configuration.
@@ -136,11 +136,11 @@ class DRMConfig:
@classmethod
def create_fairplay(
cls,
server_url: str,
server_certificate: str,
priority: int = 1,
**license_kwargs
cls,
server_url: str,
server_certificate: str,
priority: int = 1,
**license_kwargs
) -> "DRMConfig":
"""
Helper to create FairPlay DRM configuration.