import type { GoogleAccountAlias } from './accounts.ts' export type YouTubeChannelKey = 'main' | 'plus' export type YouTubeChannelInfo = { key: YouTubeChannelKey /** google account alias used for YouTube Data API OAuth */ account: Extract channelId: string title: string handle: string url: string /** Primary content on this channel (for agent routing) */ content: string[] /** Former public names agents may still encounter in legacy copy */ legacyNames?: string[] } /** Canonical Kent YouTube channel registry for agent routing. */ export const YOUTUBE_CHANNELS: Record = { main: { key: 'main', account: 'youtube-brand', channelId: 'UCz-BYvuntVRt_VpfR6FKXJw', title: 'Kent C. Dodds', handle: '@kentcdodds', url: 'https://www.youtube.com/@kentcdodds', content: [ 'Better with Kent', 'workshop promos', 'curated dev content', 'live streams (VOD unlisted after stream)', ], }, plus: { key: 'plus', account: 'youtube-plus', channelId: 'UCyCnaVEEdtP_IzGv06wBArQ', title: 'kentcdodds-plus', handle: '@kentcdodds-plus', url: 'https://www.youtube.com/@kentcdodds-plus', content: [ 'Become an Epic Product Engineer full episodes', 'BEPE promo Shorts', 'legacy Chats with Kent video archive', ], legacyNames: ['Chats with Kent'], }, } export const YOUTUBE_CHANNEL_KEYS = ['main', 'plus'] as const export function listYouTubeChannels(): YouTubeChannelInfo[] { return YOUTUBE_CHANNEL_KEYS.map((key) => ({ ...YOUTUBE_CHANNELS[key] })) } export function resolveYouTubeChannel( input: { channel?: string; account?: string } | string = {}, ): YouTubeChannelInfo { const channelKey = typeof input === 'string' ? input : input.channel?.trim() || input.account?.trim() if (!channelKey) return { ...YOUTUBE_CHANNELS.main } const fromKey = YOUTUBE_CHANNELS[channelKey as YouTubeChannelKey] if (fromKey) return { ...fromKey } const fromAccount = YOUTUBE_CHANNEL_KEYS.map((key) => YOUTUBE_CHANNELS[key]).find( (entry) => entry.account === channelKey, ) if (fromAccount) return { ...fromAccount } const fromChannelId = YOUTUBE_CHANNEL_KEYS.map((key) => YOUTUBE_CHANNELS[key]).find( (entry) => entry.channelId === channelKey, ) if (fromChannelId) return { ...fromChannelId } throw new Error( `Unknown YouTube channel "${channelKey}". Pass one of: ${YOUTUBE_CHANNEL_KEYS.join(', ')}, youtube-brand, youtube-plus, or a channel id.`, ) } /** * Return Kent's canonical YouTube channel registry for routing uploads and analytics. * @example * import youtubeChannels from 'kody:@kentcdodds/google/youtube-channels' * const channel = youtubeChannels().channels.find((c) => c.key === 'main') * // => { key: 'main', account: 'youtube-brand', channelId: 'UC...', ... } */ export default function youtubeChannels() { return { channels: listYouTubeChannels(), keys: [...YOUTUBE_CHANNEL_KEYS] } }