I am looking to download a video with subtitles using the Youtube_dl library. Currently, I am able to download a single video at a time but I am unable to download subtitles with it.
Currently, my implementation is:
import youtube_dl
link = input('Please enter a url link:\n')
youtube_dl_options = {}
with youtube_dl.YoutubeDL(youtube_dl_options) as youtube_dl_client:
youtube_dl_client.download([link])
I would like to be able to download the subtitle as well as the video with it.
The easiest way is to visit a subtitle website, search for your TV show or movie and download the SRT file. The two most popular sites for getting subtitles are Subscene and OpenSubtitles.org. On OpenSubtitles, perform a search and then you'll see all the available subtitles for different languages at the bottom.
The youtube_dl project is hosted on github (https://github.com/rg3/youtube-dl/blob/master/youtube_dl/YoutubeDL.py)
Looking at the YoutubeDL module it looks like there are a bunch of options (see lines 142-298, the one you want is on line 183).
You can pass the option using the dictionary ydl_opts
Try changing ydl_opts
to this:
ydl_opts = {"writesubtitles": True}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With