lghorizon 0.8.6__tar.gz → 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lghorizon-0.8.6 → lghorizon-0.9.0}/.github/workflows/build-on-pr.yml +1 -1
- {lghorizon-0.8.6 → lghorizon-0.9.0}/.github/workflows/publish-to-pypi.yml +1 -1
- {lghorizon-0.8.6 → lghorizon-0.9.0}/.gitignore +1 -0
- lghorizon-0.9.0/.vscode/launch.json +15 -0
- lghorizon-0.9.0/PKG-INFO +191 -0
- lghorizon-0.9.0/README.md +153 -0
- lghorizon-0.9.0/lghorizon/__init__.py +71 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lghorizon/const.py +11 -4
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lghorizon/exceptions.py +3 -3
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lghorizon/helpers.py +1 -1
- lghorizon-0.9.0/lghorizon/lghorizon_api.py +300 -0
- lghorizon-0.9.0/lghorizon/lghorizon_device.py +409 -0
- lghorizon-0.9.0/lghorizon/lghorizon_device_state_processor.py +365 -0
- lghorizon-0.9.0/lghorizon/lghorizon_message_factory.py +38 -0
- lghorizon-0.9.0/lghorizon/lghorizon_models.py +1512 -0
- lghorizon-0.9.0/lghorizon/lghorizon_mqtt_client.py +335 -0
- lghorizon-0.9.0/lghorizon/lghorizon_recording_factory.py +55 -0
- lghorizon-0.9.0/lghorizon.egg-info/PKG-INFO +191 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lghorizon.egg-info/SOURCES.txt +8 -2
- lghorizon-0.9.0/main.py +85 -0
- lghorizon-0.9.0/renovate.json +7 -0
- lghorizon-0.8.6/PKG-INFO +0 -41
- lghorizon-0.8.6/README.md +0 -3
- lghorizon-0.8.6/lghorizon/__init__.py +0 -41
- lghorizon-0.8.6/lghorizon/lghorizon_api.py +0 -539
- lghorizon-0.8.6/lghorizon/models.py +0 -762
- lghorizon-0.8.6/lghorizon.egg-info/PKG-INFO +0 -41
- lghorizon-0.8.6/renovate.json +0 -7
- lghorizon-0.8.6/test.py +0 -84
- {lghorizon-0.8.6 → lghorizon-0.9.0}/.coverage +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/.flake8 +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/LICENSE +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/instructions.txt +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lghorizon/py.typed +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lghorizon.egg-info/dependency_links.txt +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lghorizon.egg-info/not-zip-safe +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lghorizon.egg-info/requires.txt +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lghorizon.egg-info/top_level.txt +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/lib64 +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/pyvenv.cfg +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/secrets_stub.json +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/setup.cfg +0 -0
- {lghorizon-0.8.6 → lghorizon-0.9.0}/setup.py +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Python Debugger: Debug LGHorizon",
|
|
9
|
+
"type": "debugpy",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"program": "main.py",
|
|
12
|
+
"console": "integratedTerminal"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
lghorizon-0.9.0/PKG-INFO
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lghorizon
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Python client for Liberty Global Horizon settop boxes
|
|
5
|
+
Home-page: https://github.com/sholofly/LGHorizon-python
|
|
6
|
+
Author: Rudolf Offereins
|
|
7
|
+
Author-email: r.offereins@gmail.com
|
|
8
|
+
License: MIT license
|
|
9
|
+
Keywords: LG,Horizon,API,Settop box
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: paho-mqtt
|
|
24
|
+
Requires-Dist: requests>=2.22.0
|
|
25
|
+
Requires-Dist: backoff>=1.9.0
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: description-content-type
|
|
31
|
+
Dynamic: home-page
|
|
32
|
+
Dynamic: keywords
|
|
33
|
+
Dynamic: license
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
Dynamic: requires-dist
|
|
36
|
+
Dynamic: requires-python
|
|
37
|
+
Dynamic: summary
|
|
38
|
+
|
|
39
|
+
# LG Horizon Api
|
|
40
|
+
|
|
41
|
+
# LG Horizon API Python Library
|
|
42
|
+
|
|
43
|
+
A Python library to interact with and control LG Horizon set-top boxes. This library provides functionalities for authentication, real-time device status monitoring via MQTT, and various control commands for your Horizon devices.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- **Authentication**: Supports authentication using username/password or a refresh token. The library automatically handles access token refreshing.
|
|
48
|
+
- **Device Management**: Discover and manage multiple LG Horizon set-top boxes associated with your account.
|
|
49
|
+
- **Real-time Status**: Monitor device status (online/running/standby) and current playback information (channel, show, VOD, recording, app) through MQTT.
|
|
50
|
+
- **Channel Information**: Retrieve a list of available channels and profile-specific favorite channels.
|
|
51
|
+
- **Recording Management**:
|
|
52
|
+
- Get a list of all recordings.
|
|
53
|
+
- Retrieve recordings for specific shows.
|
|
54
|
+
- Check recording quota and usage.
|
|
55
|
+
- **Device Control**: Send various commands to your set-top box:
|
|
56
|
+
- Power on/off.
|
|
57
|
+
- Play, pause, stop, rewind, fast forward.
|
|
58
|
+
- Change channels (up/down, direct channel selection).
|
|
59
|
+
- Record current program.
|
|
60
|
+
- Set player position for VOD/recordings.
|
|
61
|
+
- Display custom messages on the TV screen.
|
|
62
|
+
- Send emulated remote control key presses.
|
|
63
|
+
- **Robustness**: Includes automatic MQTT reconnection with exponential backoff and token refresh logic to maintain a stable connection.
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install lghorizon-python # (Replace with actual package name if different)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
Here's a basic example of how to use the library to connect to your LG Horizon devices and monitor their state:
|
|
74
|
+
|
|
75
|
+
First, create a `secrets.json` file in the root of your project with your LG Horizon credentials:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"username": "your_username",
|
|
80
|
+
"password": "your_password",
|
|
81
|
+
"country": "nl" // e.g., "nl" for Netherlands, "be" for Belgium
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Then, you can use the library as follows:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
import asyncio
|
|
89
|
+
import json
|
|
90
|
+
import logging
|
|
91
|
+
import aiohttp
|
|
92
|
+
|
|
93
|
+
from lghorizon.lghorizon_api import LGHorizonApi
|
|
94
|
+
from lghorizon.lghorizon_models import LGHorizonAuth
|
|
95
|
+
|
|
96
|
+
_LOGGER = logging.getLogger(__name__)
|
|
97
|
+
|
|
98
|
+
async def main():
|
|
99
|
+
logging.basicConfig(level=logging.INFO) # Set to DEBUG for more verbose output
|
|
100
|
+
|
|
101
|
+
with open("secrets.json", encoding="utf-8") as f:
|
|
102
|
+
secrets = json.load(f)
|
|
103
|
+
username = secrets.get("username")
|
|
104
|
+
password = secrets.get("password")
|
|
105
|
+
country = secrets.get("country", "nl")
|
|
106
|
+
|
|
107
|
+
async with aiohttp.ClientSession() as session:
|
|
108
|
+
auth = LGHorizonAuth(session, country, username=username, password=password)
|
|
109
|
+
api = LGHorizonApi(auth)
|
|
110
|
+
|
|
111
|
+
async def device_state_changed_callback(device_id: str):
|
|
112
|
+
device = devices[device_id]
|
|
113
|
+
_LOGGER.info(
|
|
114
|
+
f"Device {device.device_friendly_name} ({device.device_id}) state changed:\n"
|
|
115
|
+
f" State: {device.device_state.state.value}\n"
|
|
116
|
+
f" UI State: {device.device_state.ui_state_type.value}\n"
|
|
117
|
+
f" Source Type: {device.device_state.source_type.value}\n"
|
|
118
|
+
f" Channel: {device.device_state.channel_name or 'N/A'} ({device.device_state.channel_id or 'N/A'})\n"
|
|
119
|
+
f" Show: {device.device_state.show_title or 'N/A'}\n"
|
|
120
|
+
f" Episode: {device.device_state.episode_title or 'N/A'}\n"
|
|
121
|
+
f" Position: {device.device_state.position or 'N/A'} / {device.device_state.duration or 'N/A'}\n"
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
_LOGGER.info("Initializing LG Horizon API...")
|
|
126
|
+
await api.initialize()
|
|
127
|
+
devices = await api.get_devices()
|
|
128
|
+
|
|
129
|
+
for device in devices.values():
|
|
130
|
+
_LOGGER.info(f"Registering callback for device: {device.device_friendly_name}")
|
|
131
|
+
await device.set_callback(device_state_changed_callback)
|
|
132
|
+
|
|
133
|
+
_LOGGER.info("API initialized. Monitoring device states. Press Ctrl+C to exit.")
|
|
134
|
+
# Keep the script running to receive MQTT updates
|
|
135
|
+
while True:
|
|
136
|
+
await asyncio.sleep(3600) # Sleep for a long time, MQTT callbacks will still fire
|
|
137
|
+
|
|
138
|
+
except Exception as e:
|
|
139
|
+
_LOGGER.error(f"An error occurred: {e}", exc_info=True)
|
|
140
|
+
finally:
|
|
141
|
+
_LOGGER.info("Disconnecting from LG Horizon API.")
|
|
142
|
+
await api.disconnect()
|
|
143
|
+
_LOGGER.info("Disconnected.")
|
|
144
|
+
|
|
145
|
+
if __name__ == "__main__":
|
|
146
|
+
asyncio.run(main())
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Authentication
|
|
150
|
+
|
|
151
|
+
The `LGHorizonAuth` class handles authentication. You can initialize it with a username and password, or directly with a refresh token if you have one. The library automatically refreshes access tokens as needed.
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
# Using username and password
|
|
155
|
+
auth = LGHorizonAuth(session, "nl", username="your_username", password="your_password")
|
|
156
|
+
|
|
157
|
+
# Using a refresh token (e.g., if you've saved it from a previous session)
|
|
158
|
+
# auth = LGHorizonAuth(session, "nl", refresh_token="your_refresh_token")
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
You can also set a callback to receive the updated refresh token when it's refreshed, allowing you to persist it for future sessions:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
def token_updated_callback(new_refresh_token: str):
|
|
165
|
+
print(f"New refresh token received: {new_refresh_token}")
|
|
166
|
+
# Here you would typically save this new_refresh_token
|
|
167
|
+
# to your secrets.json or other persistent storage.
|
|
168
|
+
|
|
169
|
+
# After initializing LGHorizonApi:
|
|
170
|
+
# api.set_token_refresh_callback(token_updated_callback)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Error Handling
|
|
174
|
+
|
|
175
|
+
The library defines custom exceptions for common error scenarios:
|
|
176
|
+
|
|
177
|
+
- `LGHorizonApiError`: Base exception for all API-related errors.
|
|
178
|
+
- `LGHorizonApiConnectionError`: Raised for network or connection issues.
|
|
179
|
+
- `LGHorizonApiUnauthorizedError`: Raised when authentication fails (e.g., invalid credentials).
|
|
180
|
+
- `LGHorizonApiLockedError`: A specific type of `LGHorizonApiUnauthorizedError` indicating a locked account.
|
|
181
|
+
|
|
182
|
+
These exceptions allow for more granular error handling in your application.
|
|
183
|
+
|
|
184
|
+
## Development
|
|
185
|
+
|
|
186
|
+
To run the example script (`main.py`) from the repository:
|
|
187
|
+
|
|
188
|
+
1. Clone this repository.
|
|
189
|
+
2. Install dependencies: `pip install -r requirements.txt` (ensure `requirements.txt` is up-to-date).
|
|
190
|
+
3. Create a `secrets.json` file as described in the Usage section.
|
|
191
|
+
4. Run `python main.py`.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# LG Horizon Api
|
|
2
|
+
|
|
3
|
+
# LG Horizon API Python Library
|
|
4
|
+
|
|
5
|
+
A Python library to interact with and control LG Horizon set-top boxes. This library provides functionalities for authentication, real-time device status monitoring via MQTT, and various control commands for your Horizon devices.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Authentication**: Supports authentication using username/password or a refresh token. The library automatically handles access token refreshing.
|
|
10
|
+
- **Device Management**: Discover and manage multiple LG Horizon set-top boxes associated with your account.
|
|
11
|
+
- **Real-time Status**: Monitor device status (online/running/standby) and current playback information (channel, show, VOD, recording, app) through MQTT.
|
|
12
|
+
- **Channel Information**: Retrieve a list of available channels and profile-specific favorite channels.
|
|
13
|
+
- **Recording Management**:
|
|
14
|
+
- Get a list of all recordings.
|
|
15
|
+
- Retrieve recordings for specific shows.
|
|
16
|
+
- Check recording quota and usage.
|
|
17
|
+
- **Device Control**: Send various commands to your set-top box:
|
|
18
|
+
- Power on/off.
|
|
19
|
+
- Play, pause, stop, rewind, fast forward.
|
|
20
|
+
- Change channels (up/down, direct channel selection).
|
|
21
|
+
- Record current program.
|
|
22
|
+
- Set player position for VOD/recordings.
|
|
23
|
+
- Display custom messages on the TV screen.
|
|
24
|
+
- Send emulated remote control key presses.
|
|
25
|
+
- **Robustness**: Includes automatic MQTT reconnection with exponential backoff and token refresh logic to maintain a stable connection.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install lghorizon-python # (Replace with actual package name if different)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
Here's a basic example of how to use the library to connect to your LG Horizon devices and monitor their state:
|
|
36
|
+
|
|
37
|
+
First, create a `secrets.json` file in the root of your project with your LG Horizon credentials:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"username": "your_username",
|
|
42
|
+
"password": "your_password",
|
|
43
|
+
"country": "nl" // e.g., "nl" for Netherlands, "be" for Belgium
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then, you can use the library as follows:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import asyncio
|
|
51
|
+
import json
|
|
52
|
+
import logging
|
|
53
|
+
import aiohttp
|
|
54
|
+
|
|
55
|
+
from lghorizon.lghorizon_api import LGHorizonApi
|
|
56
|
+
from lghorizon.lghorizon_models import LGHorizonAuth
|
|
57
|
+
|
|
58
|
+
_LOGGER = logging.getLogger(__name__)
|
|
59
|
+
|
|
60
|
+
async def main():
|
|
61
|
+
logging.basicConfig(level=logging.INFO) # Set to DEBUG for more verbose output
|
|
62
|
+
|
|
63
|
+
with open("secrets.json", encoding="utf-8") as f:
|
|
64
|
+
secrets = json.load(f)
|
|
65
|
+
username = secrets.get("username")
|
|
66
|
+
password = secrets.get("password")
|
|
67
|
+
country = secrets.get("country", "nl")
|
|
68
|
+
|
|
69
|
+
async with aiohttp.ClientSession() as session:
|
|
70
|
+
auth = LGHorizonAuth(session, country, username=username, password=password)
|
|
71
|
+
api = LGHorizonApi(auth)
|
|
72
|
+
|
|
73
|
+
async def device_state_changed_callback(device_id: str):
|
|
74
|
+
device = devices[device_id]
|
|
75
|
+
_LOGGER.info(
|
|
76
|
+
f"Device {device.device_friendly_name} ({device.device_id}) state changed:\n"
|
|
77
|
+
f" State: {device.device_state.state.value}\n"
|
|
78
|
+
f" UI State: {device.device_state.ui_state_type.value}\n"
|
|
79
|
+
f" Source Type: {device.device_state.source_type.value}\n"
|
|
80
|
+
f" Channel: {device.device_state.channel_name or 'N/A'} ({device.device_state.channel_id or 'N/A'})\n"
|
|
81
|
+
f" Show: {device.device_state.show_title or 'N/A'}\n"
|
|
82
|
+
f" Episode: {device.device_state.episode_title or 'N/A'}\n"
|
|
83
|
+
f" Position: {device.device_state.position or 'N/A'} / {device.device_state.duration or 'N/A'}\n"
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
_LOGGER.info("Initializing LG Horizon API...")
|
|
88
|
+
await api.initialize()
|
|
89
|
+
devices = await api.get_devices()
|
|
90
|
+
|
|
91
|
+
for device in devices.values():
|
|
92
|
+
_LOGGER.info(f"Registering callback for device: {device.device_friendly_name}")
|
|
93
|
+
await device.set_callback(device_state_changed_callback)
|
|
94
|
+
|
|
95
|
+
_LOGGER.info("API initialized. Monitoring device states. Press Ctrl+C to exit.")
|
|
96
|
+
# Keep the script running to receive MQTT updates
|
|
97
|
+
while True:
|
|
98
|
+
await asyncio.sleep(3600) # Sleep for a long time, MQTT callbacks will still fire
|
|
99
|
+
|
|
100
|
+
except Exception as e:
|
|
101
|
+
_LOGGER.error(f"An error occurred: {e}", exc_info=True)
|
|
102
|
+
finally:
|
|
103
|
+
_LOGGER.info("Disconnecting from LG Horizon API.")
|
|
104
|
+
await api.disconnect()
|
|
105
|
+
_LOGGER.info("Disconnected.")
|
|
106
|
+
|
|
107
|
+
if __name__ == "__main__":
|
|
108
|
+
asyncio.run(main())
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Authentication
|
|
112
|
+
|
|
113
|
+
The `LGHorizonAuth` class handles authentication. You can initialize it with a username and password, or directly with a refresh token if you have one. The library automatically refreshes access tokens as needed.
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
# Using username and password
|
|
117
|
+
auth = LGHorizonAuth(session, "nl", username="your_username", password="your_password")
|
|
118
|
+
|
|
119
|
+
# Using a refresh token (e.g., if you've saved it from a previous session)
|
|
120
|
+
# auth = LGHorizonAuth(session, "nl", refresh_token="your_refresh_token")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
You can also set a callback to receive the updated refresh token when it's refreshed, allowing you to persist it for future sessions:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
def token_updated_callback(new_refresh_token: str):
|
|
127
|
+
print(f"New refresh token received: {new_refresh_token}")
|
|
128
|
+
# Here you would typically save this new_refresh_token
|
|
129
|
+
# to your secrets.json or other persistent storage.
|
|
130
|
+
|
|
131
|
+
# After initializing LGHorizonApi:
|
|
132
|
+
# api.set_token_refresh_callback(token_updated_callback)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Error Handling
|
|
136
|
+
|
|
137
|
+
The library defines custom exceptions for common error scenarios:
|
|
138
|
+
|
|
139
|
+
- `LGHorizonApiError`: Base exception for all API-related errors.
|
|
140
|
+
- `LGHorizonApiConnectionError`: Raised for network or connection issues.
|
|
141
|
+
- `LGHorizonApiUnauthorizedError`: Raised when authentication fails (e.g., invalid credentials).
|
|
142
|
+
- `LGHorizonApiLockedError`: A specific type of `LGHorizonApiUnauthorizedError` indicating a locked account.
|
|
143
|
+
|
|
144
|
+
These exceptions allow for more granular error handling in your application.
|
|
145
|
+
|
|
146
|
+
## Development
|
|
147
|
+
|
|
148
|
+
To run the example script (`main.py`) from the repository:
|
|
149
|
+
|
|
150
|
+
1. Clone this repository.
|
|
151
|
+
2. Install dependencies: `pip install -r requirements.txt` (ensure `requirements.txt` is up-to-date).
|
|
152
|
+
3. Create a `secrets.json` file as described in the Usage section.
|
|
153
|
+
4. Run `python main.py`.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Python client for LG Horizon."""
|
|
2
|
+
|
|
3
|
+
from .lghorizon_api import LGHorizonApi
|
|
4
|
+
from .lghorizon_device import LGHorizonDevice
|
|
5
|
+
from .lghorizon_models import (
|
|
6
|
+
LGHorizonAuth,
|
|
7
|
+
LGHorizonChannel,
|
|
8
|
+
LGHorizonCustomer,
|
|
9
|
+
LGHorizonDeviceState,
|
|
10
|
+
LGHorizonProfile,
|
|
11
|
+
LGHorizonRecording,
|
|
12
|
+
LGHorizonRecordingList,
|
|
13
|
+
LGHorizonShowRecordingList,
|
|
14
|
+
LGHorizonRecordingSeason,
|
|
15
|
+
LGHorizonRecordingSingle,
|
|
16
|
+
LGHorizonRecordingShow,
|
|
17
|
+
LGHorizonRecordingQuota,
|
|
18
|
+
LGHorizonRecordingType,
|
|
19
|
+
LGHorizonUIStateType,
|
|
20
|
+
LGHorizonMessageType,
|
|
21
|
+
LGHorizonRunningState,
|
|
22
|
+
LGHorizonRecordingSource,
|
|
23
|
+
LGHorizonRecordingState,
|
|
24
|
+
LGHorizonSourceType,
|
|
25
|
+
LGHorizonPlayerState,
|
|
26
|
+
LGHorizonAppsState,
|
|
27
|
+
LGHorizonUIState,
|
|
28
|
+
LGHorizonProfileOptions,
|
|
29
|
+
LGHorizonServicesConfig,
|
|
30
|
+
)
|
|
31
|
+
from .exceptions import (
|
|
32
|
+
LGHorizonApiError,
|
|
33
|
+
LGHorizonApiConnectionError,
|
|
34
|
+
LGHorizonApiUnauthorizedError,
|
|
35
|
+
LGHorizonApiLockedError,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"LGHorizonApi",
|
|
40
|
+
"LGHorizonDevice",
|
|
41
|
+
"LGHorizonAuth",
|
|
42
|
+
"LGHorizonChannel",
|
|
43
|
+
"LGHorizonCustomer",
|
|
44
|
+
"LGHorizonDeviceState",
|
|
45
|
+
"LGHorizonProfile",
|
|
46
|
+
"LGHorizonApiError",
|
|
47
|
+
"LGHorizonApiConnectionError",
|
|
48
|
+
"LGHorizonApiUnauthorizedError",
|
|
49
|
+
"LGHorizonApiLockedError",
|
|
50
|
+
"LGHorizonRecordingList",
|
|
51
|
+
"LGHorizonRecordingSeason",
|
|
52
|
+
"LGHorizonRecordingSingle",
|
|
53
|
+
"LGHorizonRecordingShow",
|
|
54
|
+
"LGHorizonRecordingQuota",
|
|
55
|
+
"LGHorizonRecordingType",
|
|
56
|
+
"LGHorizonUIStateType",
|
|
57
|
+
"LGHorizonMessageType",
|
|
58
|
+
"LGHorizonRunningState",
|
|
59
|
+
"LGHorizonRecordingSource",
|
|
60
|
+
"LGHorizonRecordingState",
|
|
61
|
+
"LGHorizonSourceType",
|
|
62
|
+
"LGHorizonPlayerState",
|
|
63
|
+
"LGHorizonAppsState",
|
|
64
|
+
"LGHorizonUIState",
|
|
65
|
+
"LGHorizonProfileOptions",
|
|
66
|
+
"LGHorizonProfile",
|
|
67
|
+
"LGHorizonAuth",
|
|
68
|
+
"LGHorizonServicesConfig",
|
|
69
|
+
"LGHorizonRecording",
|
|
70
|
+
"LGHorizonShowRecordingList",
|
|
71
|
+
]
|
|
@@ -38,11 +38,18 @@ RECORDING_TYPE_SEASON = "season"
|
|
|
38
38
|
|
|
39
39
|
BE_AUTH_URL = "https://login.prd.telenet.be/openid/login.do"
|
|
40
40
|
|
|
41
|
+
PLATFORM_TYPES = {
|
|
42
|
+
"EOS": {"manufacturer": "Arris", "model": "DCX960"},
|
|
43
|
+
"EOS2": {"manufacturer": "HUMAX", "model": "2008C-STB-TN"},
|
|
44
|
+
"HORIZON": {"manufacturer": "Arris", "model": "DCX960"},
|
|
45
|
+
"APOLLO": {"manufacturer": "Arris", "model": "VIP5002W"},
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
COUNTRY_SETTINGS = {
|
|
42
49
|
"nl": {
|
|
43
50
|
"api_url": "https://spark-prod-nl.gnp.cloud.ziggogo.tv",
|
|
44
51
|
"mqtt_url": "obomsg.prod.nl.horizon.tv",
|
|
45
|
-
"
|
|
52
|
+
"use_refreshtoken": False,
|
|
46
53
|
"channels": [
|
|
47
54
|
{
|
|
48
55
|
"channelId": "NL_000073_019506",
|
|
@@ -106,7 +113,7 @@ COUNTRY_SETTINGS = {
|
|
|
106
113
|
},
|
|
107
114
|
"be-nl-preprod": {
|
|
108
115
|
"api_url": "https://spark-preprod-be.gnp.cloud.telenet.tv",
|
|
109
|
-
"
|
|
116
|
+
"use_refreshtoken": True,
|
|
110
117
|
"oauth_username_fieldname": "j_username",
|
|
111
118
|
"oauth_password_fieldname": "j_password",
|
|
112
119
|
"oauth_add_accept_header": False,
|
|
@@ -131,13 +138,13 @@ COUNTRY_SETTINGS = {
|
|
|
131
138
|
},
|
|
132
139
|
"ie": {
|
|
133
140
|
"api_url": "https://spark-prod-ie.gnp.cloud.virginmediatv.ie",
|
|
134
|
-
"
|
|
141
|
+
"use_refreshtoken": False,
|
|
135
142
|
"channels": [],
|
|
136
143
|
"language": "en",
|
|
137
144
|
},
|
|
138
145
|
"pl": {
|
|
139
146
|
"api_url": "https://spark-prod-pl.gnp.cloud.upctv.pl",
|
|
140
|
-
"
|
|
147
|
+
"use_refreshtoken": False,
|
|
141
148
|
"channels": [],
|
|
142
149
|
"language": "pl",
|
|
143
150
|
"platform_types": {
|
|
@@ -6,12 +6,12 @@ class LGHorizonApiError(Exception):
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class LGHorizonApiConnectionError(LGHorizonApiError):
|
|
9
|
-
"""
|
|
9
|
+
"""Exception for connection-related errors with the LG Horizon API."""
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class LGHorizonApiUnauthorizedError(Exception):
|
|
13
|
-
"""
|
|
13
|
+
"""Exception for unauthorized access to the LG Horizon API."""
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class LGHorizonApiLockedError(LGHorizonApiUnauthorizedError):
|
|
17
|
-
"""
|
|
17
|
+
"""Exception for locked account errors with the LG Horizon API."""
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import random
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def make_id(string_length=10):
|
|
6
|
+
async def make_id(string_length=10):
|
|
7
7
|
"""Create an id with given length."""
|
|
8
8
|
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
9
9
|
return "".join(random.choice(letters) for i in range(string_length))
|