mirror of
https://github.com/nirvana-7777/script.service.ultimate.git
synced 2026-09-25 02:22:44 +02:00
magentaeu: change epg_manager
This commit is contained in:
@@ -740,6 +740,19 @@ class EPGProgramDetails:
|
||||
season_number: Optional[int] = None
|
||||
episode_number: Optional[int] = None
|
||||
|
||||
country_of_origin: Optional[List[str]] = None
|
||||
"""
|
||||
Country/countries of origin as returned by the provider's detail
|
||||
endpoint (e.g. ["Österreich"], ["USA"]). Not part of EPGContent —
|
||||
EPGEntry has no matching field, same treatment as presenter/composers.
|
||||
"""
|
||||
|
||||
trailer: Optional[List[str]] = None
|
||||
"""
|
||||
Trailer URL(s), when the provider's detail endpoint returns them.
|
||||
Not part of EPGContent — no matching EPGEntry field.
|
||||
"""
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Serialise to a plain dict, omitting None values."""
|
||||
result: dict = {"program_id": self.program_id}
|
||||
@@ -750,7 +763,8 @@ class EPGProgramDetails:
|
||||
"presenter", "composers", "contributors",
|
||||
"backdrop", "poster", "imdb_number", "provider_vod_id",
|
||||
"genres", "parental_rating",
|
||||
"release_date", "duration"
|
||||
"release_date", "duration",
|
||||
"country_of_origin", "trailer",
|
||||
)
|
||||
|
||||
for field in simple_fields:
|
||||
|
||||
@@ -34,7 +34,7 @@ from typing import Any, Dict, List, Optional, Set, Tuple
|
||||
|
||||
from .utils import build_guest_headers
|
||||
from ...base.utils.logger import logger
|
||||
from ...base.models.epg_models import EPGEntry, EPGProgramDetails
|
||||
from ...base.models.epg_models import EPGEntry, EPGProgramDetails, EPGFlags
|
||||
from .constants import (
|
||||
DEFAULT_REQUEST_TIMEOUT,
|
||||
SUPPORTED_COUNTRIES,
|
||||
@@ -360,6 +360,9 @@ class MagentaEUEpgManager:
|
||||
presenter=credit_map.get("presenter"),
|
||||
composers=credit_map.get("composers"),
|
||||
contributors=credit_map.get("contributors"),
|
||||
duration=raw.get("runtime_seconds"),
|
||||
country_of_origin=raw.get("country_of_origin") or None,
|
||||
trailer=raw.get("trailer") or None,
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
@@ -714,6 +717,17 @@ class MagentaEUEpgManager:
|
||||
item.get("episode_number"), max_valid=None
|
||||
)
|
||||
|
||||
# Flags — only derivable when details were fetched
|
||||
flags = None
|
||||
if details:
|
||||
flag_bits = []
|
||||
if details.get("is_live"):
|
||||
flag_bits.append(EPGFlags.IS_LIVE)
|
||||
if details.get("show_type") == "TVShow":
|
||||
flag_bits.append(EPGFlags.IS_SERIES)
|
||||
if flag_bits:
|
||||
flags = EPGFlags.combine(*flag_bits)
|
||||
|
||||
# Build EPGEntry with both IDs
|
||||
return EPGEntry(
|
||||
# Required fields
|
||||
@@ -760,7 +774,7 @@ class MagentaEUEpgManager:
|
||||
first_aired=None, # Not available from bifrost API
|
||||
imdb_number=None, # Not available from bifrost API
|
||||
series_link=None, # Not available from bifrost API
|
||||
flags=None, # Could be set based on programme properties if needed
|
||||
flags=flags, # Could be set based on programme properties if needed
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user