This repository contains a Python script that allows you to fetch video transcripts from a YouTube channel.
-
Clone the repository to your local machine using the following command:
git clone https://github.com/imomayiz/youtube_scraper.git
-
Navigate to the
youtube_scraper
directory: -
Install the necessary dependencies by running the following command:
pip install -r requirements.txt
-
Create a
.env
file in theyoutube_scraper
directory and add your YouTube API key. The.env
file should contain the following line:YOUTUBE_API_KEY=your-api-key
Replace
your-api-key
with your actual YouTube API key. For more details on how to create a youtube api key, follow this guide.
To fetch video transcripts from a YouTube channel, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the
youtube_scraper
directory:cd youtube_scraper
-
Run the following command to execute the script:
python ytb_scraper.py --channel_name "your-channel-name" --results_dir "path-to-save-transcripts" --max_videos 10
Replace
your-channel-name
with the name of the YouTube channel you want to fetch transcripts from. Replacepath-to-save-transcripts
with the directory where you want to save the transcripts. The--max_videos
argument is optional and allows you to limit the number of videos to fetch a transcript for. -
The script will start fetching the transcripts from all videos in the specified channel and save them in separate text files.
N.B. Not all videos have a transcript!