YouTube
In this section, we present how to connect YouTube to MindsDB.
YouTube is a popular online video-sharing platform and social media website where users can upload, view, share, and interact with videos created by individuals and organizations from around the world.
Data from YouTube can be utilized within MindsDB to train AI models and chatbots based on user comments, detect sentiment of comments, or use AI models to create replies.
Connection
This handler is implemented using the google-api-python-client
library, a Python library that from where we can use YouTube v3 API.
The only required argument to establish a connection are as follows:
youtube_api_token
which is a Google API key used for authentication.
Check out this guide on how to create the API key in order to access YouTube data.
The first step is to create a database with the new Youtube
engine using the following command:
CREATE DATABASE mindsdb_youtube
WITH ENGINE = 'youtube',
PARAMETERS = {
"youtube_api_token": "<your-youtube-api-key-token>"
};
If you installed MindsDB locally via pip, you need to install all handler dependencies manually. To do so, go to the handler’s folder (mindsdb/integrations/handlers/youtube_handler) and run this command: pip install -r requirements.txt
.
Usage
Use the established connection to query the get_comments
table for any YouTube Video of your choice.
SELECT * FROM mindsdb_youtube.get_comments
WHERE youtube_video_id = "raWFGQ20OfA";
Advanced queries which are supported
SELECT * FROM mindsdb_youtube.get_comments
WHERE youtube_video_id = "raWFGQ20OfA"
ORDER BY display_name ASC
LIMIT 5;