Skip to content

Instantly share code, notes, and snippets.

@jlewin
Last active December 10, 2015 23:28
Show Gist options
  • Save jlewin/4509284 to your computer and use it in GitHub Desktop.
Save jlewin/4509284 to your computer and use it in GitHub Desktop.
Extract a quote from YouTube transcripts
// Usage: Open the transcript view, select the line to start at, and call getQuoteFromVideo
// passing it just the number of lines to collect
// or
// Call getQuoteFromVideo passing it the number of lines to collect and an element id to start at
function getQuoteFromVideo(count, captionStartID){
var captionLine = document.querySelector(captionStartID || '.caption-line-highlight');
var text = '';
for(var i = 0; i < count && captionLine; i++){
text += captionLine.querySelector('.caption-line-text').textContent + ' ';
captionLine = captionLine.nextSibling;
}
// Trim newlines and return text
return text.replace(/\n/g, ' ');
}
// Start at a specific id
console.log(getQuoteFromVideo(20, '#cp-793'));
console.log('----');
// or start at the currently selected line
console.log(getQuoteFromVideo(20));
@jlewin
Copy link
Author

jlewin commented Jan 11, 2013

Built so I could extract this gem from Linus Torvalds
http://www.youtube.com/watch?v=WVTWCPoUt8w&feature=youtu.be&t=37m30s

You don't design software. You don't you know what it is the user wants. In most cases the user
himself doesn't know what he wants. I mean, how many people ever worked in a software project
where you knew what the end result would be, and you turned out to be right... There's not a single
person I think that has ever had that happen to them. That means that designing things doesn't
actually work because if you design things and you don't know what you're designing for, the design
simply cannot work.

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