A Hubot script for searching YouTube.
In the Hubot project repo, run:
npm install hubot-youtube --save
Then add hubot-youtube to your external-scripts.json
:
[
"hubot-youtube"
]
Obtain a Google Developer Console token
Ensure your Project has a billing account connected in order to query the API.
Enable the "YouTube Data API v3" permission from the API menu.
Create a "Public" token rather than the OAuth credentials for this particular implementation.
Copy your token to the HUBOT_YOUTUBE_API_KEY
environment variable.
export HUBOT_YOUTUBE_API_KEY=<your token>
Learn more about how to generate Google credentials.
If you want Hubot to only return the most relevant result rather than randomly one of the top 15 results, set the environment variable HUBOT_YOUTUBE_DETERMINISTIC_RESULTS
.
export HUBOT_YOUTUBE_DETERMINISTIC_RESULTS=true
If you want Hubot to listen every messages (without mentioning the bot) on public channel, set HUBOT_YOUTUBE_HEAR
.
export HUBOT_YOUTUBE_HEAR=true
If you want Hubot to display the video title along with the URL, set HUBOT_YOUTUBE_DISPLAY_VIDEO_TITLE
.
export HUBOT_YOUTUBE_DISPLAY_VIDEO_TITLE=true
If you want Hubot to decode any HTML entities in the video title, set HUBOT_YOUTUBE_DECODE_HTML
.
export HUBOT_YOUTUBE_DECODE_HTML=true
user1> hubot youtube no no no cat remix
hubot> https://www.youtube.com/watch?v=z7OJ3vDqyw8&feature=youtube_gdata
The YouTube API now requires a billing account attached to your GCP project.