Coder Social home page Coder Social logo

gijigae / youtube-subtitles-downloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eliascotto/youtube-subtitles-downloader

0.0 1.0 0.0 46 KB

Node library for download subtitles from Youtube and translate them or convert to SRT. Also available as CLI

License: MIT License

JavaScript 100.00%

youtube-subtitles-downloader's Introduction

Youtube Subtitles Downloader

dependencies Status devDependencies Status

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

Install

npm install youtube-subtitles-downloader

install global for use the CLI

npm install -g youtube-subtitles-downloader

Usage example

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

YTSubtitles

async YTSubtitles.getSubtitles(videoID, languageCode)

Download the subtitles of the video using the optional language code

Params
  • videoID: YouTube video ID
  • languageCode (optional): language code of the subtitles to return
Return

Array with the fetched subtitles content

async YTSubtitles.getLanguagesList(videoID)

Get the languages list for the video

Params
  • videoID: YouTube video ID
Return

An array of subtitles objects (YTSub)

YTSubtitles.extractIdFromUrl(url)

Extract the video ID

Params
  • url: YouTube video URL
Return

String video ID

YTSub

async fetch()

Download the subtitles of the video

Return

Array with the fetched subtitles content

async fetchSRT()

Download the subtitles of the video in SRT format

Return

Array with the fetched subtitles content in SRT format

async translate(languageCode)

Translate the subtitle into another language returning a new YTSub object

Params
  • languageCode: Language code for translation
Return

A new YTSub object constructed with the new language

Properties

translationLanguages

List of languages object available for translate the subtitles

languageCode, languageName, languageId

Code, name and vvsId of the subtitles retrieved from YouTube

isTranslatable

Is current language is translatable

CLI

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

youtube-subtitles-downloader's People

Contributors

eliascotto avatar elias94 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.