9842e52806775f67c20ece81ca43307136ae8021
Changed the file mode from 100644 (non-executable) to 100755 (executable) to allow the script to be run directly.
YouTube Transcript Downloader and Translator
A Python program to download YouTube video transcripts and translate them to English.
Features
- Extract YouTube video ID from various URL formats
- Download video transcripts in multiple languages
- Save transcripts to text files
- Support for timestamped output
- Automatic translation to English using Google Translate
- Language detection to determine if translation is needed
Installation
- Install the required dependencies:
pip install -r requirements.txt
Or install directly:
pip install youtube-transcript-api deep-translator
Usage
Command Line
python youtube_transcript_downloader.py <youtube_url>
Interactive Mode
If no URL is provided, the program will prompt you to enter one:
python youtube_transcript_downloader.py
Examples
# Using a standard YouTube URL
python youtube_transcript_downloader.py https://www.youtube.com/watch?v=dQw4w9WgXcQ
# Using a shortened youtu.be URL
python youtube_transcript_downloader.py https://youtu.be/dQw4w9WgXcQ
Output
The program will:
- Display the transcript in the terminal
- Save the transcript to a file named
transcript_<video_id>.txt - If translation is needed, prompt the user to translate to English
- Save both original and translated transcripts to separate files
Notes
- The video must have captions/subtitles available for transcript extraction
- The program first tries to fetch English transcripts
- If no English transcript is available, it will try to get the original language
- The program automatically detects if translation is needed and prompts to translate to English
- For videos without English captions, the program will prompt you to translate the transcript
Requirements
- Python 3.6+
- youtube-transcript-api
- deep-translator
Description
Languages
Python
100%