Skip to main content
Glama
phase1-candidate-search.ts1.31 kB
import { FindConsistentOutlierChannelsOptions } from "../../types/analyzer.types.js"; import { YoutubeService } from "../../services/youtube.service.js"; import { calculateChannelAgePublishedAfter, isQuotaError, } from "./analysis.logic.js"; export async function executeInitialCandidateSearch( options: FindConsistentOutlierChannelsOptions, youtubeService: YoutubeService ): Promise<string[]> { try { const publishedAfter = calculateChannelAgePublishedAfter( options.channelAge ); const searchResults = await youtubeService.searchVideos({ query: options.query, publishedAfter: publishedAfter, type: "video", order: "relevance", maxResults: 50, regionCode: options.regionCode, videoCategoryId: options.videoCategoryId, }); const channelIds = new Set<string>(); for (const video of searchResults) { if (video.snippet?.channelId) { channelIds.add(video.snippet.channelId); } } return Array.from(channelIds); } catch (error: unknown) { if (isQuotaError(error)) { throw new Error("YouTube API quota exceeded during Phase 1."); } const message = error instanceof Error ? error.message : "An unknown error occurred"; throw new Error(`Phase 1 failed: ${message}`); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kirbah/mcp-youtube'

If you have feedback or need assistance with the MCP directory API, please join our Discord server