douyin_user_videos.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. """获取一页作者作品并自动保存。"""
  2. from __future__ import annotations
  3. import asyncio
  4. import httpx as httpx
  5. from agents.find_agent.support.douyin_user_videos import (
  6. _douyin_user_videos_raw,
  7. _wait_rate_limit as _wait_rate_limit,
  8. )
  9. from agents.find_agent.support.search_persistence import persist_search_payload
  10. from supply_agent.tools import tool
  11. @tool
  12. async def douyin_user_videos(
  13. run_id: str,
  14. account_id: str,
  15. query_reason: str,
  16. source_value: str | None = None,
  17. parent_search_id: int | None = None,
  18. page_no: int = 1,
  19. sort_type: str = "最热",
  20. cursor: str = "",
  21. min_duration_seconds: int = 0,
  22. timeout: float | None = None,
  23. ) -> str:
  24. """获取一页作者作品,创建搜索记录和候选记录并返回对应数据库 ID。"""
  25. result = await _douyin_user_videos_raw(
  26. account_id=account_id,
  27. sort_type=sort_type,
  28. cursor=cursor,
  29. min_duration_seconds=min_duration_seconds,
  30. timeout=timeout,
  31. )
  32. return await asyncio.to_thread(
  33. persist_search_payload,
  34. result,
  35. run_id=run_id,
  36. keyword=f"author:{account_id}",
  37. query_reason=query_reason,
  38. source_type="author",
  39. source_value=source_value or account_id,
  40. parent_search_id=parent_search_id,
  41. cursor=cursor,
  42. page_no=page_no,
  43. provider="internal_blogger",
  44. sort_type=sort_type,
  45. )