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
7 changes: 7 additions & 0 deletions lghorizon/lghorizon_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""LG Horizon API client."""

import logging
import json
from typing import Any, Dict, cast, Callable, Optional

from .lghorizon_device import LGHorizonDevice
Expand Down Expand Up @@ -261,6 +262,8 @@ async def _refresh_channels(self):

async def get_all_recordings(self) -> LGHorizonRecordingList:
"""Retrieve all recordings."""
if not self._customer.has_cloud_recording:
return LGHorizonRecordingList([])
_LOGGER.debug("Retrieving recordings...")
service_url = await self._service_config.get_service_url("recordingService")
lang = await self._customer.get_profile_lang(self._profile_id)
Expand All @@ -275,6 +278,8 @@ async def get_show_recordings(
self, show_id: str, channel_id: str
) -> LGHorizonShowRecordingList: # type: ignore[valid-type]
"""Retrieve all recordings."""
if not self._customer.has_cloud_recording:
return LGHorizonShowRecordingList(None, None, [])
_LOGGER.debug("Retrieving recordings fro show...")
service_url = await self._service_config.get_service_url("recordingService")
lang = await self._customer.get_profile_lang(self._profile_id)
Expand All @@ -288,6 +293,8 @@ async def get_show_recordings(
async def get_recording_quota(self) -> LGHorizonRecordingQuota:
"""Refresh recording quota."""
_LOGGER.debug("Refreshing recording quota...")
if not self._customer.has_cloud_recording:
return LGHorizonRecordingQuota({})
service_url = await self._service_config.get_service_url("recordingService")
quota_json = await self.auth.request(
service_url,
Expand Down
1 change: 1 addition & 0 deletions lghorizon/lghorizon_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(
self._model = None
self._recording_capacity = None
self._device_state_processor = device_state_processor
self._change_callback = None

@property
def device_id(self) -> str:
Expand Down
12 changes: 12 additions & 0 deletions lghorizon/lghorizon_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,18 @@ def city_id(self) -> int:
"""Return the city id."""
return self._json_payload["cityId"]

@property
def recording_retention_period(self) -> Optional[int]:
"""Return the city id."""
return self._json_payload.get("recordingRetentionPeriod", None)

@property
def has_cloud_recording(self) -> bool:
"""Return the city id."""
return (
not self.recording_retention_period or self.recording_retention_period <= 0
)

@property
def assigned_devices(self) -> list[str]:
"""Return the assigned set-top boxes."""
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async def main():

async with aiohttp.ClientSession() as session:
auth = LGHorizonAuth(session, country, username=username, password=password)
api = LGHorizonApi(auth)
api = LGHorizonApi(auth, profile_id=None)

# Start the input reader task
input_task = asyncio.create_task(read_input_and_signal_shutdown())
Expand Down