Browse Source

修复请求搜索结果的问题

刘立冬 4 weeks ago
parent
commit
40df541dd1
1 changed files with 24 additions and 3 deletions
  1. 24 3
      sug_v6_1_2_115.py

+ 24 - 3
sug_v6_1_2_115.py

@@ -498,6 +498,27 @@ def process_note_data(note: dict) -> Post:
     interact_info = note_card.get("interact_info", {})
     user_info = note_card.get("user", {})
 
+    # ========== 调试日志 START ==========
+    note_id = note.get("id", "")
+    raw_title = note_card.get("display_title")  # 不提供默认值
+    raw_body = note_card.get("desc")
+    raw_type = note_card.get("type")
+
+    # 打印原始值类型和内容
+    print(f"\n[DEBUG] 处理帖子 {note_id}:")
+    print(f"  raw_title 类型: {type(raw_title).__name__}, 值: {repr(raw_title)}")
+    print(f"  raw_body 类型: {type(raw_body).__name__}, 值: {repr(raw_body)[:100] if raw_body else repr(raw_body)}")
+    print(f"  raw_type 类型: {type(raw_type).__name__}, 值: {repr(raw_type)}")
+
+    # 检查是否为 None
+    if raw_title is None:
+        print(f"  ⚠️  WARNING: display_title 是 None!")
+    if raw_body is None:
+        print(f"  ⚠️  WARNING: desc 是 None!")
+    if raw_type is None:
+        print(f"  ⚠️  WARNING: type 是 None!")
+    # ========== 调试日志 END ==========
+
     # 提取图片URL - 使用新的字段名 image_url
     images = []
     for img in image_list:
@@ -517,9 +538,9 @@ def process_note_data(note: dict) -> Post:
             video_url = video_info.get("media", {}).get("stream", {}).get("h264", [{}])[0].get("master_url", "")
 
     return Post(
-        note_id=note.get("id", ""),
-        title=note_card.get("display_title", ""),
-        body_text=note_card.get("desc", ""),
+        note_id=note.get("id") or "",
+        title=note_card.get("display_title") or "",
+        body_text=note_card.get("desc") or "",
         type=note_type,
         images=images,
         video=video_url,