@framers/agentos-ext-channel-youtube

中文文档
0.1.9发布于 2026/11/13Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 2万

YouTube channel adapter for AgentOS — upload videos, publish Shorts, comment, search, track analytics, manage playlists, and schedule via YouTube Data API v3.

原始使用文档
文档目录17 节
  1. Installation
  2. Usage
  3. Configuration
  4. Tools
  5. youtubeUpload
  6. youtubeShort
  7. youtubeComment
  8. youtubeSearch
  9. youtubeTrending
  10. youtubeAnalytics
  11. youtubePlaylist
  12. youtubeSchedule
  13. Channel adapter
  14. Reading the status of videos
  15. Notes
  16. Releases
  17. License

YouTube channel

This pack gives an agent video and Shorts uploads, comments, search, trends, statistics, playlist management and scheduled publishing through the YouTube Data API using googleapis. Code that holds the service can also read the status of a batch of videos (below).

Installation

npm install @framers/agentos-ext-channel-youtube

Peer dependency: @framers/agentos >=0.10.40.

Usage

import { AgentOS } from '@framers/agentos';

const agentos = await AgentOS.create({
  extensionManifest: {
    packs: [
      {
        package: '@framers/agentos-ext-channel-youtube',
        options: { apiKey: process.env.YOUTUBE_API_KEY },
      },
    ],
  },
});

Configuration

OptionSecret idEnvironment variableRequiredDefault
apiKeyyoutube.apiKeyVariable named by apiKeyEnv, then YOUTUBE_API_KEY, then GOOGLE_API_KEYYesNone
apiKeyEnvNoneNoneNoYOUTUBE_API_KEY
oauthNoneNoneNoResolved credentials if complete, otherwise none
oauth.clientIdyoutube.oauth.clientIdYOUTUBE_OAUTH_CLIENT_IDNoNone
oauth.clientSecretyoutube.oauth.clientSecretYOUTUBE_OAUTH_CLIENT_SECRETNoNone
oauth.refreshTokenyoutube.oauth.refreshTokenYOUTUBE_OAUTH_REFRESH_TOKENNoNone
priorityNoneNoneNo50
secretsyoutube.apiKey, youtube.oauth.clientId, youtube.oauth.clientSecret, youtube.oauth.refreshTokenNoneNoNone

The API key resolves from options, then options.secrets, then environment variables. The first environment lookup uses apiKeyEnv, which defaults to YOUTUBE_API_KEY. An explicit oauth object overrides OAuth secret and environment resolution. Otherwise each OAuth field resolves from secrets before its environment variable, and OAuth is enabled only when all fields resolve. The oauth interface requires all fields when the object is supplied.

Tools

ToolWhat it does
youtubeUploadUpload a video with title, description, tags and privacy settings.
youtubeShortUpload a Short with a #Shorts tag.
youtubeCommentPost a comment or reply to an existing comment.
youtubeSearchSearch videos, channels or playlists by keyword.
youtubeTrendingGet popular videos by region and category.
youtubeAnalyticsGet video or channel performance metrics.
youtubePlaylistCreate, list, add videos to or delete playlists.
youtubeScheduleUpload a private video for scheduled public publishing.

youtubeUpload

ParameterTypeRequiredDescription
videoUrlstringYesURL of the video file to upload
titlestringYesVideo title (max 100 chars)
descriptionstringYesVideo description (max 5000 chars)
tagsstring[]NoVideo tags for discoverability
categoryIdstringNoYouTube category ID (default: 22, People & Blogs)
privacyStatusstring: public, private, unlistedNoPrivacy status (default: public)
mimeTypestringNoVideo MIME type (default: video/mp4)

youtubeShort

