@joegesualdo/get-youtube-subtitle-url-node

Get the url for a youtube video's subtitles.

Stats

StarsIssuesVersionUpdatedCreatedSize
@joegesualdo/get-youtube-subtitle-url-node
900.1.04 years ago5 years agoMinified + gzip package size for @joegesualdo/get-youtube-subtitle-url-node in KB

Readme

get-youtube-subtitle-url Build Status

Get the url for a youtube video's subtitles.

Install

$ npm install --save @joegesualdo/get-youtube-subtitle-url-node

Usage

import getYoutubeSubtitleUrl from '@joegesualdo/get-youtube-subtitle-url-node';

const videoId ='7W-d2gtis7k'
getYoutubeSubtitleUrl('TImPW-khOww')
.then((result) => {
  console.log(result)
  // {
  //   automaticallyGenerated: false,
  //   url: 'https://www.youtube.com/api/timedtext?lang=en&fmt=vtt&name=&v=TImPW-khOww'
  // }
})
.catch(err => {
  // Executed if subtitles are not available for this video.
})

API

getYoutubeSubtitleUrl(videoId, opts)

Fetches the url for the subtitles

Name Type Description
videoId String The id of the youtube video

Returns: Object, with the url and whether or not the subtitles were automatically generated.

Options
Name Type Default Options Description
type String either auto, nonauto, either The type of subtitles
import getYoutubeSubtitleUrl from '@joegesualdo/get-youtube-subtitle-url-node';

const videoId ='TImPW-khOww'
getYoutubeSubtitleUrl('TImPW-khOww', {type: 'nonauto'})
.then((result) => {
  console.log(result)
  // {
  //   automaticallyGenerated: false,
  //   url: 'https://www.youtube.com/api/timedtext?lang=en&fmt=vtt&name=&v=TImPW-khOww'
  // }
})
.catch(err => {
  // Executed if subtitles are not available for this video.
})

Test

$ npm test

License

MIT © Joe Gesualdo

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.