Add gfycat support
This commit is contained in:
parent
047a61ea0d
commit
cfe10c5532
|
@ -96,7 +96,7 @@ function getBetterUrl(url, callback) {
|
||||||
url = url.replace("gifv", "mp4");
|
url = url.replace("gifv", "mp4");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isTwitterUrl(url)) {
|
if(isTwitterImageUrl(url)) {
|
||||||
if(url.indexOf(':') != url.lastIndexOf(':')) { //Match if there are occurences of ':' other than the ':' in 'https://', such as in '.jpg:large'
|
if(url.indexOf(':') != url.lastIndexOf(':')) { //Match if there are occurences of ':' other than the ':' in 'https://', such as in '.jpg:large'
|
||||||
url = url.substr(0, url.lastIndexOf(':'));
|
url = url.substr(0, url.lastIndexOf(':'));
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,19 @@ function getBetterUrl(url, callback) {
|
||||||
url = url + '/imgpsh_fullsize';
|
url = url + '/imgpsh_fullsize';
|
||||||
|
|
||||||
callback(url);
|
callback(url);
|
||||||
|
} else if(isGfycatUrl(url)) {
|
||||||
|
var id = url.substr(url.lastIndexOf('/') + 1);
|
||||||
|
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.open('GET', 'http://gfycat.com/cajax/get/' + id, true);
|
||||||
|
request.onload = function () {
|
||||||
|
var json = JSON.parse(request.responseText);
|
||||||
|
|
||||||
|
var webmUrl = json.gfyItem.webmUrl;
|
||||||
|
|
||||||
|
callback(webmUrl);
|
||||||
|
};
|
||||||
|
request.send();
|
||||||
} else {
|
} else {
|
||||||
callback(url);
|
callback(url);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +207,7 @@ function cleanExtension(url) {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isTwitterUrl(url) {
|
function isTwitterImageUrl(url) {
|
||||||
return url.indexOf('pbs.twimg.com/media/') != -1;
|
return url.indexOf('pbs.twimg.com/media/') != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,6 +223,10 @@ function isSkypeUrl(url) {
|
||||||
return url.indexOf('api.asm.skype.com/v1/objects/') != -1;
|
return url.indexOf('api.asm.skype.com/v1/objects/') != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isGfycatUrl(url) {
|
||||||
|
return url.indexOf('gfycat.com/') != -1;
|
||||||
|
}
|
||||||
|
|
||||||
function isCoolUrl(url, callback) {
|
function isCoolUrl(url, callback) {
|
||||||
url = url.toLowerCase();
|
url = url.toLowerCase();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue