Node library for download subtitles from Youtube and translate them or convert to SRT. Also available as CLI. Partially used with the Youtube Subtitles Viewer Chrome extension
npm install youtube-subtitles-downloader
install global for use the CLI
npm install -g youtube-subtitles-downloader
const id = YTSubtitles.extractIdFromUrl('https://www.youtube.com/watch?v=vG-QZOTc5_Q')
YTSubtitles.getLanguagesList(id).then((resp) => {
resp[0].fetch().then(lang => {
console.log(lang)
// do something else with subtitles
})
})
using the CLI
$ ytsub uICEJnBuhy0 -l en
$ ytsub uICEJnBuhy0 -s
$ ytsub uICEJnBuhy0 -l en -s -o sub.srt
$ ytsub uICEJnBuhy0 -t el
$ ytsub list uICEJnBuhy0
$ ytsub list-translations uICEJnBuhy0
Download the subtitles of the video using the optional language code
videoID
: YouTube video IDlanguageCode
(optional): language code of the subtitles to return
Array with the fetched subtitles content
Get the languages list for the video
videoID
: YouTube video ID
An array of subtitles objects (YTSub)
Extract the video ID
url
: YouTube video URL
String video ID
Download the subtitles of the video
Array with the fetched subtitles content
Download the subtitles of the video in SRT format
Array with the fetched subtitles content in SRT format
Translate the subtitle into another language returning a new YTSub object
languageCode
: Language code for translation
A new YTSub object constructed with the new language
List of languages object available for translate the subtitles
Code, name and vvsId of the subtitles retrieved from YouTube
Is current language is translatable
Usage: ytsub [options] [command] <video-id>
Download YouTube video subtitles using the video id
Options:
-V, --version output the version number
-l, --language <language-code> Set subtitles language
-t, --translate <language-code> Translate subtitles in another language
-s, --srt Output in SRT format
-o, --output <path> Output file
-h, --help display help for command
Commands:
list <video-id> Get the list of available languages with codes and names
list-translations <video-id> Get the list of available languages for translation
Examples:
$ ytsub uICEJnBuhy0 -l en
$ ytsub uICEJnBuhy0 -s
$ ytsub uICEJnBuhy0 -l en -s -o sub.srt
$ ytsub uICEJnBuhy0 -t el
$ ytsub list uICEJnBuhy0
$ ytsub list-translations uICEJnBuhy0
Elia Scotto | Website