Skip to content

Instantly share code, notes, and snippets.

@austenito
Created August 28, 2011 00:51
Show Gist options
  • Save austenito/1176079 to your computer and use it in GitHub Desktop.
Save austenito/1176079 to your computer and use it in GitHub Desktop.
bad code
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);
}
});
@j3j3
Copy link

j3j3 commented May 16, 2012

What an amazing gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment