Last active
August 2, 2020 22:54
-
-
Save kovacshuni/d3bdb376b7053923cfeccebf3ee6d5b5 to your computer and use it in GitHub Desktop.
subtitles-shift-up
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
# Appends a new line with a - to every frame of movie subtitles to shift | |
# the overall position up when the tv cuts down the bottom. | |
# | |
# ruby subtitles-shift-up.rb Titanic.srt | |
# or | |
# ruby subtitles-shift-up.rb Titanic.srt UTF-8 | |
# | |
# result: Titanic-shifted.srt | |
def addEmptyLine(inFile, outFile) | |
inFile.each_line do |line| | |
if line.strip.empty? | |
outFile.puts "-" | |
outFile.puts | |
else | |
outFile.puts line | |
end | |
end | |
end | |
inFile = | |
if ARGV[1].nil? | |
File.open(ARGV[0], "r", :encoding => ARGV[1]) | |
else | |
File.open(ARGV[0], "r", :encoding => 'ISO-8859-1') | |
end | |
outFile = File.open("#{ARGV[0]}-shifted.srt", "w", :encoding => 'UTF-8') | |
addEmptyLine(inFile, outFile) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment