lghorizon 0.9.1__tar.gz → 0.9.2__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.9.1 → lghorizon-0.9.2}/PKG-INFO +1 -1
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/lghorizon_device_state_processor.py +17 -18
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon.egg-info/PKG-INFO +1 -1
- {lghorizon-0.9.1 → lghorizon-0.9.2}/main.py +37 -3
- {lghorizon-0.9.1 → lghorizon-0.9.2}/.coverage +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/.flake8 +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/.github/workflows/build-on-pr.yml +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/.github/workflows/publish-to-pypi.yml +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/.gitignore +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/.vscode/launch.json +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/LICENSE +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/README.md +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/instructions.txt +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/__init__.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/const.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/exceptions.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/helpers.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/lghorizon_api.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/lghorizon_device.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/lghorizon_message_factory.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/lghorizon_models.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/lghorizon_mqtt_client.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/lghorizon_recording_factory.py +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon/py.typed +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon.egg-info/SOURCES.txt +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon.egg-info/dependency_links.txt +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon.egg-info/not-zip-safe +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon.egg-info/requires.txt +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lghorizon.egg-info/top_level.txt +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/lib64 +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/pyvenv.cfg +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/renovate.json +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/secrets_stub.json +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/setup.cfg +0 -0
- {lghorizon-0.9.1 → lghorizon-0.9.2}/setup.py +0 -0
|
@@ -154,13 +154,11 @@ class LGHorizonDeviceStateProcessor:
|
|
|
154
154
|
device_state.season_number = replay_event.season_number
|
|
155
155
|
device_state.episode_number = replay_event.episode_number
|
|
156
156
|
device_state.show_title = replay_event.title
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
device_state.last_position_update = int(time.time() * 1000)
|
|
157
|
+
device_state.last_position_update = int(time.time())
|
|
160
158
|
device_state.start_time = replay_event.start_time
|
|
161
159
|
device_state.end_time = replay_event.end_time
|
|
162
160
|
device_state.duration = replay_event.end_time - replay_event.start_time
|
|
163
|
-
device_state.position =
|
|
161
|
+
device_state.position = int(time.time()) - int(replay_event.start_time)
|
|
164
162
|
|
|
165
163
|
# Add random number to url to force refresh
|
|
166
164
|
join_param = "?"
|
|
@@ -200,8 +198,10 @@ class LGHorizonDeviceStateProcessor:
|
|
|
200
198
|
device_state.season_number = replay_event.season_number
|
|
201
199
|
device_state.episode_number = replay_event.episode_number
|
|
202
200
|
device_state.show_title = replay_event.title
|
|
203
|
-
device_state.last_position_update =
|
|
204
|
-
|
|
201
|
+
device_state.last_position_update = int(
|
|
202
|
+
player_state.last_speed_change_time / 1000
|
|
203
|
+
)
|
|
204
|
+
device_state.position = int(player_state.relative_position / 1000)
|
|
205
205
|
device_state.start_time = replay_event.start_time
|
|
206
206
|
device_state.end_time = replay_event.end_time
|
|
207
207
|
device_state.duration = replay_event.end_time - replay_event.start_time
|
|
@@ -237,22 +237,19 @@ class LGHorizonDeviceStateProcessor:
|
|
|
237
237
|
device_state.id = replay_event.event_id
|
|
238
238
|
# Iets met buffer doen
|
|
239
239
|
channel = self._channels[replay_event.channel_id]
|
|
240
|
-
padding = channel.replay_pre_padding + channel.replay_post_padding
|
|
241
240
|
device_state.source_type = source.source_type
|
|
242
241
|
device_state.channel_id = channel.id
|
|
243
242
|
device_state.episode_title = replay_event.episode_name
|
|
244
243
|
device_state.season_number = replay_event.season_number
|
|
245
244
|
device_state.episode_number = replay_event.episode_number
|
|
246
245
|
device_state.show_title = replay_event.title
|
|
247
|
-
device_state.last_position_update = int(
|
|
246
|
+
device_state.last_position_update = int(
|
|
247
|
+
player_state.last_speed_change_time / 1000
|
|
248
|
+
)
|
|
248
249
|
device_state.start_time = replay_event.start_time
|
|
249
250
|
device_state.end_time = replay_event.end_time
|
|
250
|
-
device_state.duration =
|
|
251
|
-
|
|
252
|
-
)
|
|
253
|
-
device_state.position = (
|
|
254
|
-
player_state.relative_position + channel.replay_pre_padding
|
|
255
|
-
)
|
|
251
|
+
device_state.duration = replay_event.end_time - replay_event.start_time
|
|
252
|
+
device_state.position = int(player_state.relative_position / 1000)
|
|
256
253
|
# Add random number to url to force refresh
|
|
257
254
|
device_state.image = await self._get_intent_image_url(replay_event.event_id)
|
|
258
255
|
|
|
@@ -286,8 +283,8 @@ class LGHorizonDeviceStateProcessor:
|
|
|
286
283
|
device_state.show_title = vod.title
|
|
287
284
|
|
|
288
285
|
device_state.duration = vod.duration
|
|
289
|
-
device_state.last_position_update = int(time.time()
|
|
290
|
-
device_state.position = player_state.relative_position
|
|
286
|
+
device_state.last_position_update = int(time.time())
|
|
287
|
+
device_state.position = int(player_state.relative_position / 1000)
|
|
291
288
|
|
|
292
289
|
device_state.image = await self._get_intent_image_url(vod.id)
|
|
293
290
|
|
|
@@ -317,8 +314,10 @@ class LGHorizonDeviceStateProcessor:
|
|
|
317
314
|
device_state.episode_title = recording.episode_title
|
|
318
315
|
device_state.season_number = recording.season_number
|
|
319
316
|
device_state.episode_number = recording.episode_number
|
|
320
|
-
device_state.last_position_update =
|
|
321
|
-
|
|
317
|
+
device_state.last_position_update = int(
|
|
318
|
+
player_state.last_speed_change_time / 1000
|
|
319
|
+
)
|
|
320
|
+
device_state.position = int(player_state.relative_position / 1000)
|
|
322
321
|
if recording.start_time:
|
|
323
322
|
device_state.start_time = int(
|
|
324
323
|
dt.fromisoformat(
|
|
@@ -4,9 +4,9 @@ import asyncio
|
|
|
4
4
|
import json
|
|
5
5
|
import logging
|
|
6
6
|
import sys # Import sys for stdin
|
|
7
|
-
|
|
8
7
|
import aiohttp
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
from datetime import datetime
|
|
10
10
|
|
|
11
11
|
from lghorizon.lghorizon_api import LGHorizonApi
|
|
12
12
|
from lghorizon.lghorizon_models import LGHorizonAuth
|
|
@@ -28,6 +28,40 @@ async def read_input_and_signal_shutdown():
|
|
|
28
28
|
_LOGGER = logging.getLogger(__name__)
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
def format_duration(total_seconds):
|
|
32
|
+
# Handle None immediately
|
|
33
|
+
if total_seconds is None:
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
# Store if the value is negative and work with positive numbers for calculation
|
|
37
|
+
is_negative = total_seconds < 0
|
|
38
|
+
total_seconds = abs(int(total_seconds))
|
|
39
|
+
|
|
40
|
+
# Efficiently calculate hours, minutes, and seconds
|
|
41
|
+
minutes, seconds = divmod(total_seconds, 60)
|
|
42
|
+
hours, minutes = divmod(minutes, 60)
|
|
43
|
+
|
|
44
|
+
# Determine the base format
|
|
45
|
+
if hours > 0:
|
|
46
|
+
result = f"{hours}:{minutes:02}:{seconds:02}"
|
|
47
|
+
elif minutes > 0:
|
|
48
|
+
result = f"{minutes}:{seconds:02}"
|
|
49
|
+
else:
|
|
50
|
+
result = f"{seconds}"
|
|
51
|
+
|
|
52
|
+
# Add the minus sign if it was negative
|
|
53
|
+
return f"-{result}" if is_negative else result
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def convert_timestamp_to_datetime(timestamp):
|
|
57
|
+
# Handle None to prevent crashes
|
|
58
|
+
if timestamp is None:
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
# Convert seconds to a datetime object
|
|
62
|
+
return datetime.fromtimestamp(timestamp)
|
|
63
|
+
|
|
64
|
+
|
|
31
65
|
async def main():
|
|
32
66
|
"""Main function to run the LG Horizon API test script."""
|
|
33
67
|
logging.basicConfig(
|
|
@@ -54,7 +88,7 @@ async def main():
|
|
|
54
88
|
async def device_callback(device_id: str):
|
|
55
89
|
device = devices[device_id]
|
|
56
90
|
print(
|
|
57
|
-
f"Device {device.device_id} state changed. Status:\n\nName: {device.device_friendly_name}\nState: {device.device_state.state.value}\nChannel: {device.device_state.channel_name} ({device.device_state.channel_id})\nShow: {device.device_state.show_title}\nEpisode: {device.device_state.episode_title}\nSource type: {device.device_state.source_type.value}\nlast pos update: {device.device_state.last_position_update}\npos: {device.device_state.position}\nstart time: {device.device_state.start_time}\nend time: {device.device_state.end_time}\n\n",
|
|
91
|
+
f"Device {device.device_id} state changed. Status:\n\nName: {device.device_friendly_name}\nState: {device.device_state.state.value}\nChannel: {device.device_state.channel_name} ({device.device_state.channel_id})\nShow: {device.device_state.show_title}\nEpisode: {device.device_state.episode_title}\nSource type: {device.device_state.source_type.value}\nlast pos update: {convert_timestamp_to_datetime(device.device_state.last_position_update)}\npos: {format_duration(device.device_state.position)}\nduration: {format_duration(device.device_state.duration)}\nstart time: {convert_timestamp_to_datetime(device.device_state.start_time)}\nend time: {convert_timestamp_to_datetime(device.device_state.end_time)}\n\n",
|
|
58
92
|
)
|
|
59
93
|
|
|
60
94
|
try:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|