From e71690a98523bf3e0c12e43e26880925da27ea70 Mon Sep 17 00:00:00 2001 From: helloteemo Date: Thu, 11 Jul 2024 17:39:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=B0=8F=E7=BA=A2?= =?UTF-8?q?=E4=B9=A6=E5=9B=BE=E7=89=87=E6=B0=B4=E5=8D=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- media_platform/xhs/client.py | 7 ++++++- store/xhs/__init__.py | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/media_platform/xhs/client.py b/media_platform/xhs/client.py index e8248fc..21eff5b 100644 --- a/media_platform/xhs/client.py +++ b/media_platform/xhs/client.py @@ -198,7 +198,12 @@ class XiaoHongShuClient(AbstractApiClient): Returns: """ - data = {"source_note_id": note_id} + data = { + "source_note_id": note_id, + "image_formats": ["jpg", "webp", "avif"], + "extra": {"need_body_topic": 1}, + "xsec_source": "pc_feed", + } uri = "/api/sns/web/v1/feed" res = await self.post(uri, data) if res and res.get("items"): diff --git a/store/xhs/__init__.py b/store/xhs/__init__.py index 6620c70..689709a 100644 --- a/store/xhs/__init__.py +++ b/store/xhs/__init__.py @@ -32,6 +32,10 @@ async def update_xhs_note(note_item: Dict): image_list: List[Dict] = note_item.get("image_list", []) tag_list: List[Dict] = note_item.get("tag_list", []) + for img in image_list: + if img.get('url_default') != '': + img.update({'url': img.get('url_default')}) + video_url = '' if note_item.get('type') == 'video': videos = note_item.get('video').get('media').get('stream').get('h264')