subtitle_scraper
The youtube api was being less of an API and more of a lamePI, so I created this. A module that will give you the captions/subitiles of a youtube video given the id
Install
npm install subtitle_scraper
Example
The module is very simple and hopefully self-explanitory based on this Example (using an Applied Science Video, check it out if you have time)
var subtitle_scraper = ; // In goes the youtube id, you can find this in the video url (usually "v=...");
Youtube will give data like so
today on Applied Science I'd like to talk about my adventures in making deco tape if you haven't heard deco tape is sort of an alternative to the currently available adhesive tapes it actually works by a different mechanism and it's not really a commercial product yet but it's got a lot of press Insert of popular science articles and so it has a few attractive qualities that make it
The module uses xml2js to parse the xml. If you think there is a better option feel free to do what you want with that information. The results from xml2js:
Bulk
It doesn't save any time, but this function allows you to get subtitles from a list of video ids. The function works just the same as before except with an array instead of a simple string and an options object is required
Here is an example:
var subtitle_scraper = ;// It is also possible now to provide a list of ids to get the subtitles for each// a delay can be provide and probably should be;
"options" can currently only provide a delay option. "delay" will result in a delay between requests
Note:
This module could stop working at any time really. If youtube changed the variable name of "ttsurl" to something like "banana" it would surely be useless.