"""Pinterest 数据源(可插拔实现,默认不启用)。 Pinterest 官方 API v5 需要商业账号 + access token(pins: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] 未配置 token(pinterest.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 []