zhangliang hai 6 horas
pai
achega
49791c48b7
Modificáronse 1 ficheiros con 9 adicións e 9 borrados
  1. 9 9
      examples/content_finder/tools/douyin_search.py

+ 9 - 9
examples/content_finder/tools/douyin_search.py

@@ -24,7 +24,7 @@ async def douyin_search(
     sort_type: str = "综合排序",
     sort_type: str = "综合排序",
     publish_time: str = "不限",
     publish_time: str = "不限",
     cursor: str = "0",
     cursor: str = "0",
-    account_id: str = "",
+    account_id: str = "771431186",
     timeout: Optional[float] = None,
     timeout: Optional[float] = None,
 ) -> ToolResult:
 ) -> ToolResult:
     """
     """
@@ -66,24 +66,24 @@ async def douyin_search(
         # 格式化输出摘要
         # 格式化输出摘要
         summary_lines = [f"搜索关键词「{keyword}」"]
         summary_lines = [f"搜索关键词「{keyword}」"]
 
 
-        items = data.get("data", {}).get("data", []) if isinstance(data.get("data"), dict) else data.get("data", [])
-        has_more = data.get("has_more", False)
-        cursor_value = data.get("cursor", "")
+        data_block = data.get("data", {}) if isinstance(data.get("data"), dict) else {}
+        items = data_block.get("data", []) if isinstance(data_block.get("data"), list) else []
+        has_more = data_block.get("has_more", False)
+        cursor_value = data_block.get("next_cursor", "")
 
 
         summary_lines.append(f"找到 {len(items)} 条结果" + (f",还有更多(cursor={cursor_value})" if has_more else ""))
         summary_lines.append(f"找到 {len(items)} 条结果" + (f",还有更多(cursor={cursor_value})" if has_more else ""))
         summary_lines.append("")
         summary_lines.append("")
 
 
         # 显示前5条
         # 显示前5条
         for i, item in enumerate(items[:5], 1):
         for i, item in enumerate(items[:5], 1):
-            aweme_info = item.get("aweme_info", {})
-            aweme_id = aweme_info.get("aweme_id", "unknown")
-            desc = aweme_info.get("desc", "无标题")[:50]
+            aweme_id = item.get("aweme_id", "unknown")
+            desc = (item.get("desc") or item.get("item_title") or "无标题")[:50]
 
 
-            author = aweme_info.get("author", {})
+            author = item.get("author", {})
             author_name = author.get("nickname", "未知作者")
             author_name = author.get("nickname", "未知作者")
             author_id = author.get("sec_uid", "")
             author_id = author.get("sec_uid", "")
 
 
-            stats = aweme_info.get("statistics", {})
+            stats = item.get("statistics", {})
             digg_count = stats.get("digg_count", 0)
             digg_count = stats.get("digg_count", 0)
             comment_count = stats.get("comment_count", 0)
             comment_count = stats.get("comment_count", 0)
             share_count = stats.get("share_count", 0)
             share_count = stats.get("share_count", 0)