Parcourir la source

fix: 兼容两种数据结构

wuwenyi il y a 3 mois
Parent
commit
f5ada696f2
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  1. 1 1
      facebook/data_handler.py

+ 1 - 1
facebook/data_handler.py

@@ -24,7 +24,7 @@ def get_post_by_doc(response):
     actor = {k: v for k, v in actor.items() if k in user_require_fields}
     image_candidates = jsonpath.jsonpath(data, '$..styles.attachment.all_subattachments.nodes')
     photo_meida_candidate = jsonpath.jsonpath(data, '$..styles.attachment.media')
-    attachments = image_candidates[0] if image_candidates else photo_meida_candidate
+    attachments = [img['media'] for img in image_candidates[0]] if image_candidates else photo_meida_candidate
     result = {
         'text': content_story['message']['text'],
         'attachments': attachments,