From a636082500a6a02e6e61062b46bad957973fec03 Mon Sep 17 00:00:00 2001 From: Xaekai Date: Mon, 16 Feb 2015 00:33:44 -0800 Subject: [PATCH] Enhance media link parser. Accept the shorthand URI style used in the logs as valid. Add an underscore to the DailyMotion negated group to prevent dupe abuse. --- www/js/util.js | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/www/js/util.js b/www/js/util.js index 8c744440..ff5f365b 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,39 @@ function parseMediaLink(url) { }; } - if ((m = url.match(/hitbox\.tv\/([^\?&#]+)/))) { + /* Shorthand URIs */ + if ((m = url.match(/(?:gp:)?(\d{21}_\d{19}_\d{19})/))) { return { id: m[1], - type: "hb" + type: "gp" + }; + } + + if ((m = url.match(/gd:([^\/]{28})/))) { + return { + id: m[1], + type: "gd" + }; + } + + if((m = url.match(/yt:([^\?&#]+)/))) { + return { + id: m[1], + type: "yt" + }; + } + + if((m = url.match(/dm:([^\?&#_]+)/))) { + return { + id: m[1], + type: "dm" + }; + } + + if((m = url.match(/vi:([^\?&#]+)/))) { + return { + id: m[1], + type: "vi" }; }