Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > BotCompany Repo | #1023389 // Make .srt from text file

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (6721L/48K).

1  
!7
2  
3  
p-exp {
4  
  new L<PairS> out1;
5  
  for (S line : tlft(userDir("Documents/give it away.txt"))) {
6  
    continue if startsWith(line, "[");
7  
    PairS p = splitAtFirstSpace(line);
8  
    continue unless p != null;
9  
    if (!regexpMatches("\\d:\\d\\d", p.a))
10  
      continue with print("Weird: " + p);
11  
    out1.add(p);
12  
  }
13  
  
14  
  new LS out;
15  
  for i over out1: {
16  
    PairS p = out1.get(i);
17  
    S nextTime = pairA(get(out1, i+1));
18  
    int minute = parseInt(substring(p.a, 0, 1));
19  
    int second = parseInt(substring(p.a, 2));
20  
    
21  
    second += 2;
22  
    if (second >= 60) { second -= 60; ++minute; }
23  
    S endTime = minute + ":" + formatInt(second, 2);
24  
    if (nextTime != null && cmp(endTime, nextTime) > 0) endTime = nextTime;
25  
    out.add("");
26  
    out.add(str(i+1));
27  
    out.add("00:0" + p.a + ",000 --> 00:0" + endTime + ",000");
28  
    out.add(p.b);
29  
  }
30  
  printLines(out);
31  
  saveTextFileVerbose(programDir("give it away.srt"), lines(out));
32  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023389
Snippet name: Make .srt from text file
Eternal ID of this version: #1023389/6
Text MD5: 0e4d6b8106f0e54f43a5ea8b488274c6
Transpilation MD5: f396b4f0b3a8009a0325043d3273fcf0
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-16 01:29:52
Source code size: 956 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 224 / 743
Version history: 5 change(s)
Referenced in: [show references]