Created
October 31, 2011 04:07
-
-
Save passingloop/1326892 to your computer and use it in GitHub Desktop.
iphone 動画変換作業用スクリプト
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 'tmpdir' | |
class MovieImporter | |
def initialize(src) | |
@src = src | |
end | |
def self.import(src) | |
MovieImporter.new(src).run | |
end | |
def run | |
Dir.mktmpdir do |tmpdir| | |
@tmpdir = tmpdir | |
IO.popen('osascript', 'w+') do |io| | |
io.puts(script) | |
end | |
end | |
end | |
private | |
def script | |
<<-EOS | |
tell application "QuickTime Player 7" | |
open "#{source_file_path}" | |
export document 1 to "#{target_file_path}" as iPhone with replacing | |
close document 1 | |
end tell | |
tell application "iTunes" | |
set m4v to POSIX file "#{target_file_path}" | |
add m4v | |
end tell | |
EOS | |
end | |
def source_file_path | |
File.expand_path(@src) | |
end | |
def target_file_path | |
File.expand_path(File.basename(@src) + '.m4v', @tmpdir) | |
end | |
end | |
if __FILE__ == $0 | |
ARGV.each do |movie_file| | |
MovieImporter.import(movie_file) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://d.hatena.ne.jp/passingloop/20111031/using_osascript_to_send_apple_events_from_ruby