Anish Mazumdar
Anish Mazumdar

Reputation: 365

Downloading subtitles using youtube_dl

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.

Upvotes: 7

Views: 3566

Answers (1)

AllenMoh
AllenMoh

Reputation: 476

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}

Upvotes: 5

Related Questions