Skip to content

hubot-archive/hubot-youtube

Repository files navigation

hubot-youtube

npm version Node.js CI

A Hubot script for searching YouTube.

Installation

In the Hubot project repo, run:

npm install hubot-youtube --save

Then add hubot-youtube to your external-scripts.json:

[
  "hubot-youtube"
]

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.

Enable v3

Create a "Public" token rather than the OAuth credentials for this particular implementation.

Get Public Token

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.

Optionally set flag for deterministic searching

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

Optionally set flag for listening on public channel

If you want Hubot to listen every messages (without mentioning the bot) on public channel, set HUBOT_YOUTUBE_HEAR.

export HUBOT_YOUTUBE_HEAR=true

Optionally set flag for displaying the video title

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

Optionally set flag for decoding HTML entities in the video title

If you want Hubot to decode any HTML entities in the video title, set HUBOT_YOUTUBE_DECODE_HTML.

export HUBOT_YOUTUBE_DECODE_HTML=true

Sample Interaction

user1> hubot youtube no no no cat remix
hubot> http://www.youtube.com/watch?v=z7OJ3vDqyw8&feature=youtube_gdata

Troubleshooting

Quota Exceeded Error

The YouTube API now requires a billing account attached to your GCP project.