Previously, I watched the TED video about how school education kills creativity.
The video is good, and there are also Chinese subtitles. Download the HD version is also available below.
Unfortunately, subtitles cannot be downloaded. (Or I cannot find it)
As the saying goes, do it yourself. Use Firebug to find the subtitle file address, download it, and see that it is in JSON format. Then, you can directly use JS output strings to convert it to srt Subtitles.
The Code is as follows. The code is very simple and practical. Without efficiency, security, and boundary problems, you can solve your problem as quickly as possible ~
I have to say that it makes sense to learn a programming language. Whatever it is, it can easily solve some practical problems. This is a pleasure.
JS is a very powerful language. It is very convenient to process JSON and XML, and most of the time it is enough. However, there will always be many defects, especially for system operations. However, if it is Microsoft's JScript, you can do it too. I used to want to learn Python, and now I feel calm. I just like what I use. Maybe, this is related to I no longer engage in IT-related industries. Enough ~
Copy codeThe Code is as follows:
// Read the chi_hans File
$. GetJSON ("chi_hans", function (json ){
Var c = json. captions, o = [];
For (var I = 0, l = c. length; I <l; I ++ ){
O. push (I + 1 );
// Here 18500 is the Time Offset
O. push (timeline (c [I]. startTime + 18500) + "-->"
+ Timeline (c [I]. startTime + c [I]. duration + 18500 ));
O. push (c [I]. content );
O. push ("");
// If (I = 5) break;
}
// Output to a textarea
$ ("# Output"). text (o. join ("\ r "));
});
// Obtain the time in the srt subtitle based on the time in JSON.
Function timeline (time ){
T = new Date (time );
Return [
LeadZero (t. getUTCHours ()),
LeadZero (t. getUTCMinutes ()),
LeadZero (t. getUTCSeconds ())
]. Join (":") + "," + leadZero3 (t. getUTCMilliseconds ());
}
// Add the leading zero
Function leadZero (s ){
If (s <10 ){
Return "0" + s;
} Else {
Return s;
}
}
// This is also the leading zero, three-digit
Function leadZero3 (s ){
Var ret;
If (s <10 ){
Ret = "00" + s;
} Else if (s <100 ){
Ret = "0" + s;
} Else {
Ret = s;
}
Return ret;
}