Skip to content

Instantly share code, notes, and snippets.

@armanbilge
Created April 7, 2015 00:19
Show Gist options
  • Save armanbilge/961dc674ab8401d2ce8a to your computer and use it in GitHub Desktop.
Save armanbilge/961dc674ab8401d2ce8a to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
Encoding.default_external = "UTF-8"
i = 0
puts STDIN.read.sub(/(WEBVTT\s+)(\d{2}:)/){|s| "#{$2}"}.gsub(/(\d{2}:\d{2})\.(\d{3}\s+)-->(\s+\d{2}:\d{2})\.(\d{3}\s*)/) { |s|
"#{i+=1}\n#{s.sub(/(\d{2}:\d{2})\.(\d{3}\s+)-->(\s+)(\d{2}:\d{2})\.(\d{3}\s*)/){|t| "00:#{$1},#{$2}-->#{$3}00:#{$4},#{$5}"}}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment