AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(youtube): shorter Search form, tabbed channel and playlist lookups, and plain field help (#15813)
Talal Jaber93556a3770f2
diff --git a/packages/pieces/community/youtube/package.json b/packages/pieces/community/youtube/package.jsonindex 53ff2599169..84b628e1f4e 100644--- a/packages/pieces/community/youtube/package.json+++ b/packages/pieces/community/youtube/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-youtube",- "version": "0.7.0",+ "version": "0.8.0","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","dependencies": {diff --git a/packages/pieces/community/youtube/src/lib/actions/download-caption.ts b/packages/pieces/community/youtube/src/lib/actions/download-caption.tsindex da289530fe7..d4ae2085a23 100644--- a/packages/pieces/community/youtube/src/lib/actions/download-caption.ts+++ b/packages/pieces/community/youtube/src/lib/actions/download-caption.ts@@ -11,18 +11,19 @@ export const youtubeDownloadCaptionAction = createAction({classification: 'READ',displayName: 'Download Caption',description:- 'Returns a caption track text by caption ID using the YouTube captions.download endpoint. Requires permission to edit the video, so it only works for captions on videos the authenticated user owns. Auto-generated (asr) caption tracks cannot be downloaded and will return a 403.',+ "Download a caption track's text. Works only on videos you own.",audience: 'human',aiMetadata: { description: 'Downloads the raw text of one YouTube caption track identified by its caption ID, optionally emitting it as SRT, VTT, SBV, SCC, or TTML and machine-translating it into a target language code. Use it after List Captions has supplied the caption ID; the endpoint only serves tracks on videos the authenticated account can edit, and auto-generated (asr) tracks are refused with a 403. Read-only and idempotent.', idempotent: true },props: {captionId: Property.ShortText({displayName: 'Caption ID',- description: 'The caption track ID to download.',+ description: "From List Captions. Auto-generated tracks can't be downloaded.",required: true,}),format: Property.StaticDropdown({- displayName: 'Format (tfmt)',- description: 'Optional output format for the caption track.',+ displayName: 'Format',+ description:+ "File format of the captions. Empty: the track's original format.",required: false,options: {options: [@@ -35,16 +36,17 @@ export const youtubeDownloadCaptionAction = createAction({},}),targetLanguage: Property.ShortText({- displayName: 'Target Language (tlang)',- description:- 'Optional language code for machine-translated captions (for example: en, es, fr).',+ displayName: 'Target Language',+ description: 'Translate the captions into this language code.',+ placeholder: 'es',required: false,}),onBehalfOfContentOwner: Property.ShortText({displayName: 'On Behalf Of Content Owner',description:- 'Optional. Intended for YouTube CMS content partners acting on behalf of a content owner.',+ 'Content owner ID, for YouTube partners who manage many channels.',required: false,+ advanced: true,}),},async run(context) {diff --git a/packages/pieces/community/youtube/src/lib/actions/get-channel.ts b/packages/pieces/community/youtube/src/lib/actions/get-channel.tsindex ca2e73b4816..2961d9523fc 100644--- a/packages/pieces/community/youtube/src/lib/actions/get-channel.ts+++ b/packages/pieces/community/youtube/src/lib/actions/get-channel.ts@@ -9,7 +9,7 @@ export const youtubeGetChannelAction = createAction({name: 'get_channel',classification: 'READ',displayName: 'Get Channel',- description: 'Retrieve a channel by ID or handle, including its subscriber and view counts.',+ description: "Get a channel's details, including subscriber and view counts.",audience: 'human',aiMetadata: {description:@@ -19,12 +19,14 @@ export const youtubeGetChannelAction = createAction({props: {channelId: Property.ShortText({displayName: 'Channel ID',- description: 'Channel ID starting with `UC`. Leave blank if using a handle.',+ description: 'Starts with UC. Leave empty to look the channel up by Handle.',+ placeholder: 'UC_x5XG1OV2P6uZZ5FSM9Ttw',required: false,}),handle: Property.ShortText({displayName: 'Handle',- description: 'Channel handle such as `@GoogleDevelopers`. Ignored when a Channel ID is given.',+ description: 'The @name on the channel page. Used only when Channel ID is empty.',+ placeholder: '@GoogleDevelopers',required: false,}),},diff --git a/packages/pieces/community/youtube/src/lib/actions/get-video.ts b/packages/pieces/community/youtube/src/lib/actions/get-video.tsindex 098a0f546db..b08e3b53232 100644--- a/packages/pieces/community/youtube/src/lib/actions/get-video.ts+++ b/packages/pieces/community/youtube/src/lib/actions/get-video.ts@@ -20,7 +20,8 @@ export const youtubeGetVideoAction = createAction({videoIds: Property.ShortText({displayName: 'Video ID',description:- 'The video ID, or a comma-separated list of IDs. This is the `v` parameter in a YouTube URL (e.g. `dQw4w9WgXcQ`).',+ 'A video ID, or several separated by commas: the v= value in the URL.',+ placeholder: 'dQw4w9WgXcQ',required: true,}),},diff --git a/packages/pieces/community/youtube/src/lib/actions/list-captions.ts b/packages/pieces/community/youtube/src/lib/actions/list-captions.tsindex d91d456e5e0..c298727d39f 100644--- a/packages/pieces/community/youtube/src/lib/actions/list-captions.ts+++ b/packages/pieces/community/youtube/src/lib/actions/list-captions.ts@@ -14,26 +14,29 @@ export const youtubeListCaptionsAction = createAction({classification: 'SEARCH',displayName: 'List Captions',description:- 'Returns caption tracks for a specific YouTube video using the captions.list endpoint.',+ "List a video's caption tracks, with the IDs Download Caption needs.",audience: 'human',aiMetadata: { description: 'Lists the caption tracks attached to a single YouTube video, covering every track on that video or only the ones named by a comma-separated list of caption IDs. Use it to discover which languages a video is captioned in and to obtain the caption ID that the Download Caption action requires. The video ID is mandatory. Read-only and idempotent.', idempotent: true },props: {videoId: Property.ShortText({displayName: 'Video ID',- description: 'The YouTube video ID to list caption tracks for.',+ description: "The v= value in the video's URL.",+ placeholder: 'dQw4w9WgXcQ',required: true,}),captionIds: Property.ShortText({displayName: 'Caption IDs',description:- 'Optional comma-separated caption track IDs to retrieve (for example: id1,id2).',+ 'Only return these tracks. Separate caption IDs with commas.',required: false,+ advanced: true,}),onBehalfOfContentOwner: Property.ShortText({displayName: 'On Behalf Of Content Owner',description:- 'Optional. Intended for YouTube CMS content partners acting on behalf of a content owner.',+ 'Content owner ID, for YouTube partners who manage many channels.',required: false,+ advanced: true,}),},async run(context) {diff --git a/packages/pieces/community/youtube/src/lib/actions/list-comments.ts b/packages/pieces/community/youtube/src/lib/actions/list-comments.tsindex 713e6220017..8f15f044301 100644--- a/packages/pieces/community/youtube/src/lib/actions/list-comments.ts+++ b/packages/pieces/community/youtube/src/lib/actions/list-comments.ts@@ -19,12 +19,13 @@ export const youtubeListCommentsAction = createAction({props: {videoId: Property.ShortText({displayName: 'Video ID',- description: 'The `v` parameter in a YouTube URL (e.g. `dQw4w9WgXcQ`).',+ description: "The v= value in the video's URL.",+ placeholder: 'dQw4w9WgXcQ',required: true,}),order: Property.StaticDropdown({displayName: 'Order',- description: 'Comment ordering.',+ description: 'How to sort the comments. Empty: newest first.',required: false,options: {options: [@@ -35,14 +36,19 @@ export const youtubeListCommentsAction = createAction({}),maxResults: Property.Number({displayName: 'Max Results',- description: 'Number of threads to return (1-100, default 20).',+ description: 'How many comment threads to return, up to 100.',+ display: 'stepper',+ min: 1,+ max: 100,+ step: 1,required: false,defaultValue: 20,}),pageToken: Property.ShortText({displayName: 'Page Token',- description: 'Token from a previous response, to fetch the next page.',+ description: 'The nextPageToken from an earlier run, to get the next page.',required: false,+ advanced: true,}),},async run(context) {diff --git a/packages/pieces/community/youtube/src/lib/actions/list-playlist-items.ts b/packages/pieces/community/youtube/src/lib/actions/list-playlist-items.tsindex 0c8c18d9ec4..e76cf19d7bd 100644--- a/packages/pieces/community/youtube/src/lib/actions/list-playlist-items.ts+++ b/packages/pieces/community/youtube/src/lib/actions/list-playlist-items.ts@@ -11,40 +11,48 @@ export const youtubeListPlaylistItemsAction = createAction({classification: 'SEARCH',displayName: 'List Playlist Items',description:- 'Returns videos in a YouTube playlist. You can filter by playlist ID or by specific item IDs.',+ 'List the videos in a playlist, or fetch specific playlist items.',audience: 'human',aiMetadata: { description: 'Lists the entries of a YouTube playlist in one of two modes: pass a playlist ID to page through that whole playlist (optionally narrowed to entries containing one video ID), or pass a comma-separated list of playlist item IDs to fetch only those entries. Exactly one of the two is required, supplying both or filtering by video without a playlist ID fails validation, and Max Results is capped at 50 with further pages fetched via the page token. Run Search with type Playlist first when the playlist ID is unknown; read-only and idempotent.', idempotent: true },props: {playlistId: Property.ShortText({displayName: 'Playlist ID',description:- 'The ID of the playlist whose items you want to list. You can find this in the playlist URL — it is the value of the `list` parameter (e.g. `PLbpi6ZahtOH6Ar_3GPy3workLYfGa7mGm`). Either this or Item IDs is required.',+ "The list= value in the playlist's URL. Leave empty to use Item IDs.",+ placeholder: 'PLbpi6ZahtOH6Ar_3GPy3workLYfGa7mGm',required: false,}),itemIds: Property.ShortText({displayName: 'Item IDs',description:- 'A comma-separated list of specific playlist item IDs to retrieve (e.g. `id1,id2,id3`). Use this instead of Playlist ID if you already know the exact item IDs you want.',+ 'Comma-separated playlist item IDs, used instead of Playlist ID.',required: false,}),maxResults: Property.Number({displayName: 'Max Results',description:- 'Maximum number of items to return. Acceptable values are 0–50. Defaults to 50.',+ 'How many items to return, up to 50.',+ display: 'stepper',+ min: 0,+ max: 50,+ step: 1,required: false,defaultValue: 50,}),pageToken: Property.ShortText({displayName: 'Page Token',description:- 'Use this to retrieve a specific page of results. The previous response includes a `nextPageToken` value — paste it here to get the next page.',+ 'The nextPageToken from an earlier run, to get the next page.',required: false,+ advanced: true,}),videoId: Property.ShortText({- displayName: 'Filter by Video ID',+ displayName: 'Video ID',description:- 'Only return playlist items that contain this video. Leave blank to return all items. The video ID is the `v` parameter in a YouTube URL (e.g. `dQw4w9WgXcQ`).',+ 'Only return entries for this video. Needs a Playlist ID.',+ placeholder: 'dQw4w9WgXcQ',required: false,+ advanced: true,}),},async run(context) {@@ -61,7 +69,7 @@ export const youtubeListPlaylistItemsAction = createAction({if (videoId && !playlistId) {throw new Error(- 'Filter by Video ID can only be used together with a Playlist ID.'+ 'Video ID can only be used together with a Playlist ID.');}diff --git a/packages/pieces/community/youtube/src/lib/actions/list-playlists.ts b/packages/pieces/community/youtube/src/lib/actions/list-playlists.tsindex 541302f5932..7d622f1781d 100644--- a/packages/pieces/community/youtube/src/lib/actions/list-playlists.ts+++ b/packages/pieces/community/youtube/src/lib/actions/list-playlists.ts@@ -19,19 +19,25 @@ export const youtubeListPlaylistsAction = createAction({props: {channelId: Property.ShortText({displayName: 'Channel ID',- description: 'Channel ID starting with `UC`.',+ description: "The channel's ID, which starts with UC.",+ placeholder: 'UC_x5XG1OV2P6uZZ5FSM9Ttw',required: true,}),maxResults: Property.Number({displayName: 'Max Results',- description: 'Number of playlists to return (1-50, default 25).',+ description: 'How many playlists to return, up to 50.',+ display: 'stepper',+ min: 1,+ max: 50,+ step: 1,required: false,defaultValue: 25,}),pageToken: Property.ShortText({displayName: 'Page Token',- description: 'Token from a previous response, to fetch the next page.',+ description: 'The nextPageToken from an earlier run, to get the next page.',required: false,+ advanced: true,}),},async run(context) {diff --git a/packages/pieces/community/youtube/src/lib/actions/search.ts b/packages/pieces/community/youtube/src/lib/actions/search.tsindex 4f4135415a2..94d715046d6 100644--- a/packages/pieces/community/youtube/src/lib/actions/search.ts+++ b/packages/pieces/community/youtube/src/lib/actions/search.ts@@ -10,21 +10,21 @@ export const youtubeSearchAction = createAction({name: 'search',classification: 'SEARCH',displayName: 'Search',- description:- 'Search YouTube videos, channels, and playlists using the YouTube Data API search.list endpoint.',+ description: 'Search YouTube for videos, channels or playlists.',audience: 'human',aiMetadata: { description: 'Runs a YouTube search.list query across videos, channels, and playlists at once or restricted to a single resource type, and can instead be scoped to uploads owned by the authenticated account (For Mine), a CMS content owner, or the developer project. Use it to turn a free-text query, channel, date range, region, or topic into video, channel, or playlist IDs for later steps; prefer List Playlist Items when the playlist ID is already known. Video-only filters such as duration, definition, caption, event type, and location require Type to be Video, and Location must be paired with Location Radius. Read-only and idempotent.', idempotent: true },props: {query: Property.ShortText({displayName: 'Query',description:- 'Search term. Supports operators like OR (`|`) and NOT (`-`) as supported by YouTube search.',+ 'Words to search for. Use | for OR and - to leave a word out.',+ placeholder: 'cooking tutorial',required: false,}),type: Property.StaticDropdown({displayName: 'Type',description:- 'Restrict results to a resource type. Use "Any" to search videos, channels, and playlists.',+ 'Which kind of result to return. Video-only filters need Video.',required: false,defaultValue: 'any',options: {@@ -39,36 +39,43 @@ export const youtubeSearchAction = createAction({forContentOwner: Property.Checkbox({displayName: 'For Content Owner',description:- 'Restrict results to videos owned by the content owner set in On Behalf Of Content Owner.',+ 'Only videos of the owner set in On Behalf Of Content Owner.',required: false,+ advanced: true,}),forDeveloper: Property.Checkbox({displayName: 'For Developer',description:- 'Restrict results to videos uploaded via your developer project.',+ "Only videos uploaded through this connection's Google Cloud app.",required: false,+ advanced: true,}),forMine: Property.Checkbox({displayName: 'For Mine',description:- 'Restrict results to videos owned by the authenticated user.',+ 'Only videos on the connected account. Needs Type set to Video.',required: false,+ advanced: true,}),onBehalfOfContentOwner: Property.ShortText({displayName: 'On Behalf Of Content Owner',description:- 'Required when For Content Owner is enabled. Intended for YouTube CMS content partners.',+ 'Content owner ID, for YouTube partners who manage many channels.',required: false,+ advanced: true,}),channelId: Property.ShortText({displayName: 'Channel ID',- description: 'Only return resources from this channel.',+ description:+ 'Only return results from this channel. The ID starts with UC.',+ placeholder: 'UC_x5XG1OV2P6uZZ5FSM9Ttw',required: false,}),channelType: Property.StaticDropdown({displayName: 'Channel Type',- description: 'Restrict channel searches to a specific channel type.',+ description: 'Show returns only channels that publish TV shows.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },@@ -93,7 +100,9 @@ export const youtubeSearchAction = createAction({}),safeSearch: Property.StaticDropdown({displayName: 'Safe Search',+ description: 'Whether to leave out restricted content.',required: false,+ advanced: true,defaultValue: 'moderate',options: {options: [@@ -105,46 +114,60 @@ export const youtubeSearchAction = createAction({}),publishedAfter: Property.DateTime({displayName: 'Published After',- description:- 'Only include resources created at or after this datetime (RFC 3339).',+ description: 'Only results published on or after this date.',required: false,}),publishedBefore: Property.DateTime({displayName: 'Published Before',- description:- 'Only include resources created before or at this datetime (RFC 3339).',+ description: 'Only results published before this date.',required: false,}),maxResults: Property.Number({displayName: 'Max Results',- description: 'Acceptable values are 0 to 50. Defaults to 25.',+ description: 'How many results to return, up to 50.',required: false,defaultValue: 25,+ display: 'stepper',+ min: 0,+ max: 50,+ step: 1,}),pageToken: Property.ShortText({displayName: 'Page Token',+ description:+ 'The nextPageToken from an earlier run, to get the next page.',required: false,+ advanced: true,}),regionCode: Property.ShortText({displayName: 'Region Code',- description: 'ISO 3166-1 alpha-2 country code (for example: US, DE, JP).',+ description:+ 'Two-letter country code. Results must be viewable there.',+ placeholder: 'US',required: false,+ advanced: true,}),relevanceLanguage: Property.ShortText({displayName: 'Relevance Language',description:- 'ISO 639-1 language code (for example: en, es, ja, zh-Hans).',+ 'Two-letter language code. Results in it rank higher.',+ placeholder: 'en',required: false,+ advanced: true,}),topicId: Property.ShortText({displayName: 'Topic ID',- description:- 'Curated Freebase topic ID to restrict results by topic (for example: /m/04rlf for Music).',+ description: 'Freebase topic ID to limit results to one topic.',+ placeholder: '/m/04rlf',required: false,+ advanced: true,}),eventType: Property.StaticDropdown({- displayName: 'Event Type (video only)',+ displayName: 'Event Type',+ description:+ 'Video only. Limit to live, upcoming or finished broadcasts.',required: false,+ advanced: true,options: {options: [{ label: 'Completed', value: 'completed' },@@ -154,24 +177,34 @@ export const youtubeSearchAction = createAction({},}),location: Property.ShortText({- displayName: 'Location (video only)',+ displayName: 'Location',description:- 'Latitude,longitude center point (for example: 37.42307,-122.08427). Requires Location Radius.',+ 'Video only. Latitude,longitude. Needs Location Radius too.',+ placeholder: '37.42307,-122.08427',required: false,+ advanced: true,}),locationRadius: Property.ShortText({- displayName: 'Location Radius (video only)',+ displayName: 'Location Radius',description:- 'Distance from Location with unit (m, km, ft, mi), for example: 5km. Requires Location.',+ 'Video only. Distance from Location in m, km, ft or mi.',+ placeholder: '5km',required: false,+ advanced: true,}),videoCategoryId: Property.ShortText({- displayName: 'Video Category ID (video only)',+ displayName: 'Video Category ID',+ description:+ "Video only. YouTube's numeric category ID, like 10 for Music.",+ placeholder: '10',required: false,+ advanced: true,}),videoDuration: Property.StaticDropdown({- displayName: 'Video Duration (video only)',+ displayName: 'Video Duration',+ description: 'Video only.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },@@ -182,8 +215,10 @@ export const youtubeSearchAction = createAction({},}),videoDefinition: Property.StaticDropdown({- displayName: 'Video Definition (video only)',+ displayName: 'Video Definition',+ description: 'Video only.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },@@ -193,8 +228,10 @@ export const youtubeSearchAction = createAction({},}),videoDimension: Property.StaticDropdown({- displayName: 'Video Dimension (video only)',+ displayName: 'Video Dimension',+ description: 'Video only.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },@@ -204,8 +241,10 @@ export const youtubeSearchAction = createAction({},}),videoEmbeddable: Property.StaticDropdown({- displayName: 'Video Embeddable (video only)',+ displayName: 'Video Embeddable',+ description: 'Video only. True: only videos other sites can embed.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },@@ -214,8 +253,10 @@ export const youtubeSearchAction = createAction({},}),videoLicense: Property.StaticDropdown({- displayName: 'Video License (video only)',+ displayName: 'Video License',+ description: 'Video only.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },@@ -225,8 +266,10 @@ export const youtubeSearchAction = createAction({},}),videoPaidProductPlacement: Property.StaticDropdown({- displayName: 'Video Paid Product Placement (video only)',+ displayName: 'Video Paid Product Placement',+ description: 'Video only. True: only videos with paid promotions.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },@@ -235,8 +278,11 @@ export const youtubeSearchAction = createAction({},}),videoSyndicated: Property.StaticDropdown({- displayName: 'Video Syndicated (video only)',+ displayName: 'Video Syndicated',+ description:+ 'Video only. True: only videos that play outside youtube.com.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },@@ -245,8 +291,10 @@ export const youtubeSearchAction = createAction({},}),videoType: Property.StaticDropdown({- displayName: 'Video Type (video only)',+ displayName: 'Video Type',+ description: 'Video only.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },@@ -256,8 +304,10 @@ export const youtubeSearchAction = createAction({},}),videoCaption: Property.StaticDropdown({- displayName: 'Video Caption (video only)',+ displayName: 'Video Caption',+ description: 'Video only.',required: false,+ advanced: true,options: {options: [{ label: 'Any', value: 'any' },diff --git a/packages/pieces/community/youtube/src/lib/common/props.ts b/packages/pieces/community/youtube/src/lib/common/props.tsindex bf053a4016a..9169135531e 100644--- a/packages/pieces/community/youtube/src/lib/common/props.ts+++ b/packages/pieces/community/youtube/src/lib/common/props.ts@@ -1,7 +1,8 @@import { Property } from '@activepieces/pieces-framework';export const channelIdentifier = Property.ShortText({- displayName: 'Channel ID, URL, or handle',- description: "YouTube channel's ID, URL, or handle (e.g: @DutchPilotGirl)",+ displayName: 'Channel',+ description: "Paste the channel's URL, its @handle, or its ID.",+ placeholder: '@GoogleDevelopers',required: true,});diff --git a/packages/pieces/community/youtube/src/lib/triggers/new-video.trigger.ts b/packages/pieces/community/youtube/src/lib/triggers/new-video.trigger.tsindex b7b680ac384..4e8a91ebf30 100644--- a/packages/pieces/community/youtube/src/lib/triggers/new-video.trigger.ts+++ b/packages/pieces/community/youtube/src/lib/triggers/new-video.trigger.ts@@ -15,7 +15,7 @@ import {} from '@activepieces/pieces-framework';import { channelIdentifier } from '../common/props';import { newVideoTriggerOutputSchema } from '../output-schemas';-import { isNil } from '@activepieces/pieces-framework';+import { isNil, tryCatch } from '@activepieces/pieces-framework';import dayjs from 'dayjs';import { load as cheerioLoad } from 'cheerio';import FeedParser from 'feedparser';@@ -24,7 +24,7 @@ export const youtubeNewVideoTrigger = createTrigger({name: 'new-video',classification: 'READ',displayName: 'New Video In Channel',- description: 'Runs when a new video is added to a YouTube channel',+ description: 'Runs when a new video is added to a YouTube channel.',aiMetadata: {description:'Fires when a new video is published on the specified YouTube channel. The event represents a single newly detected video from the channel RSS feed, including its title, link, video ID, publish date, author, and thumbnail.',@@ -343,15 +343,14 @@ function getId(item: { id?: string; guid?: string }) {}async function getChannelId(urlOrId: string) {- if (urlOrId.trim().startsWith('@')) {- urlOrId = 'https://www.youtube.com/' + urlOrId;+ const trimmed = urlOrId.trim();+ const pageUrl = await toChannelPageUrl(trimmed);+ if (isNil(pageUrl)) {+ return trimmed;}- if (!urlOrId.includes('https')) {- return urlOrId;- }- const response = await httpClient.sendRequest<any>({+ const response = await httpClient.sendRequest<string>({method: HttpMethod.GET,- url: urlOrId,+ url: pageUrl,});const $ = cheerioLoad(response.body);@@ -364,6 +363,27 @@ async function getChannelId(urlOrId: string) {throw new Error('Invalid YouTube channel URL');}+async function toChannelPageUrl(value: string): Promise<string | null> {+ if (value.startsWith('@')) {+ return `https://www.youtube.com/${value}`;+ }+ if (!value.includes('://') && !value.includes('youtube.com/')) {+ return null;+ }+ const withScheme = value.includes('://') ? value : `https://${value}`;+ const { data: parsed } = await tryCatch(async () => new URL(withScheme));+ if (isNil(parsed) || !isYoutubeUrl(parsed)) {+ throw new Error('Invalid YouTube channel URL');+ }+ return `https://www.youtube.com${parsed.pathname}`;+}++function isYoutubeUrl(url: URL): boolean {+ const host = url.hostname.toLowerCase();+ const isWeb = url.protocol === 'https:' || url.protocol === 'http:';+ return isWeb && (host === 'youtube.com' || host.endsWith('.youtube.com'));+}+async function getRssItems(channelId: string): Promise<any[]> {const url = `https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}`;const response = await httpClient.sendRequest<Buffer>({