Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lghorizon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
LGHorizonUIState,
LGHorizonProfileOptions,
LGHorizonServicesConfig,
LGHorizonMediaType,
)
from .exceptions import (
LGHorizonApiError,
Expand Down Expand Up @@ -70,5 +71,6 @@
"LGHorizonServicesConfig",
"LGHorizonRecording",
"LGHorizonShowRecordingList",
"LGHorizonMediaType",
"COUNTRY_SETTINGS",
]
19 changes: 16 additions & 3 deletions lghorizon/lghorizon_device_state_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
LGHorizonNDVRSource,
LGHorizonReviewBufferSource,
LGHorizonRecordingSource,
LGHorizonMediaType,
)
from .lghorizon_models import LGHorizonAuth
from .lghorizon_models import LGHorizonReplayEvent, LGHorizonVOD, LGHorizonVODType
Expand Down Expand Up @@ -124,6 +125,7 @@ async def _process_apps_state(
device_state.show_title = apps_state.app_name
device_state.image = apps_state.logo_path
device_state.ui_state_type = LGHorizonUIStateType.APPS
device_state.media_type = LGHorizonMediaType.APP

async def _process_linear_state(
self,
Expand All @@ -145,8 +147,10 @@ async def _process_linear_state(
service_path,
)
replay_event = LGHorizonReplayEvent(event_json)
device_state.id = replay_event.event_id
channel = self._channels[replay_event.channel_id]

device_state.media_type = LGHorizonMediaType.CHANNEL
device_state.id = replay_event.event_id
device_state.source_type = source.source_type
device_state.channel_id = channel.id
device_state.channel_name = channel.title
Expand Down Expand Up @@ -189,8 +193,10 @@ async def _process_reviewbuffer_state(
service_path,
)
replay_event = LGHorizonReplayEvent(event_json)
device_state.id = replay_event.event_id
channel = self._channels[replay_event.channel_id]

device_state.media_type = LGHorizonMediaType.CHANNEL
device_state.id = replay_event.event_id
device_state.source_type = source.source_type
device_state.channel_id = channel.id
device_state.channel_name = channel.title
Expand All @@ -205,6 +211,7 @@ async def _process_reviewbuffer_state(
device_state.start_time = replay_event.start_time
device_state.end_time = replay_event.end_time
device_state.duration = replay_event.end_time - replay_event.start_time

# Add random number to url to force refresh
join_param = "?"
if join_param in channel.stream_image:
Expand Down Expand Up @@ -234,9 +241,11 @@ async def _process_replay_state(
service_path,
)
replay_event = LGHorizonReplayEvent(event_json)
device_state.id = replay_event.event_id
# Iets met buffer doen
channel = self._channels[replay_event.channel_id]

device_state.media_type = LGHorizonMediaType.CHANNEL
device_state.id = replay_event.event_id
device_state.source_type = source.source_type
device_state.channel_id = channel.id
device_state.episode_title = replay_event.episode_name
Expand Down Expand Up @@ -279,8 +288,10 @@ async def _process_vod_state(
device_state.episode_title = vod.title
device_state.season_number = vod.season
device_state.episode_number = vod.episode
device_state.media_type = LGHorizonMediaType.EPISODE
else:
device_state.show_title = vod.title
device_state.media_type = LGHorizonMediaType.MOVIE

device_state.duration = vod.duration
device_state.last_position_update = int(time.time())
Expand Down Expand Up @@ -335,6 +346,8 @@ async def _process_ndvr_state(
else:
device_state.show_title = recording.show_title

device_state.media_type = LGHorizonMediaType.CHANNEL

device_state.image = await self._get_intent_image_url(recording.id)

async def _get_intent_image_url(self, intent_id: str) -> Optional[str]:
Expand Down
24 changes: 24 additions & 0 deletions lghorizon/lghorizon_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ class LGHorizonUIStateType(Enum):
UNKNOWN = "unknown"


class LGHorizonMediaType(Enum):
"""Enumeration of LG Horizon Media types"""

UNKNOWN = "unknown"
CHANNEL = "channel"
APP = "app"
MOVIE = "movie"
EPISODE = "episode"
TVSHOW = "tvshow"


class LGHorizonMessage(ABC):
"""Abstract base class for LG Horizon messages."""

Expand Down Expand Up @@ -869,6 +880,7 @@ class LGHorizonDeviceState:
_speed: Optional[int]
_start_time: Optional[int]
_end_time: Optional[int]
_media_type: LGHorizonMediaType

def __init__(self) -> None:
"""Initialize the playing info."""
Expand All @@ -890,6 +902,7 @@ def __init__(self) -> None:
self._id = None
self._start_time = None
self._end_time = None
self._media_type = LGHorizonMediaType.UNKNOWN

@property
def state(self) -> LGHorizonRunningState:
Expand Down Expand Up @@ -1031,6 +1044,16 @@ def ui_state_type(self, value: LGHorizonUIStateType) -> None:
"""Set the source type."""
self._ui_state_type = value

@property
def media_type(self) -> LGHorizonMediaType:
"""Return the source type."""
return self._media_type

@media_type.setter
def media_type(self, value: LGHorizonMediaType) -> None:
"""Set the source type."""
self._media_type = value

@property
def paused(self) -> bool:
"""Return if the media is paused."""
Expand Down Expand Up @@ -1099,6 +1122,7 @@ async def reset(self) -> None:
self.id = None
self.start_time = None
self.end_time = None
self.media_type = LGHorizonMediaType.UNKNOWN
await self.reset_progress()


Expand Down