Firebug subtitle file JSON address get code _javascript tips

Source: Internet
Author: User
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.