Skip to content

Commit a2759bc

Browse files
committed
Add missing model fields from protocol spec
- ImageInfo: hd_size (HD image cipher size) - VoiceInfo: encode_type, bits_per_sample, sample_rate These fields are present in the protocol but were not being parsed.
1 parent c000f8a commit a2759bc

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/weilink/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,7 @@ def _parse_image_item(cls, raw: dict[str, Any]) -> ImageInfo:
13401340
url=raw.get("url", ""),
13411341
thumb_width=raw.get("thumb_width", 0),
13421342
thumb_height=raw.get("thumb_height", 0),
1343+
hd_size=raw.get("hd_size", 0),
13431344
)
13441345

13451346
@classmethod
@@ -1350,6 +1351,9 @@ def _parse_voice_item(cls, raw: dict[str, Any]) -> VoiceInfo:
13501351
media=media,
13511352
playtime=raw.get("playtime", 0),
13521353
text=raw.get("text", ""),
1354+
encode_type=raw.get("encode_type", 0),
1355+
bits_per_sample=raw.get("bits_per_sample", 0),
1356+
sample_rate=raw.get("sample_rate", 0),
13531357
)
13541358

13551359
@classmethod

src/weilink/models.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@ class ImageInfo:
123123
url: Direct image URL (may be empty).
124124
thumb_width: Thumbnail width in pixels.
125125
thumb_height: Thumbnail height in pixels.
126+
hd_size: HD image cipher size in bytes.
126127
"""
127128

128129
media: MediaInfo = field(default_factory=MediaInfo)
129130
url: str = ""
130131
thumb_width: int = 0
131132
thumb_height: int = 0
133+
hd_size: int = 0
132134

133135

134136
@dataclass(frozen=True)
@@ -137,13 +139,19 @@ class VoiceInfo:
137139
138140
Attributes:
139141
media: CDN media reference for the voice file.
140-
playtime: Duration in seconds.
142+
playtime: Duration in milliseconds.
141143
text: Voice-to-text transcription (may be empty).
144+
encode_type: Audio codec (1=pcm, 2=adpcm, 4=speex, 5=amr, 6=silk, 7=mp3).
145+
bits_per_sample: Bit depth.
146+
sample_rate: Sample rate in Hz.
142147
"""
143148

144149
media: MediaInfo = field(default_factory=MediaInfo)
145150
playtime: int = 0
146151
text: str = ""
152+
encode_type: int = 0
153+
bits_per_sample: int = 0
154+
sample_rate: int = 0
147155

148156

149157
@dataclass(frozen=True)

0 commit comments

Comments
 (0)