get_youtube_feed
Fetch videos from your YouTube account's subscriptions, liked videos, watch later list, or viewing history using authenticated browser cookies.
Instructions
Fetch videos from your YouTube account using Chrome cookies. Supports: subscriptions, liked, watch_later, history.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| feed | Yes | Which feed to fetch | |
| limit | No | Max number of videos to return (default 15) |
Implementation Reference
- src/index.ts:176-195 (handler)The tool registration and handler logic for 'get_youtube_feed'. It validates input parameters, calls 'fetchFeed', and processes the result using 'pickVideoFields'.
server.tool( 'get_youtube_feed', 'Fetch videos from your YouTube account using Chrome cookies. Supports: subscriptions, liked, watch_later, history.', { feed: z.enum(['subscriptions', 'liked', 'watch_later', 'history']).describe('Which feed to fetch'), limit: z.number().min(1).max(50).default(15).describe('Max number of videos to return (default 15)'), }, async ({ feed, limit }) => { const depErr = checkDeps(); if (depErr) return errorResult(depErr); try { const result = await fetchFeed(FEED_URLS[feed], limit); const videos = (result.entries || []).map(pickVideoFields); return textResult({ feed, count: videos.length, videos }); } catch (err) { return errorResult(`Error fetching ${feed}: ${err instanceof Error ? err.message : String(err)}`); } } ); - src/ytdlp.ts:39-53 (helper)The core logic that fetches the YouTube feed data by spawning 'yt-dlp' with appropriate arguments.
export function fetchFeed(url: string, limit: number, start = 1): Promise<YtFeedResult> { const args = [ url, '-J', '--flat-playlist', '--playlist-start', String(start), '--playlist-end', String(start + limit - 1), '--cookies-from-browser', getBrowser(), ]; // YouTube-specific extractor arg if (url.includes('youtube.com') || url.includes('youtu.be')) { args.push('--extractor-args', 'youtubetab:approximate_date'); } return spawnYtDlp(args).then((out) => JSON.parse(out)); }