Download tool.py from flashdata-dev/youtube-metadata-chapters-flashdata: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/spaces/flashdata-dev/youtube-metadata-chapters-flashdata/resolve/main/tool.py
- Command line
-
hf download hf://spaces/flashdata-dev/youtube-metadata-chapters-flashdata/tool.py
-
curl -L -o tool.py https://huggingface.co/spaces/flashdata-dev/youtube-metadata-chapters-flashdata/resolve/main/tool.py
1.39 kB
| from smolagents import Tool | |
| class FlashDataTool(Tool): | |
| name = 'youtube_metadata' | |
| description = 'Get details for a YouTube video ID: title, description, channel, statistics and available chapters or media-format information. Chapters, statistics and formats depend on availability. Metadata retrieval does not download video or transcript text. Uses paid FlashData API credits. Never automatically retry an uncertain submission; check Jobs first.' | |
| inputs = {'include_chapters': {'description': 'Include available video chapters. Default: True.', | |
| 'nullable': True, | |
| 'type': 'boolean'}, | |
| 'include_formats': {'description': 'Include available format metadata. Default: True.', | |
| 'nullable': True, | |
| 'type': 'boolean'}, | |
| 'video_id': {'description': '11-character YouTube video ID or a YouTube video URL.', | |
| 'type': 'string'}} | |
| output_type = 'object' | |
| def forward(self, video_id: str, include_chapters: bool = True, include_formats: bool = True) -> dict: | |
| from langchain_flashdata import FlashDataYouTubeMetadata | |
| values = {'video_id': video_id, 'include_chapters': include_chapters, 'include_formats': include_formats} | |
| return FlashDataYouTubeMetadata().invoke({key: value for key, value in values.items() if value is not None}) | |