2

I'm on Fedora 28 OS and have youtube-dl version 2019.03.18 and I wanted to download all the subs and only the subs of a Crashcourse playlist off of youtube, consisting of 45 videos.

I want all the subs to be written in a single *.txt file so that I can then edit it and print-it-to-pdf format (with evince), also applying the appropriate page numbering/header/footer.

I tried the following:

youtube-dl --skip-download --write-sub --playlist-items 6-10 <PLAYLIST-URL> >> all-subs.txt

This however only wrote the 'verbose' output to all-subs.txt and just downloaded the *.vtt format subs (I don't know why youtube-dl won't download in any other format, even if told to do so, a glitch still unresolved).

1

It seems that youtube-dl doesn't support such feature, but you can use cat to concatenate all the downloaded files:

$ youtube-dl --output '%(autonumber)s.%(ext)s' --skip-download --write-sub 'https://www.youtube.com/watch?v=-5wpm-gesOY' 'https://www.youtube.com/watch?v=w3_0x6oaDmI'
[youtube] -5wpm-gesOY: Downloading webpage
[youtube] -5wpm-gesOY: Downloading video info webpage
[info] Writing video subtitles to: 00001.en-GB.vtt
[youtube] w3_0x6oaDmI: Downloading webpage
[youtube] w3_0x6oaDmI: Downloading video info webpage
[info] Writing video subtitles to: 00002.en.vtt
$ cat ./* > all-subs.vtt

Note that %(autonumber)s is needed to concatenate the files in order. When downloading from playlists, you may use %(playlist_index)s instead.


I don't know why youtube-dl won't download in any other format, even if told to do so, a glitch still unresolved

While it's possible to request a specific format using the --sub-format option, please note that the availability of such format depends on the website. YouTube only offers ttml and vtt files, as far as I can tell (and I'm able to download subtitles in both formats):

$ youtube-dl --list-subs 'https://www.youtube.com/watch?v=-5wpm-gesOY'
...
Available subtitles for -5wpm-gesOY:
Language formats
en-GB    vtt, ttml
ru       vtt, ttml
fr       vtt, ttml
...
$ youtube-dl --output '%(autonumber)s.%(ext)s' --skip-download --sub-format 'vtt' --write-sub 'https://www.youtube.com/watch?v=-5wpm-gesOY'
[youtube] -5wpm-gesOY: Downloading webpage
[youtube] -5wpm-gesOY: Downloading video info webpage
[info] Writing video subtitles to: 00001.en-GB.vtt
$ youtube-dl --output '%(autonumber)s.%(ext)s' --skip-download --sub-format 'ttml' --write-sub 'https://www.youtube.com/watch?v=-5wpm-gesOY'
[youtube] -5wpm-gesOY: Downloading webpage
[youtube] -5wpm-gesOY: Downloading video info webpage
[info] Writing video subtitles to: 00001.en-GB.ttml
  • I'd like to edit out all the time stamped lines, leaving only the transcript. I've tried doing it with grep but is there another Linux CLI tool that can shorten the length of the file? – WobblyWindows Apr 14 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.