ParameterTypeRequiredDescription
videoUrlstringYesURL of the short-form video file
titlestringYesShort title (max 100 chars)
descriptionstringNoShort description
tagsstring[]NoAdditional tags (besides #Shorts)
privacyStatusstring: public, private, unlistedNoPrivacy status (default: public)

youtubeComment

ParameterTypeRequiredDescription
videoIdstringYesYouTube video ID
textstringYesComment text
parentCommentIdstringNoParent comment ID for replying to a comment

youtubeSearch

ParameterTypeRequiredDescription
querystringYesSearch query
typestring: video, channel, playlistNoSearch type (default: video)
maxResultsnumberNoMax results to return (default: 10, max: 50)
orderstring: relevance, date, rating, viewCount, titleNoSort order (default: relevance)
regionCodestringNoISO 3166-1 alpha-2 region code (e.g., US, GB)

youtubeTrending

ParameterTypeRequiredDescription
regionCodestringNoISO 3166-1 alpha-2 region code (default: US)
categoryIdstringNoYouTube video category ID (e.g., 10 for Music, 17 for Sports, 20 for Gaming)
maxResultsnumberNoMax results to return (default: 20, max: 50)

youtubeAnalytics

ParameterTypeRequiredDescription
typestring: video, channelYesWhether to get analytics for a video or a channel
videoIdstringNoVideo ID (required when type is video)
channelIdstringNoChannel ID (optional for type channel, defaults to own channel if OAuth is set up)

youtubePlaylist

ParameterTypeRequiredDescription
actionstring: create, list, listItems, addVideo, deleteYesPlaylist action to perform
titlestringNoPlaylist title (required for create)
descriptionstringNoPlaylist description
privacyStatusstring: public, private, unlistedNoPrivacy status (default: public)
playlistIdstringNoPlaylist ID (required for listItems, addVideo, delete)
videoIdstringNoVideo ID (required for addVideo)
channelIdstringNoChannel ID (optional for list, defaults to own channel)
maxResultsnumberNoMax results for list operations

youtubeSchedule

ParameterTypeRequiredDescription
videoUrlstringYesURL of the video file to upload
titlestringYesVideo title (max 100 chars)
descriptionstringYesVideo description (max 5000 chars)
publishAtstringYesISO 8601 datetime for scheduled publish time
tagsstring[]NoVideo tags for discoverability
categoryIdstringNoYouTube category ID (default: 22, People & Blogs)
mimeTypestringNoVideo MIME type (default: video/mp4)

Channel adapter

The adapter registers platform youtube. Activation initializes the API service, and connection status follows its running state. A video block triggers an upload from its HTTPS URL; metadata comes from platformOptions.title, platformOptions.tags, platformOptions.categoryId and platformOptions.privacyStatus. The title falls back to the video caption, then Untitled; a text block supplies the description before the caption fallback.

Without a video block, sending posts a comment using conversationId as the video ID and replyToMessageId as the optional parent comment ID. Empty video IDs or comment text throw. The adapter stores event handlers but emits no inbound events. Typing indicators do nothing.

Reading the status of videos

YouTubeService.getVideosStatus(videoIds) reads the status of many videos at once and needs the API key alone. It calls videos.list with the parts snippet, status and contentDetails once for each fifty ids, and each call costs one quota unit, so 120 ids cost three units.

It returns one row for each video the API returned, in the order of the ids asked for. An id asked twice is read once and has one row. An id the API returns nothing for, such as a removed or private video, has no row. A row holds the video's id and these fields, each value as the API gave it, so a caller checks a value's type itself:

PartFields
snippetchannelId, channelTitle, title, description
statusembeddable, madeForKids, privacyStatus
contentDetailscaption, duration, contentRating

A field the API left out is absent from the row. An empty list makes no call. A failed call, a refused quota among them, rejects with the API's own error, and no rows are returned. The method stores nothing and logs nothing.

import { YouTubeService, type VideoStatusRow } from '@framers/agentos-ext-channel-youtube';

const youtube = new YouTubeService({ apiKey: process.env.YOUTUBE_API_KEY! });
await youtube.initialize();
const rows: VideoStatusRow[] = await youtube.getVideosStatus(['video-id-1', 'video-id-2']);

Notes

Creating the pack throws if no API key resolves. Uploads, comments, playlist creation, playlist additions and playlist deletion require OAuth credentials and change content on the account. Listing the account's own playlists also requires OAuth. Channel analytics require channelId when OAuth is absent.

Upload tools fetch HTTP or HTTPS video URLs and stream responses to the API. They set no download timeout, check no HTTP response status and implement no redirect handling. The service defaults uploads to public, video/mp4 and the People & Blogs category, and sets selfDeclaredMadeForKids to false.

Shorts uploads add Shorts to tags and append #Shorts to the description. The code does not validate duration or orientation. Scheduling rejects invalid or past dates, then uploads with private privacy and publishAt; it uses no local publishing timer.

Search, trending and playlist listing requests are capped at 50 results. Playlist lists default to 25 results. Tool failures return success: false and an error message. Action-specific playlist fields and video analytics IDs are checked during execution despite being optional in their schemas.

Releases

New versions are published from framerslab/agentos-extensions by GitHub Actions through npm trusted publishing, with a provenance statement.

License

Apache-2.0

版本与发布记录

@framers/agentos-ext-channel-youtube 共发布 10 个版本,首次发布于 2026/05/02;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.9latest2026/11/132 天前
0.1.82026/11/114 天前
0.1.72026/11/0114 天前
0.1.62026/11/0115 天前
0.1.52026/10/121 个月前
0.1.42026/10/111 个月前

关于 @framers/agentos-ext-channel-youtube 的常见问题

@framers/agentos-ext-channel-youtube 是什么?

YouTube channel adapter for AgentOS — upload videos, publish Shorts, comment, search, track analytics, manage playlists, and schedule via YouTube Data API v3.

如何安装 @framers/agentos-ext-channel-youtube?

在项目目录运行 npm install @framers/agentos-ext-channel-youtube,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@framers/agentos(>=0.10.40)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@framers/agentos-ext-channel-youtube 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@framers/agentos-ext-channel-youtube 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@framers/agentos-ext-channel-youtube 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@framers/agentos-ext-channel-youtube 可以商用吗?

@framers/agentos-ext-channel-youtube 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@framers/agentos-ext-channel-youtube 的下载量有多少?

根据 npm 官方下载统计,@framers/agentos-ext-channel-youtube 在 2026/10/16 – 2026/11/14 这 30 天内被下载 20,476 次,日均约 683 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@framers/agentos-ext-channel-youtube 还在维护吗?

最新版本 0.1.9 发布于 2026/11/13(2 天前);至今共发布 10 个版本,其中过去 12 个月发布了 10 个;首次发布于 2026/05/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。