Skip to content

Commit 1469e9c

Browse files
authored
feat(youtube): add captions, trending, and video categories tools with enhanced API coverage (#3060)
* feat(youtube): add captions, trending, and video categories tools with enhanced API coverage * fix(youtube): remove captions tool (requires OAuth), fix tinybird defaults, encode pageToken
1 parent 06d7ce7 commit 1469e9c

File tree

14 files changed

+1019
-209
lines changed

14 files changed

+1019
-209
lines changed

apps/docs/content/docs/en/tools/youtube.mdx

Lines changed: 196 additions & 85 deletions
Large diffs are not rendered by default.

apps/sim/blocks/blocks/youtube.ts

Lines changed: 125 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const YouTubeBlock: BlockConfig<YouTubeResponse> = {
99
description: 'Interact with YouTube videos, channels, and playlists',
1010
authMode: AuthMode.ApiKey,
1111
longDescription:
12-
'Integrate YouTube into the workflow. Can search for videos, get video details, get channel information, get all videos from a channel, get channel playlists, get playlist items, find related videos, and get video comments.',
12+
'Integrate YouTube into the workflow. Can search for videos, get trending videos, get video details, get video categories, get channel information, get all videos from a channel, get channel playlists, get playlist items, and get video comments.',
1313
docsLink: 'https://docs.sim.ai/tools/youtube',
1414
category: 'tools',
1515
bgColor: '#FF0000',
@@ -21,7 +21,9 @@ export const YouTubeBlock: BlockConfig<YouTubeResponse> = {
2121
type: 'dropdown',
2222
options: [
2323
{ label: 'Search Videos', id: 'youtube_search' },
24+
{ label: 'Get Trending Videos', id: 'youtube_trending' },
2425
{ label: 'Get Video Details', id: 'youtube_video_details' },
26+
{ label: 'Get Video Categories', id: 'youtube_video_categories' },
2527
{ label: 'Get Channel Info', id: 'youtube_channel_info' },
2628
{ label: 'Get Channel Videos', id: 'youtube_channel_videos' },
2729
{ label: 'Get Channel Playlists', id: 'youtube_channel_playlists' },
@@ -49,13 +51,33 @@ export const YouTubeBlock: BlockConfig<YouTubeResponse> = {
4951
integer: true,
5052
condition: { field: 'operation', value: 'youtube_search' },
5153
},
54+
{
55+
id: 'pageToken',
56+
title: 'Page Token',
57+
type: 'short-input',
58+
placeholder: 'Token for pagination (from nextPageToken)',
59+
condition: { field: 'operation', value: 'youtube_search' },
60+
},
5261
{
5362
id: 'channelId',
5463
title: 'Filter by Channel ID',
5564
type: 'short-input',
5665
placeholder: 'Filter results to a specific channel',
5766
condition: { field: 'operation', value: 'youtube_search' },
5867
},
68+
{
69+
id: 'eventType',
70+
title: 'Live Stream Filter',
71+
type: 'dropdown',
72+
options: [
73+
{ label: 'All Videos', id: '' },
74+
{ label: 'Currently Live', id: 'live' },
75+
{ label: 'Upcoming Streams', id: 'upcoming' },
76+
{ label: 'Past Streams', id: 'completed' },
77+
],
78+
value: () => '',
79+
condition: { field: 'operation', value: 'youtube_search' },
80+
},
5981
{
6082
id: 'publishedAfter',
6183
title: 'Published After',
@@ -131,7 +153,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
131153
id: 'videoCategoryId',
132154
title: 'Category ID',
133155
type: 'short-input',
134-
placeholder: '10 for Music, 20 for Gaming',
156+
placeholder: 'Use Get Video Categories to find IDs',
135157
condition: { field: 'operation', value: 'youtube_search' },
136158
},
137159
{
@@ -163,7 +185,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
163185
title: 'Region Code',
164186
type: 'short-input',
165187
placeholder: 'US, GB, JP',
166-
condition: { field: 'operation', value: 'youtube_search' },
188+
condition: {
189+
field: 'operation',
190+
value: ['youtube_search', 'youtube_trending', 'youtube_video_categories'],
191+
},
167192
},
168193
{
169194
id: 'relevanceLanguage',
@@ -184,6 +209,31 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
184209
value: () => 'moderate',
185210
condition: { field: 'operation', value: 'youtube_search' },
186211
},
212+
// Get Trending Videos operation inputs
213+
{
214+
id: 'maxResults',
215+
title: 'Max Results',
216+
type: 'slider',
217+
min: 1,
218+
max: 50,
219+
step: 1,
220+
integer: true,
221+
condition: { field: 'operation', value: 'youtube_trending' },
222+
},
223+
{
224+
id: 'videoCategoryId',
225+
title: 'Category ID',
226+
type: 'short-input',
227+
placeholder: 'Use Get Video Categories to find IDs',
228+
condition: { field: 'operation', value: 'youtube_trending' },
229+
},
230+
{
231+
id: 'pageToken',
232+
title: 'Page Token',
233+
type: 'short-input',
234+
placeholder: 'Token for pagination (from nextPageToken)',
235+
condition: { field: 'operation', value: 'youtube_trending' },
236+
},
187237
// Get Video Details operation inputs
188238
{
189239
id: 'videoId',
@@ -193,6 +243,14 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
193243
required: true,
194244
condition: { field: 'operation', value: 'youtube_video_details' },
195245
},
246+
// Get Video Categories operation inputs
247+
{
248+
id: 'hl',
249+
title: 'Language',
250+
type: 'short-input',
251+
placeholder: 'en, es, fr (for category names)',
252+
condition: { field: 'operation', value: 'youtube_video_categories' },
253+
},
196254
// Get Channel Info operation inputs
197255
{
198256
id: 'channelId',
@@ -241,6 +299,13 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
241299
value: () => 'date',
242300
condition: { field: 'operation', value: 'youtube_channel_videos' },
243301
},
302+
{
303+
id: 'pageToken',
304+
title: 'Page Token',
305+
type: 'short-input',
306+
placeholder: 'Token for pagination (from nextPageToken)',
307+
condition: { field: 'operation', value: 'youtube_channel_videos' },
308+
},
244309
// Get Channel Playlists operation inputs
245310
{
246311
id: 'channelId',
@@ -260,6 +325,13 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
260325
integer: true,
261326
condition: { field: 'operation', value: 'youtube_channel_playlists' },
262327
},
328+
{
329+
id: 'pageToken',
330+
title: 'Page Token',
331+
type: 'short-input',
332+
placeholder: 'Token for pagination (from nextPageToken)',
333+
condition: { field: 'operation', value: 'youtube_channel_playlists' },
334+
},
263335
// Get Playlist Items operation inputs
264336
{
265337
id: 'playlistId',
@@ -279,6 +351,13 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
279351
integer: true,
280352
condition: { field: 'operation', value: 'youtube_playlist_items' },
281353
},
354+
{
355+
id: 'pageToken',
356+
title: 'Page Token',
357+
type: 'short-input',
358+
placeholder: 'Token for pagination (from nextPageToken)',
359+
condition: { field: 'operation', value: 'youtube_playlist_items' },
360+
},
282361
// Get Video Comments operation inputs
283362
{
284363
id: 'videoId',
@@ -309,6 +388,13 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
309388
value: () => 'relevance',
310389
condition: { field: 'operation', value: 'youtube_comments' },
311390
},
391+
{
392+
id: 'pageToken',
393+
title: 'Page Token',
394+
type: 'short-input',
395+
placeholder: 'Token for pagination (from nextPageToken)',
396+
condition: { field: 'operation', value: 'youtube_comments' },
397+
},
312398
// API Key (common to all operations)
313399
{
314400
id: 'apiKey',
@@ -321,13 +407,15 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
321407
],
322408
tools: {
323409
access: [
324-
'youtube_search',
325-
'youtube_video_details',
326410
'youtube_channel_info',
327-
'youtube_channel_videos',
328411
'youtube_channel_playlists',
329-
'youtube_playlist_items',
412+
'youtube_channel_videos',
330413
'youtube_comments',
414+
'youtube_playlist_items',
415+
'youtube_search',
416+
'youtube_trending',
417+
'youtube_video_categories',
418+
'youtube_video_details',
331419
],
332420
config: {
333421
tool: (params) => {
@@ -339,8 +427,12 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
339427
switch (params.operation) {
340428
case 'youtube_search':
341429
return 'youtube_search'
430+
case 'youtube_trending':
431+
return 'youtube_trending'
342432
case 'youtube_video_details':
343433
return 'youtube_video_details'
434+
case 'youtube_video_categories':
435+
return 'youtube_video_categories'
344436
case 'youtube_channel_info':
345437
return 'youtube_channel_info'
346438
case 'youtube_channel_videos':
@@ -363,16 +455,19 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
363455
// Search Videos
364456
query: { type: 'string', description: 'Search query' },
365457
maxResults: { type: 'number', description: 'Maximum number of results' },
458+
pageToken: { type: 'string', description: 'Page token for pagination' },
366459
// Search Filters
367460
publishedAfter: { type: 'string', description: 'Published after date (RFC 3339)' },
368461
publishedBefore: { type: 'string', description: 'Published before date (RFC 3339)' },
369462
videoDuration: { type: 'string', description: 'Video duration filter' },
370463
videoCategoryId: { type: 'string', description: 'YouTube category ID' },
371464
videoDefinition: { type: 'string', description: 'Video quality filter' },
372465
videoCaption: { type: 'string', description: 'Caption availability filter' },
466+
eventType: { type: 'string', description: 'Live stream filter (live/upcoming/completed)' },
373467
regionCode: { type: 'string', description: 'Region code (ISO 3166-1)' },
374468
relevanceLanguage: { type: 'string', description: 'Language code (ISO 639-1)' },
375469
safeSearch: { type: 'string', description: 'Safe search level' },
470+
hl: { type: 'string', description: 'Language for category names' },
376471
// Video Details & Comments
377472
videoId: { type: 'string', description: 'YouTube video ID' },
378473
// Channel Info
@@ -384,7 +479,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
384479
order: { type: 'string', description: 'Sort order' },
385480
},
386481
outputs: {
387-
// Search Videos & Playlist Items
482+
// Search Videos, Trending, Playlist Items, Captions, Categories
388483
items: { type: 'json', description: 'List of items returned' },
389484
totalResults: { type: 'number', description: 'Total number of results' },
390485
nextPageToken: { type: 'string', description: 'Token for next page' },
@@ -399,11 +494,33 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
399494
viewCount: { type: 'number', description: 'View count' },
400495
likeCount: { type: 'number', description: 'Like count' },
401496
commentCount: { type: 'number', description: 'Comment count' },
497+
favoriteCount: { type: 'number', description: 'Favorite count' },
402498
thumbnail: { type: 'string', description: 'Thumbnail URL' },
403499
tags: { type: 'json', description: 'Video tags' },
500+
categoryId: { type: 'string', description: 'Video category ID' },
501+
definition: { type: 'string', description: 'Video definition (hd/sd)' },
502+
caption: { type: 'string', description: 'Has captions (true/false)' },
503+
licensedContent: { type: 'boolean', description: 'Is licensed content' },
504+
privacyStatus: { type: 'string', description: 'Privacy status' },
505+
liveBroadcastContent: { type: 'string', description: 'Live broadcast status' },
506+
defaultLanguage: { type: 'string', description: 'Default language' },
507+
defaultAudioLanguage: { type: 'string', description: 'Default audio language' },
508+
// Live Streaming Details
509+
isLiveContent: { type: 'boolean', description: 'Whether video is/was a live stream' },
510+
scheduledStartTime: { type: 'string', description: 'Scheduled start time for live streams' },
511+
actualStartTime: { type: 'string', description: 'Actual start time of live stream' },
512+
actualEndTime: { type: 'string', description: 'End time of live stream' },
513+
concurrentViewers: { type: 'number', description: 'Current viewers (live only)' },
514+
activeLiveChatId: { type: 'string', description: 'Live chat ID' },
404515
// Channel Info
405516
subscriberCount: { type: 'number', description: 'Subscriber count' },
406517
videoCount: { type: 'number', description: 'Total video count' },
407518
customUrl: { type: 'string', description: 'Channel custom URL' },
519+
country: { type: 'string', description: 'Channel country' },
520+
uploadsPlaylistId: { type: 'string', description: 'Uploads playlist ID' },
521+
bannerImageUrl: { type: 'string', description: 'Channel banner URL' },
522+
hiddenSubscriberCount: { type: 'boolean', description: 'Is subscriber count hidden' },
523+
// Video Categories
524+
assignable: { type: 'boolean', description: 'Whether category can be assigned' },
408525
},
409526
}

apps/sim/tools/registry.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,8 @@ import {
16481648
youtubeCommentsTool,
16491649
youtubePlaylistItemsTool,
16501650
youtubeSearchTool,
1651+
youtubeTrendingTool,
1652+
youtubeVideoCategoriesTool,
16511653
youtubeVideoDetailsTool,
16521654
} from '@/tools/youtube'
16531655
import {
@@ -1982,13 +1984,15 @@ export const tools: Record<string, ToolConfig> = {
19821984
typeform_create_form: typeformCreateFormTool,
19831985
typeform_update_form: typeformUpdateFormTool,
19841986
typeform_delete_form: typeformDeleteFormTool,
1985-
youtube_search: youtubeSearchTool,
1986-
youtube_video_details: youtubeVideoDetailsTool,
19871987
youtube_channel_info: youtubeChannelInfoTool,
1988-
youtube_playlist_items: youtubePlaylistItemsTool,
1989-
youtube_comments: youtubeCommentsTool,
1990-
youtube_channel_videos: youtubeChannelVideosTool,
19911988
youtube_channel_playlists: youtubeChannelPlaylistsTool,
1989+
youtube_channel_videos: youtubeChannelVideosTool,
1990+
youtube_comments: youtubeCommentsTool,
1991+
youtube_playlist_items: youtubePlaylistItemsTool,
1992+
youtube_search: youtubeSearchTool,
1993+
youtube_trending: youtubeTrendingTool,
1994+
youtube_video_categories: youtubeVideoCategoriesTool,
1995+
youtube_video_details: youtubeVideoDetailsTool,
19921996
notion_read: notionReadTool,
19931997
notion_read_database: notionReadDatabaseTool,
19941998
notion_write: notionWriteTool,

0 commit comments

Comments
 (0)