Browse files

Added option for forced subtitles download

  • Loading branch information...
1 parent a8369eb commit f268a3925301f4ec293652bb1463764e32b90ec0 @zewelor zewelor committed Aug 17, 2012
Showing with 6 additions and 1 deletion.
  1. +4 −0 bin/suby
  2. +2 −1 lib/suby.rb
View
4 bin/suby
@@ -13,6 +13,10 @@ option_parser = OptionParser.new do |opts|
options[:lang] = lang
end
+ opts.on '-f', '--force', 'Force subtitles download even if already exists' do |lang|
+ options[:force] = true
+ end
+
opts.on '-h', '--help', 'Show usage' do
puts opts
exit
View
3 lib/suby.rb
@@ -15,13 +15,14 @@ class << self
include Interface
def download_subtitles(files, options = {})
+ Zip.options[:on_exists_proc] = options[:force]
files.each { |file|
file = Path(file)
if file.dir?
download_subtitles(file.children, options)
elsif SUB_EXTENSIONS.include?(file.ext)
# ignore already downloaded subtitles
- elsif SUB_EXTENSIONS.any? { |ext| f = file.sub_ext(ext) and f.exist? and !f.empty? }
+ elsif !options[:force] and SUB_EXTENSIONS.any? { |ext| f = file.sub_ext(ext) and f.exist? and !f.empty? }
puts "Skipping: #{file}"
elsif !file.exist? or video?(file)
download_subtitles_for_file(file, options)

0 comments on commit f268a39

Please sign in to comment.