Created
November 7, 2022 09:30
-
-
Save Sen/a47dab5f9929dd374f41354c8ad57c24 to your computer and use it in GitHub Desktop.
fix subtitle
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
#!/usr/bin/env ruby | |
# sync subtitle with https://github.com/smacke/ffsubsync | |
video_ext = %w(mp4 mkv avi) | |
subtitle_ext = %w(srt ssa ass) | |
work_hash = [] | |
files = Dir[Dir.pwd + '/*'] | |
video_files = files.select do |file_name| | |
video_ext.include?(file_name.split('.')[-1]) | |
end | |
video_files.each do |filename| | |
if /s\d+?e(\d+)/ =~ filename.downcase | |
number = $1 | |
subtitle_filename = files.select do |name| | |
subtitle_ext.include?(name.split('.')[-1]) && name.include?(number) && !name.include?('fixed') | |
end[0] | |
ext = subtitle_filename.split('.')[-1] | |
system "ffs #{filename} -i #{subtitle_filename} -o #{Dir.pwd}/fixed_#{number}.#{ext}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment