From 701d9265b499011596447feb1ca174530a484d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20V=C3=B6lker?= Date: Tue, 17 Jan 2023 22:26:40 +0100 Subject: [PATCH 1/2] Added new function to read recordings/list --- haphilipsjs/__init__.py | 14 ++++++++++++++ haphilipsjs/typing.py | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/haphilipsjs/__init__.py b/haphilipsjs/__init__.py index b2b37a4..96a38fa 100644 --- a/haphilipsjs/__init__.py +++ b/haphilipsjs/__init__.py @@ -26,6 +26,7 @@ ChannelsType, ContextType, FavoriteListType, + RecordingsListed, MenuItemsSettingsCurrent, MenuItemsSettingsCurrentPost, MenuItemsSettingsCurrentValueValue, @@ -238,6 +239,7 @@ def __init__( self.ambilight_current_configuration: Optional[ AmbilightCurrentConfiguration ] = None + self.recordings_list: Dict[str, RecordingsListed] = {} self.huelamp_power: Optional[str] = None self.powerstate = None if auth_shared_key: @@ -1225,6 +1227,18 @@ async def setAmbilightCurrentConfiguration( return True + async def getRecordingsList(self): + if self.json_feature_supported("recordings", "List"): + r = cast( + Optional[RecordingsListed], + await self.getReq("recordings/list"), + ) + if r: + self.recordings_list = r["recordings"] + else: + self.recordings_list = {} + return r + async def openURL(self, url: str): if self.json_feature_supported("activities", "browser"): r = await self.postReq("activities/browser", {"url": url}) diff --git a/haphilipsjs/typing.py b/haphilipsjs/typing.py index 4ddc40a..4026e33 100644 --- a/haphilipsjs/typing.py +++ b/haphilipsjs/typing.py @@ -220,6 +220,23 @@ class AmbilightCurrentConfiguration(TypedDict, total=False): audioSettings: AmbilightAudioSettingsType colorSettings: AmbilightColorSettingsType +class RecordingsListedType(TypedDict, total=False): + RecordingId: int + RecordingType: str #RECORDING_ONGOING, RECORDING_SCHEDULED, RECORDING_NEW, RECORDING_PARTIALLY_VIEWED, RECORDING_VIEWED + RecName: str + EventInfo: str + EventId: int + StartTime: int + ActualStartTime: int + Duration: int + IsRadio: bool + IsPartial: bool + RecError: str #REC_ERROR_NONE, ... + +class RecordingsListed(TypedDict): + version: str + recordingsList: List[RecordingsListedType] + class MenuItemsSettingsNodeDataSliderData(TypedDict): min: int max: int From 71e763606fdd26936879ac571ca3453034940f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20V=C3=B6lker?= Date: Thu, 19 Jan 2023 17:36:29 +0100 Subject: [PATCH 2/2] Corrected types and completed the dict --- haphilipsjs/__init__.py | 8 ++++---- haphilipsjs/typing.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/haphilipsjs/__init__.py b/haphilipsjs/__init__.py index 96a38fa..ea0a742 100644 --- a/haphilipsjs/__init__.py +++ b/haphilipsjs/__init__.py @@ -239,7 +239,7 @@ def __init__( self.ambilight_current_configuration: Optional[ AmbilightCurrentConfiguration ] = None - self.recordings_list: Dict[str, RecordingsListed] = {} + self.recordings_list: Optional[RecordingsListed] = None self.huelamp_power: Optional[str] = None self.powerstate = None if auth_shared_key: @@ -1227,16 +1227,16 @@ async def setAmbilightCurrentConfiguration( return True - async def getRecordingsList(self): + async def getRecordings(self): if self.json_feature_supported("recordings", "List"): r = cast( Optional[RecordingsListed], await self.getReq("recordings/list"), ) if r: - self.recordings_list = r["recordings"] + self.recordings_list = r else: - self.recordings_list = {} + self.recordings_list = None return r async def openURL(self, url: str): diff --git a/haphilipsjs/typing.py b/haphilipsjs/typing.py index 4026e33..5fe173f 100644 --- a/haphilipsjs/typing.py +++ b/haphilipsjs/typing.py @@ -222,20 +222,47 @@ class AmbilightCurrentConfiguration(TypedDict, total=False): class RecordingsListedType(TypedDict, total=False): RecordingId: int + ServerRecordingId: int RecordingType: str #RECORDING_ONGOING, RECORDING_SCHEDULED, RECORDING_NEW, RECORDING_PARTIALLY_VIEWED, RECORDING_VIEWED RecName: str - EventInfo: str EventId: int + EventInfo: str + EventExtendedInfo: str + EventGenre: str + EventRating: int + SeriesID: str StartTime: int ActualStartTime: int Duration: int + MarginStart: int + MarginEnd: int + AutoMarginStart: int + AutoMarginEnd: int + RetentionInfo: int + SeasonNo: int + EpisodeNo: int + EpisodeCount: int + ProgramNumber: int + ProgramDuration: int + ResumeInfo: int + LastPinChangedTime: int + HasCicamPin: bool + hasDot: bool + HasLicenseFile: bool IsRadio: bool IsPartial: bool + IsIpEpgRec: bool + isFTARecording: bool + EITVersion: int + EITSource: str #EIT_SOURCE_PF, ... RecError: str #REC_ERROR_NONE, ... + Version: int + Size: int + ccid: int class RecordingsListed(TypedDict): version: str - recordingsList: List[RecordingsListedType] + recordings: List[RecordingsListedType] class MenuItemsSettingsNodeDataSliderData(TypedDict): min: int