Created
April 21, 2014 07:30
-
-
Save adammw/11135063 to your computer and use it in GitHub Desktop.
PBS Video Extractor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very useful for getting around the region restrictions while travelling in Europe. Thank you.