From 50bf8760103b51c5a0bd81e17af4caf6ab371dda Mon Sep 17 00:00:00 2001 From: calzoneman Date: Thu, 22 Jan 2015 23:21:31 -0600 Subject: [PATCH] Add hitbox support --- lib/get-info.js | 16 +++++++++++++- lib/utilities.js | 3 +++ www/js/player.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++- www/js/util.js | 9 ++++++++ 4 files changed, 82 insertions(+), 2 deletions(-) diff --git a/lib/get-info.js b/lib/get-info.js index 504427d9..da3b44ac 100644 --- a/lib/get-info.js +++ b/lib/get-info.js @@ -910,7 +910,21 @@ var Getters = { Logger.errlog.log("Unknown error for Google+ ID " + id + ": " + e.stack); } }); - } + }, + + /* hitbox.tv */ + hb: function (id, callback) { + var m = id.match(/([\w-]+)/); + if (m) { + id = m[1]; + } else { + callback("Invalid ID", null); + return; + } + var title = "Hitbox.tv - " + id; + var media = new Media(id, title, "--:--", "hb"); + callback(false, media); + }, }; /** diff --git a/lib/utilities.js b/lib/utilities.js index 276daf12..b7f191d1 100644 --- a/lib/utilities.js +++ b/lib/utilities.js @@ -238,6 +238,8 @@ return "https://docs.google.com/file/d/" + id; case "fi": return id; + case "hb": + return "http://hitbox.tv/" + id; default: return ""; } @@ -252,6 +254,7 @@ case "cu": case "im": case "jw": + case "hb": return true; default: return false; diff --git a/www/js/player.js b/www/js/player.js index 9ab9fe9a..7cefd9ce 100644 --- a/www/js/player.js +++ b/www/js/player.js @@ -1044,6 +1044,59 @@ function FilePlayer(data) { } }; +var HitboxPlayer = function (data) { + var self = this; + self.videoId = data.id; + self.videoLength = data.seconds; + self.init = function () { + if (location.protocol.match(/^https/)) { + var div = makeAlert("Security Policy", + "You are currently connected via HTTPS but " + + "Hitbox only supports plain HTTP. Due to browser " + + "security policy, the embed player cannot be loaded. " + + "In order to watch the video, you must visit this page " + + "from its plain HTTP URL (your websocket will still be " + + "secured with HTTPS). Please complain to Hitbox about this.", + "alert-danger"); + div.addClass("embed-responsive-item"); + removeOld(div); + return; + } + + var iframe = $("