YouTube

search-videos

youtube.com
InstallationInstalls just this skill for your agent
Side effectread
Authnone
Needsnavigate · evaluate
Summary

Search YouTube videos by keyword, returning title, channel, views and length.

Params
{"query":"string (search text)"}
Returns
{"count":"int","query":"string","results":"array of { videoId, title, channel, url, views, published, length }"}
SKILL.md45 lines

Intent

Search YouTube videos by keyword. Navigates the results page with hl=en and reads the embedded ytInitialData JSON that YouTube ships in the page (no API key needed). Param: query (search text). Returns {count, results:[{videoId, title, channel, url, views, published, length}]}. The views, published and length fields are the display strings YouTube renders (for exact view counts on a single video, use youtube.com/get-video).

Execute

  1. navigate → https://www.youtube.com/results?search_query={{query|encode}}&hl=en
  2. evaluate the Extractor below with params. It does the in-page work and returns the JSON in returns.

Extractor

( async (root, params) => { const yt = window.ytInitialData; if (!yt) return { count: 0, results: [], error: 'no ytInitialData (page not ready)' }; const vids = []; const seen = new Set(); const walk = (o) => { if (!o || typeof o !== 'object') return; if (o.videoRenderer && o.videoRenderer.videoId) { const v = o.videoRenderer; const id = v.videoId; if (!seen.has(id)) { seen.add(id); const runs = (v.title && v.title.runs) || []; vids.push({ videoId: id, title: runs.map(r => r.text).join(''), channel: (v.ownerText && v.ownerText.runs && v.ownerText.runs[0] && v.ownerText.runs[0].text) || (v.longBylineText && v.longBylineText.runs && v.longBylineText.runs[0] && v.longBylineText.runs[0].text) || null, url: 'https://www.youtube.com/watch?v=' + id, views: (v.viewCountText && (v.viewCountText.simpleText || (v.viewCountText.runs || []).map(r => r.text).join(''))) || null, published: (v.publishedTimeText && v.publishedTimeText.simpleText) || null, length: (v.lengthText && v.lengthText.simpleText) || null }); } } for (const k in o) walk(o[k]); }; walk(yt); return { count: vids.length, query: String((params && params.query) || ''), results: vids }; } )

Success assertion

{
  "expr": "typeof result === 'object' && Array.isArray(result.results)",
  "type": "value"
}