Created
August 28, 2011 00:51
-
-
Save austenito/1176079 to your computer and use it in GitHub Desktop.
bad code
This file contains 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
add_to_queue: function(video_url, room_hash, queue_name) { | |
id = video.get_video_id(video_url); | |
switch(video.get_video_type(video_url)) { | |
case 1: | |
service = 'youtube'; | |
video_key = 'video:' + service + ':' + id; | |
db.rpush(queue_name, video_key, function() {}); | |
db.hget('videos', video_key, function(err, data) { | |
if (data == null){ | |
json_feed = 'http://gdata.youtube.com/feeds/api/videos/' + id + | |
'?v=2&alt=json'; | |
video.parse_json_feed(json_feed, function(res) { | |
details = {'title': res.entry.title, 'id': id, 'service': service}; | |
json_details = JSON.stringify(details); | |
db.hset('videos', video_key, json_details, function() { | |
nowjs.getGroup(room_hash).now.pushToVideoQueue(json_details); | |
}); | |
}); | |
} | |
else { | |
nowjs.getGroup(room_hash).now.pushToVideoQueue(data); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What an amazing gist.