Class: Os
Class Method Summary collapse
- .check_for_sub(path, lang) ⇒ Object
- .default_movie_subtitle(path) ⇒ Object
-
.delete_video_default_subtitle(path) ⇒ Object
Receives the path of a movie file and deletes its subtitle.
- .download_subs(file) ⇒ Object
- .make_default_subtitle(path, lang) ⇒ Object
-
.se(command) ⇒ Object
Shell execute.
Class Method Details
.check_for_sub(path, lang) ⇒ Object
30 31 32 |
# File 'lib/os.rb', line 30 def check_for_sub(path, lang) File.exist?(path.sub(/#{File.extname(path)}$/i, ".#{lang}.srt")) end |
.default_movie_subtitle(path) ⇒ Object
6 7 8 |
# File 'lib/os.rb', line 6 def default_movie_subtitle(path) path.sub(/#{File.extname(path)}$/i, '.srt') end |
.delete_video_default_subtitle(path) ⇒ Object
Receives the path of a movie file and deletes its subtitle
11 12 13 14 |
# File 'lib/os.rb', line 11 def delete_video_default_subtitle(path) subtitle_file = default_movie_subtitle(path) rm(subtitle_file) if File.exist?(subtitle_file) end |
.download_subs(file) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/os.rb', line 34 def download_subs(file) delete_video_default_subtitle(file) Settings.langs.each do |lang| Sl.info "Language: #{lang}" se("getsub -aLl #{lang} \"#{file}\"") # Will to it just for the 1st time make_default_subtitle(file, lang) end end |
.make_default_subtitle(path, lang) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/os.rb', line 16 def make_default_subtitle(path, lang) # path = /tmp/a.avi # lang = por # /tmp/a.por.srt default_sub = default_movie_subtitle(path) specific_sub = path.sub(/#{File.extname(path)}$/i, ".#{lang}.srt") if File.exist?(specific_sub) and !File.exist?(default_sub) Sl.info "cp #{File.basename(specific_sub)} to #{File.basename(default_sub)}" cp specific_sub, default_sub return true end false end |