diff --git a/lib/get-info.js b/lib/get-info.js index 9e8ab002..c07d0b09 100644 --- a/lib/get-info.js +++ b/lib/get-info.js @@ -418,7 +418,7 @@ var Getters = { dm: function (id, callback) { var m = id.match(/([\w-]+)/); if (m) { - id = m[1]; + id = m[1].split("_")[0]; } else { callback("Invalid ID", null); return; diff --git a/www/js/util.js b/www/js/util.js index 8c744440..95afc6ca 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -1266,6 +1266,13 @@ function parseMediaLink(url) { }; } + if ((m = url.match(/hitbox\.tv\/([^\?&#]+)/))) { + return { + id: m[1], + type: "hb" + }; + } + if((m = url.match(/vimeo\.com\/([^\?&#]+)/))) { return { id: m[1], @@ -1273,7 +1280,7 @@ function parseMediaLink(url) { }; } - if((m = url.match(/dailymotion\.com\/video\/([^\?&#]+)/))) { + if((m = url.match(/dailymotion\.com\/video\/([^\?&#_]+)/))) { return { id: m[1], type: "dm" @@ -1308,10 +1315,26 @@ function parseMediaLink(url) { }; } - if ((m = url.match(/hitbox\.tv\/([^\?&#]+)/))) { + /* Shorthand URIs */ + // To catch Google Plus by ID alone + if ((m = url.match(/(?:gp:)?(\d{21}_\d{19}_\d{19})/))) { return { id: m[1], - type: "hb" + type: "gp" + }; + } + // So we still trim DailyMotion URLs + if((m = url.match(/dm:([^\?&#_]+)/))) { + return { + id: m[1], + type: "dm" + }; + } + // Generic for the rest. + if ((m = url.match(/([a-z]{2}):([^\?&#]+)/)) { + return { + id: m[2], + type: m[1] }; }