Skip to content

Instantly share code, notes, and snippets.

@adammw
Created April 21, 2014 07:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adammw/11135063 to your computer and use it in GitHub Desktop.
Save adammw/11135063 to your computer and use it in GitHub Desktop.
PBS Video Extractor
// PBS Video Extractor
(function () {
var getVideoUrl = function (id, fn) {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://video.pbs.org/video/' + id + '.smil');
xhr.responseType = 'document';
xhr.onload = function () {
var videos = Array.prototype.slice.call(xhr.response.querySelectorAll('video'), 0);
videos.sort(function (a, b) {
if (a.getAttribute('width') > b.getAttribute('width')) return -1;
if (a.getAttribute('width') < b.getAttribute('width')) return 1;
return 0;
});
var url = 'http://ga.video.cdn.pbs.org/' + videos[0].getAttribute('src');
fn(url);
};
xhr.send();
};
getVideoUrl(jwSettings.videoId, function (url) {
location.href = url;
});
})();
@nmuldoon
Copy link

Very useful for getting around the region restrictions while travelling in Europe. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment