To summarize a given Youtube video, first I use “yt-dlp“ to download the video’s subtitle, then use AI to summarize its content. More details can be found in the following Python script.
# This script summarizes the content of a YouTube video using the DeepSeek API. # It reads the subtitle file of the video, sends it to the API for # summarization, and prints the summary. # # Please install OpenAI SDK first: # pip install openai # # You need to get an API key from "https://deepseek.com". Set it as an # environment variable named DEEPSEEK_API_KEY before running the # script: # export DEEPSEEK_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ## # Then run the current script with the subtitle file path as an argument: # python summarize_youtube_video.py path/to/subtitle_file.txt # # To get the YouTube video subtitle, run the following command in your terminal: # yt-dlp --write-subs --write-auto-subs --skip-download \ # -o "%(title)s.%(ext)s" --cookies-from-browser 'chrome' --sub-langs 'zh-Hans' \ # 'https://www.youtube.com/watch?v=abcdefghijkl' # # If it reports "There are no subtitles for the requested languages", run the # following command to list all subtitles and select the one you want: # yt-dlp --list-subs 'https://www.youtube.com/watch?v=abcdefghijkl'