Files
pod_trend_agent/graph/sources/pinterest_source.py
T
3218485270 f493bde8a9 POD 趋势感知 Agent:缓存热点模式 + 三图合成 + 热点去重/风格去重 + review 兜底
- 缓存热点批量流程(有采集缓存不触发 Google)
- 简报不足直接从采集缓存生成(轻量补齐)
- 三图合成(模特/印花/底图)+ 底图压缩 <2MB
- 热点去重→风格去重自动切换 + 不适合类目 review 兜底
- 透明背景(background=transparent)+ 提示词清洗(敏感词/背景描述)
- 任务前 basemap 校验 + 模板国家校验 + 模特任务级分配
2026-08-22 14:14:01 +08:00

32 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Pinterest 数据源(可插拔实现,默认不启用)。
Pinterest 官方 API v5 需要商业账号 + access tokenpins:read scope),且 App 需通过 API Review。
未配置或 Review 未过时直接返回空列表(不抛异常),由 config 的 sources 列表控制是否启用。
要启用:在 config.yaml 的 sources 里加入 "pinterest",并填 pinterest.token / board / query。
"""
from typing import Any, Dict, List
from .base import DataSource
class PinterestSource(DataSource):
name = "pinterest"
def fetch(self, country, country_config, global_config):
cfg = (global_config or {}).get("pinterest", {}) or {}
if not cfg.get("enabled", False):
return []
token = cfg.get("token", "")
if not token:
print("[Pinterest] 未配置 tokenpinterest.enabled=true 但未填 token),跳过。")
return []
# 官方 API v5 抓取逻辑(需商业账号 + Review 通过)。
# 这里保留可插拔接口骨架;实际调用示例:
# headers = {"Authorization": f"Bearer {token}"}
# r = requests.get("https://api.pinterest.com/v5/pins/?query=...", headers=headers)
# 因多数项目难以通过 Review,默认返回空,避免阻塞主流程。
print("[Pinterest] 已配置但抓取逻辑未启用(需商业 Review)。返回空。")
return []