Merge pull request #446 from Xaekai/3.0

Enhance media link parser.
This commit is contained in:
Calvin Montgomery 2015-02-17 10:42:33 -06:00
commit f790a9dbd5
2 changed files with 27 additions and 4 deletions

View File

@ -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;

View File

@ -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]
};
}