From a636082500a6a02e6e61062b46bad957973fec03 Mon Sep 17 00:00:00 2001 From: Xaekai Date: Mon, 16 Feb 2015 00:33:44 -0800 Subject: [PATCH 1/3] 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" }; } From ca17c82c8c792cf33663349aeccf87c62bff7da9 Mon Sep 17 00:00:00 2001 From: Xaekai Date: Mon, 16 Feb 2015 00:50:15 -0800 Subject: [PATCH 2/3] Make doubly sure fixed calzoneman/sync#445 --- lib/get-info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 5c6a966e6ff26f6e2db8b76601d8227b892f27af Mon Sep 17 00:00:00 2001 From: Xaekai Date: Mon, 16 Feb 2015 22:40:18 -0800 Subject: [PATCH 3/3] Use a generic matcher for the shorthand URIs. --- www/js/util.js | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/www/js/util.js b/www/js/util.js index ff5f365b..95afc6ca 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -1316,38 +1316,25 @@ function parseMediaLink(url) { } /* 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: "gp" }; } - - if ((m = url.match(/gd:([^\/]{28})/))) { - return { - id: m[1], - type: "gd" - }; - } - - if((m = url.match(/yt:([^\?&#]+)/))) { - return { - id: m[1], - type: "yt" - }; - } - + // So we still trim DailyMotion URLs if((m = url.match(/dm:([^\?&#_]+)/))) { return { id: m[1], type: "dm" }; } - - if((m = url.match(/vi:([^\?&#]+)/))) { + // Generic for the rest. + if ((m = url.match(/([a-z]{2}):([^\?&#]+)/)) { return { - id: m[1], - type: "vi" + id: m[2], + type: m[1] }; }