diff options
| author | Loek Le Blansch <loek@pipeframe.xyz> | 2026-08-02 14:48:29 +0200 |
|---|---|---|
| committer | Loek Le Blansch <loek@pipeframe.xyz> | 2026-08-02 14:48:29 +0200 |
| commit | e43eb1177872f52e949fb5f0f93396ed94b0d093 (patch) | |
| tree | 78b73af6a989fa2996d71b112e161b70d35081ef /home/dot_local/share/bin/executable_labels2lrc | |
| parent | 2f14a896e4b897bd747c24d7ad8e9e7bb3237d03 (diff) | |
move to chezmoi
Diffstat (limited to 'home/dot_local/share/bin/executable_labels2lrc')
| -rw-r--r-- | home/dot_local/share/bin/executable_labels2lrc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/home/dot_local/share/bin/executable_labels2lrc b/home/dot_local/share/bin/executable_labels2lrc new file mode 100644 index 0000000..c8abc1c --- /dev/null +++ b/home/dot_local/share/bin/executable_labels2lrc @@ -0,0 +1,30 @@ +#!/bin/python3 + +import re +import sys + +for line in sys.stdin: + line = line.rstrip("\n") + fields = line.split("\t") + + if len(fields) < 3: + continue + + time = fields[0] + + # Equivalent of: + # gensub(/([0-9]+)\.([0-9]{,2})([0-9]*)/, "\\1\\2.\\3", "g", time) + time = re.sub(r'(\d+)\.(\d{0,2})(\d*)', r'\1\2.\3', time) + + # AWK rounds by adding 0.5 then truncating. + time = int(float(time) + 0.5) + + millis = time % 100 + time //= 100 + + seconds = time % 60 + time //= 60 + + minutes = time % 100 + + print(f"[{minutes:02d}:{seconds:02d}.{millis:02d}]{fields[2]}") |