Class: Yt2srt
- Inherits:
-
Object
- Object
- Yt2srt
- Defined in:
- lib/yt2srt.rb
Overview
Main Yt2srt class, contains helper methods to convert Youtube Captions subtitles to SubRip (.srt) format
Class Method Summary collapse
-
.convert(input_file, output_file) ⇒ Object
Main method, used to convert Youtube Captions subtitles to SubRip (.srt) format.
Class Method Details
.convert(input_file, output_file) ⇒ Object
Main method, used to convert Youtube Captions subtitles to SubRip (.srt) format
Example:
>> Yt2srt.convert(input, output)
Arguments:
input_file: (String)
output_file: (String)
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/yt2srt.rb', line 66 def self.convert(input_file, output_file) puts "Starting conversion: #{input_file} --> #{output_file}" text=File.open(input_file).read ofx= File.open(output_file, 'w') text.gsub!(/\r\n?/, "\n") text.each_line.with_index(1) do |line, index| newLine = convert_line(index, line); ofx << newLine end ofx.close puts "Conversion completed successfully!" end |