I was looking for a solution to write a script which warns if the embed video on the website has been deleted or removed on the video provider site such as Youtube, Vimeo.
I looked everywhere, but i cannot find any solution on this subject.
I was looking for a solution to write a script which warns if the embed video on the website has been deleted or removed on the video provider site such as Youtube, Vimeo.
I looked everywhere, but i cannot find any solution on this subject.
Check this out:
function isURLReal(fullyQualifiedURL) {
var URL = encodeURIComponent(fullyQualifiedURL),
dfd = $.Deferred(),
checkURLPromise = $.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22' + URL + '%22&format=json');
checkURLPromise
.done(function(response) {
// results should be null if the page 404s or the domain doesn't work
if (response.query.results) {
dfd.resolve(true);
} else {
dfd.reject(false);
}
})
.fail(function() {
dfd.reject('failed');
});
});
return dfd.promise();
}
// usage
isURLReal('http://google.com')
.done(function(result) {
// yes
})
.fail(function(result) {
// no, or request failed
});
Full details here : StackOverFlowLink