Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
Adding screencast script
Browse files Browse the repository at this point in the history
Watches for screencast links and posts the images from the main page.
  • Loading branch information
chrismlarson committed Oct 13, 2012
1 parent 675f4f2 commit e4a7183
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/scripts/screencast.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Description:
# Post screencast image link
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# http://screencast.com/... - Display image from Screencast
#
# Author:
# Chris Larson

Select = require( "soupselect" ).select
HTMLParser = require "htmlparser"

module.exports = (robot) ->
robot.hear /(http:\/\/)?screencast.com\/t\/([^\s]*)/i, (msg) ->
SCShortId = escape(msg.match[2])
try
msg.http("http://screencast.com/t/"+SCShortId).get() (err, resp, body) ->
htmlHandler = new HTMLParser.DefaultHandler( (()->), ignoreWhitespace: true )
htmlParser = new HTMLParser.Parser htmlHandler

htmlParser.parseComplete body
try
url = Select( htmlHandler.dom, "img.embeddedObject" )[0].attribs.src
catch error
msg.send url
catch error

0 comments on commit e4a7183

Please sign in to comment.