Created
May 4, 2023 22:41
-
-
Save exegeteio/c8d9337e2518b4be79d3678879219b2e to your computer and use it in GitHub Desktop.
SRT Formatter for Matty Twoshoes on twitch.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "csv" | |
# Going to store each line into an array. | |
output = [] | |
# Loop over input from STDIN | |
ARGF.each do |line| | |
# Removes newlines and such. | |
line.chomp! | |
# If a blank line, output and continue skip the rest. | |
if line == "" | |
puts (output[0..2] + [output[3..].join(" ")]).to_csv | |
output = [] | |
next | |
end | |
# Process timestamps if this matches. | |
if line.match(/ --> /) | |
output += line.split(/ --> /) | |
next | |
end | |
# Append to the array. | |
output << line | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment