# Path to video on local filesystem.video_file = '/path/to/video_file.mp4'# Optionally add transcripts in .vtt format.transcript_path = '/path/to/transcript.vtt'# Add metadata for this video.metadata = { 'title': 'Example video', 'description': 'This is an example video', 'info': { # Add any other info here. }}client.index_video(index_name, video_file=video_file, transcript_path=transcript_path, metadata=metadata)
# Path to video on local filesystem.video_url = 'https://link.to/video.mp4'# Add metadata for this video.metadata = { 'title': 'Example video', 'description': 'This is an example video', 'info': { # Add any other info here. }}client.index_video(index_name, video_url=video_url, metadata=metadata)
AskVideos provides convenience functions to index videos from YouTube. Please comply with your local laws for use of video content.
Add from search terms
Copy
# Find videos of 'dogs'.search_term = 'dogs'# Only use top 10 search resultsmax_videos = 10# Only index videos shorter than 10 mins.max_duration = 600client.index_from_youtube_search(index_name, search_term, max_videos=max_videos, max_duration=max_duration)
Add from url
Copy
# Index this video from URL.video_url = 'https://www.youtube.com/watch?v=video_id'# Only use top 10 search resultsmax_videos = 10# Only index videos shorter than 10 mins.max_duration = 600client.index_from_youtube_url(index_name, video_url, max_videos=max_videos, max_duration=max_duration)
Add from playlist
Copy
# Index videos from this playlist.playlist_url = 'https://www.youtube.com/playlist?list=playlist_url'# Only use top 10 search resultsmax_videos = 10# Only index videos shorter than 10 mins.max_duration = 600client.index_from_youtube_playlist(index_name, playlist_url, max_videos=max_videos, max_duration=max_duration)
Add from channel
Copy
# Index videos from this channel.channel_url = 'https://www.youtube.com/channel/channel_id'# Only use top 10 search resultsmax_videos = 10# Only index videos shorter than 10 mins.max_duration = 600client.index_from_youtube_channel(index_name, channel_url, max_videos=max_videos, max_duration=max_duration)