Skip to content

Instantly share code, notes, and snippets.

@josenaves
Forked from aanton/10gen-extract-videos.js
Last active December 19, 2015 20:49
Show Gist options
  • Save josenaves/6015808 to your computer and use it in GitHub Desktop.
Save josenaves/6015808 to your computer and use it in GitHub Desktop.
/*
Instructions:
1. Log in with your account and go to the desired course
2. Open the courseware tab
3. Configure the week variable
4. Copy this code and paste it in the browser console
*/
var week = 1;
var urls = [];
jQuery('nav ul[role=tabpanel]:eq(' + (week-1) + ') li').each(function() {
urls.push(jQuery(this).find('a').attr('href'));
});
var codes = [];
var regex = /data-streams="1.0:(.*?)"/gi, result;
jQuery.each(urls, function (index, value) {
jQuery.ajax(value, {
'async': false,
'dataType': 'html',
'success': function(data) {
while ( (result = regex.exec(data)) )
{
codes.push(result[1]);
}
}
});
// return false; // break bucle
});
jQuery.each(codes, function(index, value) {
console.log('youtube-dl --write-sub http://www.youtube.com/watch?v=' + value);
});
console.log('Number of videos in the week ' + week + ': ' + codes.length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment