Created
April 10, 2012 12:31
-
-
Save jacobk/2351058 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Metadata lookup for youtube links | |
# | |
# <youtube link> - returns info about the link | |
# | |
module.exports = (robot) -> | |
robot.hear youtube.link, (msg) -> | |
msg.http(youtube.uri msg.match[1]).get() (err, res, body) -> | |
if res.statusCode is 200 | |
data = JSON.parse(body) | |
msg.send "Youtube: #{data.entry.title["$t"]}" | |
youtube = | |
link: /(?:youtu\.be\/|youtube.com\/(?:watch\?.*\bv=|embed\/|v\/)|ytimg\.com\/vi\/)(.+?)(?:[^-a-zA-Z0-9]|$)/ | |
uri: (vid) -> "https://gdata.youtube.com/feeds/api/videos/#{vid}?v=2&alt=json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment