yt-script is a command-line tool for fetching and formatting YouTube video transcripts. It supports multiple languages, various output formats, and optional translation of transcripts.
- Fetches transcripts for YouTube videos.
- Supports multiple languages.
- Outputs transcripts in various formats (pretty, JSON, plain text).
- Option to translate transcripts to different languages.
- Lists available languages for transcripts.
To install yt-script
globally, run:
npm install -g .
To install yt-script
locally for development or testing, run:
npm install .
The basic command to fetch a transcript is:
yt-script <video_id_or_url>
--list-transcripts
: List available languages for the given videos.--languages <languages...>
: List of languages in descending priority (default:['en']
).--format <format>
: Output format (pretty
,json
,text
, default:pretty
).--translate <language>
: Language to translate the transcript to.
-
Fetch transcript in default format (pretty):
yt-script https://www.youtube.com/watch?v=abcd1234EFG
-
Fetch transcript in JSON format:
yt-script https://www.youtube.com/watch?v=abcd1234EFG --format json
-
Fetch transcript and translate to French:
yt-script https://www.youtube.com/watch?v=abcd1234EFG --translate fr
-
List available languages for a video:
yt-script https://www.youtube.com/watch?v=abcd1234EFG --list-transcripts
-
Fetch transcript with multiple languages prioritized:
yt-script https://www.youtube.com/watch?v=abcd1234EFG --languages en fr de
For development, clone the repository and install the dependencies:
git clone https://github.com/zshmeta/ytScript.git
cd ytScript
npm install
Run the script locally:
node index.js <video_id_or_url>