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

Commit 73dbb0a

Browse files
committed
beastmode.coffee - returns beastmode.fm track info/art
1 parent aaacf9c commit 73dbb0a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/scripts/beastmode.coffee

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Description
2+
# Listens for beastmode.fm track urls and returns track title and cover art
3+
#
4+
# Dependencies:
5+
# "jsdom": "~0.2.13"
6+
#
7+
# Configuration:
8+
# None
9+
#
10+
# Commands:
11+
# {beastmodefm-url} - Return track title and cover art
12+
#
13+
# Notes:
14+
#
15+
#
16+
# Author:
17+
# benpink
18+
19+
jsdom = require 'jsdom'
20+
jquery = 'http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js'
21+
22+
module.exports = (robot) ->
23+
24+
robot.hear /beastmode.fm.*?(\/(\d+))/i, (msg) ->
25+
robot.http('http://beastmode.fm/track/' + msg.match[2])
26+
.get() (err, res, body) ->
27+
jsdom.env body, [jquery], (errors, window) ->
28+
trackImg = window.$('#track-img img').attr('src')
29+
trackTitle = window.$('#article-info h1').text()
30+
msg.send trackTitle + ' ' + trackImg

0 commit comments

Comments
 (0)