Created
September 8, 2011 23:37
-
-
Save bmatsuo/1205104 to your computer and use it in GitHub Desktop.
Windows capable PopenRunner subclass for the handbrake ruby gem.
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
require "rubygems" | |
require "handbrake" | |
require 'rbconfig' | |
$on_mswin = Config::CONFIG['target_os'].match(/^mingw/) | |
require 'win32/open3' if $on_mswin | |
class MyRunner < HandBrake::CLI::PopenRunner | |
def command(args) | |
return super if !$on_mswin | |
"\"#{args.unshift(@cli.bin_path).collect { |a| a.gsub(%r(")) { %('""') } }.join('" "')}\"" | |
end | |
end | |
hb_path = "HandBrakeCLI.exe" | |
raise Exception, "No HandBrakeCLI executable" if !File.exists?(hb_path) | |
hb = HandBrake::CLI.new( | |
:bin_path => hb_path, | |
:runner => lambda { |cli| MyRunner.new(cli) }, | |
:trace => false | |
) | |
puts "HandBrakeCLI is #{hb.update ? "not " : ""}up to date." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment