pypetkitapi 1.6.0__py3-none-any.whl → 1.6.1__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/medias.py +34 -36
- {pypetkitapi-1.6.0.dist-info → pypetkitapi-1.6.1.dist-info}/METADATA +1 -1
- {pypetkitapi-1.6.0.dist-info → pypetkitapi-1.6.1.dist-info}/RECORD +5 -5
- {pypetkitapi-1.6.0.dist-info → pypetkitapi-1.6.1.dist-info}/LICENSE +0 -0
- {pypetkitapi-1.6.0.dist-info → pypetkitapi-1.6.1.dist-info}/WHEEL +0 -0
pypetkitapi/medias.py
CHANGED
@@ -25,6 +25,7 @@ class MediasFiles:
|
|
25
25
|
record_type: str
|
26
26
|
url: str
|
27
27
|
aes_key: str
|
28
|
+
timestamp: str | None = None
|
28
29
|
|
29
30
|
|
30
31
|
async def extract_filename_from_url(url: str) -> str:
|
@@ -70,49 +71,46 @@ class MediaHandler:
|
|
70
71
|
"""Process individual records and return media info."""
|
71
72
|
media_files = []
|
72
73
|
|
74
|
+
async def process_item(record_items, reversed_order=False):
|
75
|
+
items = reversed(record_items) if reversed_order else record_items
|
76
|
+
last_item = next(
|
77
|
+
(item for item in items if item.preview and item.aes_key),
|
78
|
+
None,
|
79
|
+
)
|
80
|
+
if last_item:
|
81
|
+
filename = await extract_filename_from_url(last_item.preview)
|
82
|
+
await self.media_download_decode.get_file(
|
83
|
+
last_item.preview, last_item.aes_key
|
84
|
+
)
|
85
|
+
|
86
|
+
timestamp = (
|
87
|
+
last_item.eat_start_time
|
88
|
+
or last_item.completed_at
|
89
|
+
or last_item.timestamp
|
90
|
+
or None
|
91
|
+
)
|
92
|
+
|
93
|
+
media_files.append(
|
94
|
+
MediasFiles(
|
95
|
+
record_type=record_type,
|
96
|
+
filename=filename,
|
97
|
+
url=last_item.preview,
|
98
|
+
aes_key=last_item.aes_key,
|
99
|
+
timestamp=timestamp,
|
100
|
+
)
|
101
|
+
)
|
102
|
+
|
73
103
|
if record_type == "feed":
|
74
104
|
for record in reversed(records):
|
75
105
|
if record.items:
|
76
|
-
|
77
|
-
|
78
|
-
item
|
79
|
-
for item in reversed(record.items)
|
80
|
-
if item.preview and item.aes_key
|
81
|
-
),
|
82
|
-
None,
|
83
|
-
)
|
84
|
-
if last_item:
|
85
|
-
filename = await extract_filename_from_url(last_item.preview)
|
86
|
-
await self.media_download_decode.get_file(
|
87
|
-
last_item.preview, last_item.aes_key
|
88
|
-
)
|
89
|
-
media_files.append(
|
90
|
-
MediasFiles(
|
91
|
-
record_type=record_type,
|
92
|
-
filename=filename,
|
93
|
-
url=last_item.preview,
|
94
|
-
aes_key=last_item.aes_key,
|
95
|
-
)
|
96
|
-
)
|
106
|
+
await process_item(record.items, reversed_order=True)
|
107
|
+
if media_files: # Stop processing if a media file is added
|
97
108
|
return media_files
|
98
109
|
else:
|
99
110
|
for record in records:
|
100
111
|
if record.items:
|
101
|
-
|
102
|
-
|
103
|
-
aes_key = last_item.aes_key
|
104
|
-
|
105
|
-
if preview_url and aes_key:
|
106
|
-
filename = await extract_filename_from_url(preview_url)
|
107
|
-
await self.media_download_decode.get_file(preview_url, aes_key)
|
108
|
-
media_files.append(
|
109
|
-
MediasFiles(
|
110
|
-
record_type=record_type,
|
111
|
-
filename=filename,
|
112
|
-
url=preview_url,
|
113
|
-
aes_key=aes_key,
|
114
|
-
)
|
115
|
-
)
|
112
|
+
await process_item(record.items)
|
113
|
+
|
116
114
|
return media_files
|
117
115
|
|
118
116
|
|
@@ -6,10 +6,10 @@ pypetkitapi/containers.py,sha256=zj0MBEYA7wp2Nieu1oW4JROs_r7il9VZN8AUyQv-gJs,419
|
|
6
6
|
pypetkitapi/exceptions.py,sha256=NWmpsI2ewC4HaIeu_uFwCeuPIHIJxZBzjoCP7aNwvhs,1139
|
7
7
|
pypetkitapi/feeder_container.py,sha256=28GXZ8Nbs08PnFZZI4ENBe3UJ63gsXT3rFa151KrPxo,13310
|
8
8
|
pypetkitapi/litter_container.py,sha256=UmgIE1iYNFetHjnTXfM6jhRnOk_0Ubdyr697-6SGKqc,18042
|
9
|
-
pypetkitapi/medias.py,sha256=
|
9
|
+
pypetkitapi/medias.py,sha256=wutuX2w3Jz6k8F3u25Ryublf5hQtTFg1yKNNCEbtfgg,7033
|
10
10
|
pypetkitapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
pypetkitapi/water_fountain_container.py,sha256=j6FQEgbZAbsPXDVhcIB05RsNnQJftcWUJKmzuX4TrjM,6712
|
12
|
-
pypetkitapi-1.6.
|
13
|
-
pypetkitapi-1.6.
|
14
|
-
pypetkitapi-1.6.
|
15
|
-
pypetkitapi-1.6.
|
12
|
+
pypetkitapi-1.6.1.dist-info/LICENSE,sha256=4FWnKolNLc1e3w6cVlT61YxfPh0DQNeQLN1CepKKSBg,1067
|
13
|
+
pypetkitapi-1.6.1.dist-info/METADATA,sha256=kSyY6TSSWwNyXHa7APUmOoeMp_VPiI9dv6zftPg7zp0,4636
|
14
|
+
pypetkitapi-1.6.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
15
|
+
pypetkitapi-1.6.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|