tools.youtube_describe module
Analyse a video via the Gemini API — YouTube (native ingestion), Rumble, Twitch, direct MP4, and 1000+ other sites via yt-dlp.
- async tools.youtube_describe.run(video_url='', youtube_url='', focus_area=None, ctx=None)[source]
Tool entry point: produce an exhaustive Gemini analysis of a video URL.
Orchestrates the whole pipeline: it classifies the URL via
_classify_url(), resolves a Gemini key (preferring the user’s stored key over the rotating default pool, with per-user default-key rate limiting viamanage_api_keys), fetches metadata with_get_video_metadata(), enforcesMAX_DURATION_SECONDS, picks an FPS with_calculate_fps(), and builds the prompt from_format_metadata_for_prompt()plusANALYSIS_PROMPTand anyfocus_area. YouTube URLs take a fast native Gemini ingestion path; everything else downloads (_download_direct()or_download_with_ytdlp()), uploads via_upload_to_gemini_sync(), and cleans up both the temp directory and the Gemini-hosted file in afinallyblock. The actual model call goes through_generate_description().Registered under
TOOL_NAME = "describe_video"and discovered bytool_loader.load_tools; the inference worker dispatches it through theToolRegistrywith a populatedctx. It reads/writes per-user API-key and usage state in Redis viactx.redis, touches the filesystem for temporary downloads, and makes outbound HTTP/Gemini calls.- Parameters:
video_url (
str) – The video URL to analyse (primary argument).youtube_url (
str) – Legacy alias accepted whenvideo_urlis absent.focus_area (
Optional[str]) – Optional aspect to give extra depth in the analysis.ctx – Tool execution context supplying
redis,user_id,channel_id, andconfigfor key resolution and limits.
- Returns:
A JSON document. On success it carries
success: truewith thedescription,model_used,source, and available metadata; on failure it carries anerrormessage (missing URL, unextractable ID, over-length, rate-limit, download/upload, or generation error).- Return type: