I want to download the subtitle of a YouTube playlist with the following specifications:
- Only in English
- In srt format
- Just the subtitles files and not the video itself
I have tried the following code snippet. But it is downloading the subtitles in all available languages and in vtt format.
ydl_opts = {
'allsubtitles': True,
'writesubtitles': True,
'convertsubtitles':True,
'skip_download':True,
'outtmpl': 'C:/Users/shrayani.mondal/Desktop/Personal/Python Projects/Speech to text/Subtitles/%(title)s.%(ext)s',
#'subtitlesformat': 'srt'
'subtitleslangs':'en',
'postprocessors': [{
'key': 'FFmpegSubtitlesConvertor',
'format': 'srt',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=Lp7E973zozc&list=PLQltO7RlbjPJnbfHLsFJWP-DYnWPugUZ7'])
My second objective is to use auto-generated English subtitles for videos that do not have subtitles available. How do I include the if statement for that?