Skip to content

Instantly share code, notes, and snippets.

@FiXato
Created August 22, 2009 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FiXato/172984 to your computer and use it in GitHub Desktop.
Save FiXato/172984 to your computer and use it in GitHub Desktop.
A srt merge script made for some user on IRC.
#!/usr/bin/env ruby
orig_lines = File.read('24_Hour_Party_People.srt').strip.split("\r\n\r")
replacement_lines = File.read('24_Hour_Party_People_utf8.txt').strip.split("\n\n")
File.open('24ppl.srt','w') do |f|
orig_lines.each_with_index do |l,i|
l.strip!
srt = l.split("\n")
next unless replacement_lines[i]
nsrt = replacement_lines[i].split("\n")
f.puts(srt[0])
f.puts(srt[1])
f.puts(nsrt[2..(nsrt.size-1)])
f.puts
end
end
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment