pypetkitapi 1.12.5__tar.gz → 1.12.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pypetkitapi
3
- Version: 1.12.5
3
+ Version: 1.12.6
4
4
  Summary: Python client for PetKit API
5
5
  License: MIT
6
6
  Author: Jezza34000
@@ -51,7 +51,7 @@ from .media import DownloadDecryptMedia, MediaCloud, MediaFile, MediaManager
51
51
  from .purifier_container import Purifier
52
52
  from .water_fountain_container import WaterFountain
53
53
 
54
- __version__ = "1.12.5"
54
+ __version__ = "1.12.6"
55
55
 
56
56
  __all__ = [
57
57
  "CTW3",
@@ -28,7 +28,9 @@ T3 = "t3"
28
28
  T4 = "t4"
29
29
  T5 = "t5"
30
30
  T6 = "t6"
31
+ W4 = "w4"
31
32
  W5 = "w5"
33
+ CTW2 = "ctw2"
32
34
  CTW3 = "ctw3"
33
35
  K2 = "k2"
34
36
  K3 = "k3"
@@ -42,7 +44,7 @@ LITTER_NO_CAMERA = [T3, T4]
42
44
  FEEDER_WITH_CAMERA = [D4H, D4SH]
43
45
  DEVICES_FEEDER = [FEEDER, FEEDER_MINI, D3, D4, D4S, D4H, D4SH]
44
46
  # Water Fountain
45
- DEVICES_WATER_FOUNTAIN = [W5, CTW3]
47
+ DEVICES_WATER_FOUNTAIN = [W4, W5, CTW2, CTW3]
46
48
  # Purifier
47
49
  DEVICES_PURIFIER = [K2]
48
50
  # All devices
@@ -76,7 +78,7 @@ class Header(StrEnum):
76
78
  ACCEPT = "*/*"
77
79
  ACCEPT_LANG = "en-US;q=1, it-US;q=0.9"
78
80
  ENCODING = "gzip, deflate"
79
- API_VERSION = "11.4.0"
81
+ API_VERSION = "12.0.2"
80
82
  CONTENT_TYPE = "application/x-www-form-urlencoded"
81
83
  AGENT = "okhttp/3.12.11"
82
84
  CLIENT = f"{Client.PLATFORM_TYPE}({Client.OS_VERSION};{Client.MODEL_NAME})"
@@ -24,6 +24,7 @@ from pypetkitapi.const import (
24
24
  FEEDER_WITH_CAMERA,
25
25
  LITTER_WITH_CAMERA,
26
26
  MediaType,
27
+ PetkitEndpoint,
27
28
  RecordTypeLST,
28
29
  )
29
30
  from pypetkitapi.litter_container import LitterRecord
@@ -353,7 +354,7 @@ class MediaManager:
353
354
  user_id=user_id,
354
355
  image=item.preview,
355
356
  video=await self.construct_video_url(
356
- device_type, item.media_api, user_id, cp_sub
357
+ device_type, item, user_id, cp_sub
357
358
  ),
358
359
  filepath=filepath,
359
360
  aes_key=item.aes_key,
@@ -407,7 +408,7 @@ class MediaManager:
407
408
  user_id=user_id,
408
409
  image=record.preview,
409
410
  video=await self.construct_video_url(
410
- device_type, record.media_api, user_id, cp_sub
411
+ device_type, record, user_id, cp_sub
411
412
  ),
412
413
  filepath=filepath,
413
414
  aes_key=record.aes_key,
@@ -442,22 +443,26 @@ class MediaManager:
442
443
  @staticmethod
443
444
  async def construct_video_url(
444
445
  device_type: str | None,
445
- media_url: str | None,
446
+ event_data: LitterRecord | RecordsItems,
446
447
  user_id: int,
447
448
  cp_sub: bool | None,
448
449
  ) -> str | None:
449
450
  """Construct the video URL.
450
451
  :param device_type: Device type
451
- :param media_url: Media URL
452
+ :param event_data: LitterRecord | RecordsItems
452
453
  :param user_id: User ID
453
454
  :param cp_sub: Cpsub value
454
455
  :return: Constructed video URL
455
456
  """
456
- if not media_url or not user_id or not cp_sub:
457
+ if not hasattr(event_data, "media_api") or not user_id or not cp_sub:
457
458
  return None
458
- params = parse_qs(urlparse(media_url).query)
459
+ params = parse_qs(str(urlparse(event_data.media_api).query))
459
460
  param_dict = {k: v[0] for k, v in params.items()}
460
- return f"/{device_type}/cloud/video?startTime={param_dict.get("startTime")}&deviceId={param_dict.get("deviceId")}&userId={user_id}&mark={param_dict.get("mark")}"
461
+ url = f"/{device_type}/{PetkitEndpoint.CLOUD_VIDEO}?startTime={param_dict.get('startTime')}&deviceId={param_dict.get('deviceId')}&userId={user_id}&mark={param_dict.get('mark')}"
462
+ if hasattr(event_data, "eat_end_time"):
463
+ # Special case for Eat video (need to add endTime)
464
+ url += f"&endTime={event_data.eat_end_time}"
465
+ return url
461
466
 
462
467
  @staticmethod
463
468
  async def _get_timestamp(item) -> int | None:
@@ -187,7 +187,7 @@ build-backend = "poetry.core.masonry.api"
187
187
 
188
188
  [tool.poetry]
189
189
  name = "pypetkitapi"
190
- version = "1.12.5"
190
+ version = "1.12.6"
191
191
  description = "Python client for PetKit API"
192
192
  authors = ["Jezza34000 <info@mail.com>"]
193
193
  readme = "README.md"
@@ -209,7 +209,7 @@ ruff = "^0.8.1"
209
209
  types-aiofiles = "^24.1.0.20240626"
210
210
 
211
211
  [tool.bumpver]
212
- current_version = "1.12.5"
212
+ current_version = "1.12.6"
213
213
  version_pattern = "MAJOR.MINOR.PATCH"
214
214
  commit_message = "bump version {old_version} -> {new_version}"
215
215
  tag_message = "{new_version}"
File without changes
File without changes