youtube-subs-json

Get captions as json from youtube by youtube-dl

Usage no npm install needed!

<script type="module">
  import youtubeSubsJson from 'https://cdn.skypack.dev/youtube-subs-json';
</script>

README

youtube-subs-json

Get captions as json from youtube by youtube-dl

Installation

  • > npm install youtube-subs-json

Usage


const getSubtitles = require('youtube-subs-json').getSubtitles;

getSubtitles({
  videoID: 'XXXXX', // youtube video id or url
  lang: 'ru' // default: `en`
}).then( captions => {
  console.log(captions)
}).catch( err => {
  console.error(err)
})

Captions will be an array of object of this format:

{
  "begin": String, // 00:00:03.419
  "end": String,   // 00:00:10.320
  "start": Number, // 3.419
  "dur": Number,   // 6.901
  "text": String   // some phrase
}