pypetkitapi 1.11.2__py3-none-any.whl → 1.11.3__py3-none-any.whl

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.
pypetkitapi/__init__.py CHANGED
@@ -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.11.2"
54
+ __version__ = "1.11.3"
55
55
 
56
56
  __all__ = [
57
57
  "CTW3",
pypetkitapi/media.py CHANGED
@@ -270,9 +270,7 @@ class MediaManager:
270
270
  device_type = (
271
271
  device_obj.device_nfo.device_type if device_obj.device_nfo else None
272
272
  )
273
- cp_sub = (
274
- device_obj.cloud_product.subscribe if device_obj.cloud_product else None
275
- )
273
+ cp_sub = self.is_subscription_active(device_obj)
276
274
 
277
275
  if not feeder_id:
278
276
  _LOGGER.warning("Missing feeder_id for record")
@@ -299,7 +297,7 @@ class MediaManager:
299
297
  _LOGGER.warning("Missing user_id for record item")
300
298
  continue
301
299
  if not item.aes_key:
302
- _LOGGER.warning("Missing aes_key for record item")
300
+ _LOGGER.debug("Missing aes_key for record item")
303
301
  continue
304
302
 
305
303
  date_str = await self.get_date_from_ts(timestamp)
@@ -331,7 +329,7 @@ class MediaManager:
331
329
  litter_id = litter.device_nfo.device_id if litter.device_nfo else None
332
330
  device_type = litter.device_nfo.device_type if litter.device_nfo else None
333
331
  user_id = litter.user.id if litter.user else None
334
- cp_sub = litter.cloud_product.subscribe if litter.cloud_product else None
332
+ cp_sub = self.is_subscription_active(litter)
335
333
 
336
334
  if not litter_id:
337
335
  _LOGGER.warning("Missing litter_id for record")
@@ -383,6 +381,19 @@ class MediaManager:
383
381
  )
384
382
  return media_files
385
383
 
384
+ @staticmethod
385
+ def is_subscription_active(device: Feeder | Litter) -> bool:
386
+ """Check if the subscription is active based on the work_indate timestamp.
387
+ :param device: Device object
388
+ :return: True if the subscription is active, False otherwise
389
+ """
390
+ if device.cloud_product and device.cloud_product.work_indate:
391
+ return (
392
+ datetime.fromtimestamp(device.cloud_product.work_indate)
393
+ > datetime.now()
394
+ )
395
+ return False
396
+
386
397
  @staticmethod
387
398
  async def get_date_from_ts(timestamp: int | None) -> str:
388
399
  """Get date from timestamp.
@@ -395,7 +406,10 @@ class MediaManager:
395
406
 
396
407
  @staticmethod
397
408
  async def construct_video_url(
398
- device_type: str | None, media_url: str | None, user_id: int, cp_sub: int | None
409
+ device_type: str | None,
410
+ media_url: str | None,
411
+ user_id: int,
412
+ cp_sub: bool | None,
399
413
  ) -> str | None:
400
414
  """Construct the video URL.
401
415
  :param device_type: Device type
@@ -404,7 +418,7 @@ class MediaManager:
404
418
  :param cp_sub: Cpsub value
405
419
  :return: Constructed video URL
