OpenSenseNova/SenseNova-Skills / skills/sn-search-social-en
sn-search-social-en
Verified用于搜索英文社交平台,包括 Reddit 帖子、Twitter/X 推文和 YouTube 视频。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 3.0 KB |
| requirements.txt | manifest | 12 B |
| scripts/reddit_search.py | script | 2.8 KB |
| scripts/search_utils.py | script | 4.3 KB |
| scripts/twitter_search.py | script | 2.5 KB |
| scripts/youtube_search.py | script | 2.2 KB |
scripts/youtube_search.py
View on GitHub#!/usr/bin/env python3
"""YouTube 视频搜索。通过 YouTube Data API v3。"""
import sys
from search_utils import build_parser, get_client, get_key, make_item, make_result, print_json
API_URL = "https://www.googleapis.com/youtube/v3/search"
def search(query: str, limit: int, api_key: str | None = None, order: str = "relevance") -> list[dict]:
"""执行 YouTube 搜索。"""
if not api_key:
raise ValueError("需要 YOUTUBE_API_KEY 环境变量。请到 Google Cloud Console 创建 API key。")
params = {
"part": "snippet",
"q": query,
"type": "video",
"maxResults": min(limit, 50),
"order": order,
"key": api_key,
}
with get_client() as client:
resp = client.get(API_URL, params=params)
resp.raise_for_status()
data = resp.json()
items = []
for result in data.get("items", [])[:limit]:
snippet = result.get("snippet", {})
video_id = result.get("id", {}).get("videoId", "")
items.append(make_item(
title=snippet.get("title", ""),
url=f"https://www.youtube.com/watch?v={video_id}" if video_id else "",
snippet=snippet.get("description", ""),
channel=snippet.get("channelTitle"),
published_at=snippet.get("publishedAt"),
thumbnail=snippet.get("thumbnails", {}).get("default", {}).get("url"),
))
return items
def main():
parser = build_parser("搜索 YouTube 视频")
parser.add_argument("--api-key", help="YouTube API Key(也可通过 YOUTUBE_API_KEY 环境变量设置)")
parser.add_argument("--order", default="relevance",
choices=["relevance", "date", "viewCount", "rating"],
help="排序方式(默认 relevance)")
args = parser.parse_args()
api_key = get_key("YOUTUBE_API_KEY", args.api_key)
try:
items = search(args.query, args.limit, api_key, args.order)
print_json(make_result(True, args.query, "youtube", items))
except Exception as e:
print_json(make_result(False, args.query, "youtube", [], str(e)))
sys.exit(1)
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |