How To Extract the Transcript for Captions on YouTube Videos
Finally, as I was writing this, I learned that you can simply enter the following JavaScript into the Console of the developer tools in your browser.
if(yt.config_.TTS_URL.length) window.location.href=yt.config_.TTS_URL+"&kind=asr&fmt=srv1&lang=en"On a Mac, you enter it here:
- Chrome: View > Developer > JavaScript Console
- Firefox: Tools > Web Developer > Web Console
- Safari: Develop > Show Web Inspector
Note that the JavaScript above ends with lang=en, meaning the language is English. If the transcript is in a different language, replace “en” with the two letter language code of the language you want to retrieve. For example, “ar” for Arabic or “es” for Spanish.
YouTube Example: https://www.youtube.com/watch?v=A4D4I0qNEYU
Example Raw Transcript: https://www.youtube.com/api/timedtext?v=A4D4I0qNEYU&key=yttt1&sparams=asr_langs%2Ccaps%2Cv%2Cxoaf%2Cxorp%2Cexpire&expire=1549420733&signature=20C1932AD521B297CF6683D461CB580538C0156A.E99BA7F7D42647E7CE68DB1C1F6DDC060FC306F9&xorp=True&xoaf=1&caps=asr&hl=en&asr_langs=ko%2Cit%2Cde%2Cja%2Cen%2Ces%2Cnl%2Cfr%2Cru%2Cpt&lang=en&name=en&fmt=srv3