Last active
August 21, 2018 00:34
-
-
Save XueshiQiao/5992949 to your computer and use it in GitHub Desktop.
combine WWDC subtitle files (fileSequence*.webvtt) to a srt file.
This file contains hidden or 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/ruby | |
docPath = "wwdc_srts" | |
#exclude . and .. folder | |
folders = Dir.entries(docPath).select{|folder| folder.to_i > 0} | |
folders.each{ |folder| | |
print folder | |
print "\n" | |
sequenceFilePath = docPath + "/" + folder | |
sequenceFiles = Dir.entries(sequenceFilePath).select{|file| file.length > 12} | |
fileCount = sequenceFiles.count | |
f = File.new(docPath + "/" + folder + ".srt", "w") | |
#combine sequence files to xxx.srt, xxx is video num, such as 210.srt. | |
for i in 0..fileCount-1 | |
out = File.open(sequenceFilePath + "/" + "fileSequence" + i.to_s + ".webvtt", "r"); | |
f.write(out.read); | |
out.close; | |
end | |
f.close | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@lexrus Cooool 受教