Download tool.py from flashdata-dev/youtube-uploader-captions-flashdata: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/flashdata-dev/youtube-uploader-captions-flashdata/resolve/main/tool.py
- Command line
-
hf download hf://spaces/flashdata-dev/youtube-uploader-captions-flashdata/tool.py
-
curl -L -o tool.py https://huggingface.co/spaces/flashdata-dev/youtube-uploader-captions-flashdata/resolve/main/tool.py
1.38 kB
| from smolagents import Tool | |
| class FlashDataTool(Tool): | |
| name = 'youtube_captions' | |
| description = 'Retrieve existing uploader-provided YouTube captions by video ID and language. Get subtitle text and timestamped segments for local processing or export. Defaults to existing English manual captions. Does not generate or translate subtitles, or fall back to another track. Uses paid FlashData API credits. Never automatically retry an uncertain submission; check Jobs first.' | |
| inputs = {'auto': {'description': 'False selects manual; true automatic captions. Default: False.', | |
| 'nullable': True, | |
| 'type': 'boolean'}, | |
| 'language': {'description': 'Requested caption language code. pattern: ^[A-Za-z0-9-]{1,35}$. ' | |
| "Default: 'en'.", | |
| 'nullable': True, | |
| 'type': 'string'}, | |
| 'video_id': {'description': '11-character YouTube video ID or a YouTube video URL.', | |
| 'type': 'string'}} | |
| output_type = 'object' | |
| def forward(self, video_id: str, language: str = 'en', auto: bool = False) -> dict: | |
| from langchain_flashdata import FlashDataYouTubeCaptions | |
| values = {'video_id': video_id, 'language': language, 'auto': auto} | |
| return FlashDataYouTubeCaptions().invoke({key: value for key, value in values.items() if value is not None}) | |