406
420
  """
407
- if not media_url or not user_id or cp_sub != 1:
421
+ if not media_url or not user_id or not cp_sub:
408
422
  return None
409
423
  params = parse_qs(urlparse(media_url).query)
410
424
  param_dict = {k: v[0] for k, v in params.items()}
@@ -539,7 +553,7 @@ class DownloadDecryptMedia:
539
553
 
540
554
  media_api = video_data.get("mediaApi", None)
541
555
  if not media_api:
542
- _LOGGER.warning("Missing mediaApi in video data")
556
+ _LOGGER.debug("Missing mediaApi in video data")
543
557
  raise ValueError("Missing mediaApi in video data")
544
558
  return await self.client.extract_segments_m3u8(str(media_api))
545
559
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pypetkitapi
3
- Version: 1.11.2
3
+ Version: 1.11.3
4
4
  Summary: Python client for PetKit API
5
5
  License: MIT
6
6
  Author: Jezza34000
@@ -1,4 +1,4 @@
1
- pypetkitapi/__init__.py,sha256=qDhET_P65lnwbZgZnkYst3IgJxPlID7fLqYnfVSzJqM,2107
1
+ pypetkitapi/__init__.py,sha256=Ta6BJBUyI7-C8kUXHJ1nym7-oXdmKWxXn1OfCssy9U8,2107
2
2
  pypetkitapi/bluetooth.py,sha256=eu6c2h6YHBafAhhSSy4As6tn29i5WbOH9tZzRlMm44U,7843
3
3
  pypetkitapi/client.py,sha256=wzZQUHg_ee6lmdAjli6zS7qw_sgPER9iLfcTZe4VTH4,27190
4
4
  pypetkitapi/command.py,sha256=cMCUutZCQo9Ddvjl_FYR5UjU_CqFz1iyetMznYwjpzM,7500
@@ -7,13 +7,13 @@ pypetkitapi/containers.py,sha256=F_uyDBD0a5QD4s_ArjYiKTAAg1XHYBvmV_lEnO9RQ-U,478
7
7
  pypetkitapi/exceptions.py,sha256=4BXUyYXLfZjNxdnOGJPjyE9ASIl7JmQphjws87jvHtE,1631
8
8
  pypetkitapi/feeder_container.py,sha256=PhidWd5WpsZqtdKZy60PzE67YXgQfApjm8CqvMCHK3U,14743
9
9
  pypetkitapi/litter_container.py,sha256=KWvHNAOJ6hDSeJ_55tqtzY9GxHtd9gAntPkbnVbdb-I,19275
10
- pypetkitapi/media.py,sha256=34q3pIfejO_z-Uk8ohQlOGaPOdaGtnI0zN1LtZ3k3F4,25904
10
+ pypetkitapi/media.py,sha256=aGl4nw8q8UK5J2pDEH-lP-Jhy4RWFAqWfyZaLeX3wKM,26356
11
11
  pypetkitapi/purifier_container.py,sha256=ssyIxhNben5XJ4KlQTXTrtULg2ji6DqHqjzOq08d1-I,2491
12
12
  pypetkitapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  pypetkitapi/schedule_container.py,sha256=OjLAY6FY-g14JNJJnYMNFV5ZtdkjUzNBit1VUiiZKnQ,2053
14
14
  pypetkitapi/utils.py,sha256=z7325kcJQUburnF28HSXrJMvY_gY9007K73Zwxp-4DQ,743
15
15
  pypetkitapi/water_fountain_container.py,sha256=5J0b-fDZYcFLNX2El7fifv8H6JMhBCt-ttxSow1ozRQ,6787
16
- pypetkitapi-1.11.2.dist-info/LICENSE,sha256=u5jNkZEn6YMrtN4Kr5rU3TcBJ5-eAt0qMx4JDsbsnzM,1074
17
- pypetkitapi-1.11.2.dist-info/METADATA,sha256=8HbQJ6UeGion-oO5Y5U0X7THfeDRYeP-EK-XVwF_Lb8,6338
18
- pypetkitapi-1.11.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
19
- pypetkitapi-1.11.2.dist-info/RECORD,,
16
+ pypetkitapi-1.11.3.dist-info/LICENSE,sha256=u5jNkZEn6YMrtN4Kr5rU3TcBJ5-eAt0qMx4JDsbsnzM,1074
17
+ pypetkitapi-1.11.3.dist-info/METADATA,sha256=Mqjd4OtD4X539bRYn15IxcRzz2nOMYNEj0jQRu_WnyU,6338
18
+ pypetkitapi-1.11.3.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
19
+ pypetkitapi-1.11.3.dist-info/RECORD,,