Fix "Unable to Find Package" NuGet Error in Visual Studio C#
There are a number of different approaches to getting subtitles for videos on YouTube. There is a wide variety of software available online that gives users the ability to download subtitles. If, on the other hand, you are already familiar with youtube-dl and wish to use it to download only subtitles from videos, then you have arrived at the correct location.
YouTube-dl is a command-line program that allows you to download videos and subtitles from YouTube.com and a few other video sites. It runs on Unix, Linux, Windows, and Mac OS X and requires only a Python interpreter (2.6, 2.6, or 3.2+).
In the youtube-dl documentation, there is clearly mention of Subtitle Options.
Subtitle-Options | Descriptions |
--write-sub | Write subtitle file |
--write-auto-sub | Create a file with automatically generated subtitles (YouTube only) |
--all-subs | Download all of the subtitles that are currently available for the video |
--list-subs | List all available subtitles for the video |
--sub-format FORMAT | Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best" |
--sub-lang LANGS | Languages of the subtitles to download(optional) separated by commas, use for available language tags |
So, let's play with these options for downloading subtitles only from Videos.
You can download all of the subtitles for a video with the following command if the owner/author of the YouTube video personally created the subtitles and added them along with the video.
youtube-dl --all-subs --skip-download VideoURL
Example:
youtube-dl --all-subs --skip-download https://www.youtube.com/watch?v=wdqapiuJmbQ
Here, —all-subs
tells YouTube to download all of the subtitles for video URL "https://www.youtube.com/watch?v=wdqapiuJmbQ" and —skip-download
tells it to stop downloading the video.
If the owner does not have any subtitles set manually, the above command will fail. YouTube will generate subtitle scripts for you in such videos. So, if you want to download these auto-generated subtitles, use the script below.
youtube-dl --write-auto-sub --skip-download VideoURL
Example:
youtube-dl --write-auto-sub --skip-download https://www.youtube.com/watch?v=Ns5YsDtzA4M
This youtube URL doesn't have subtitles so it will download auto-generated subtitles and also keep downloading the video.
It will list all of the video's subtitle languages and formats. The command for this is as follows:
youtube-dl --list-subs VideoURL
Example:
youtube-dl --list-subs https://www.youtube.com/watch?v=wdqapiuJmbQ
With the above, we have a video that has two languages en and es. So, let's download subtitles in Spanish Language(es) as shown below:
If you want auto-generated subtitles in es then use --write-auto-sub
instead of --write-sub
If you want to download only in srt format then you can use the below command:
youtube-dl --write-auto-sub --convert-subs=srt --sub-lang en --skip-download URL
For the video: https://www.youtube.com/watch?v=abcxyz, the file named will be abcxyz.en.srt
For this, you can combine both --write-sub and --write-auto-sub options in one command as shown below.
youtube-dl --write-sub --write-auto-sub --skip-download VIDEOURL
Conclusion:
This article might be helpful to you if you just want to download video subtitles only using youtube-dl
FAQ:
For various reasons, the video's author can disable automatic captioning. If they did not include manual subtitles, none are available.You will also be unable to download those types of subtitles. Also, there might be another reason like you might be using the wrong command for generating subtitles.