Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download YouTube subtitles using excel vba

Tags:

youtube

excel

vba

I have the following code that download xml file with the subtitle of a video from YouTube

Sub Test()
Dim http        As Object
Dim oStream     As Object

Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "http://video.google.com/timedtext?lang=en&v=qANA6POtuFo", False
http.send
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write http.responseBody

oStream.SaveToFile ThisWorkbook.Path & "\Sample.xml", 2
oStream.Close
End Sub

But it doesn't work for other videos for example I tried this link v=4Z3EJrh7_5k

Any idea how to do the download with any video with a subtitle?

like image 541
YasserKhalil Avatar asked Jul 22 '18 06:07

YasserKhalil


People also ask

Is it possible to download YouTube subtitles?

YouTube offers viewers the option to download a video's subtitles as text, provided that the video's creator has already added those subtitles to their video file.

How do I extract subtitles from YouTube?

Select the pencil icon (Details) for the video you want to edit. Select Subtitles and Click on EDIT. To download the subtitles (caption) without the time stamp, click EDIT AS TEXT. Note: To download the subtitles with time stamp, click 3 dots next to “Edit as Text.”


1 Answers

As far as I researched, you cannot download from 4Z3EJrh7_5k because it's subtitle is not a file someone uploaded, but it is generated automatically.

To see if a video has any subtitle file, you can use http://video.google.com/timedtext?type=list&v=qANA6POtuFo, and it will list every file with languages inserted in the video. You can note that it shows only one, even if you go to the video and click, there are two (English and English (Automatically generated))

like image 60
Moacir Avatar answered Oct 16 '22 06:10

Moacir