A previous look at the Ted video about school education kills creative video.
Video is good, there are Chinese subtitles and so on. Below also provides the high-definition version downloading, is very joyful.
Unfortunately, subtitles do not provide downloads. (or I didn't find it)
As the saying goes, own hands and clothing. Take Firebug directly to find the title file address, download down to see is JSON format, then think directly with JS output string can be converted to SRT subtitles.
Code as follows, very simple code, practical is good, do not seek efficiency, security and boundary issues, only the quickest to solve my problem ~
I have to say, learning a programming language is very meaningful, no matter what, can be very convenient to solve some practical problems. This is very happy.
JS is a very powerful language, very handy for processing JSON and XML, and most of the time it's enough. However, there will be inadequate time, especially for the operation of the system, there are always many defects. But if you count Microsoft's JScript, it's OK. Once wanted to learn python, now also calm, casually use anything, like the good. Perhaps this is related to my no longer engaged in it-related industries. enough to do it ~
Copy Code code as follows:
Read 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);
18500 Here is a time shift.
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;
}
Here I output to a textarea
$ ("#output"). Text (O.join ("\ R"));
});
This is based on the time in JSON to get the time in SRT subtitles.
function timeline (time) {
T=new Date (time);
return [
Leadzero (T.getutchours ()),
Leadzero (T.getutcminutes ()),
Leadzero (T.getutcseconds ())
].join (":") + "," +leadzero3 (T.getutcmilliseconds ());
}
Join leading zeros
function Leadzero (s) {
if (s<10) {
Return "0" +s;
}else {
return s;
}
}
This is also a leading zero, three-digit
function LeadZero3 (s) {
VAR ret;
if (s<10) {
Ret= "+s";
}else if (s<100) {
ret= "0" +s;
}else {
Ret=s;
}
return ret;
}