#!/usr/bin/ruby =begin Copyright 2010, Roger Pack This file is part of Sensible Cinema. Sensible Cinema is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Sensible Cinema is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Sensible Cinema. If not, see . =end require File.dirname(__FILE__) + "/../lib/add_any_bundled_gems_to_load_path.rb" require 'sane' Thread.abort_on_exception=true # gah for file in ['overlayer', 'keyboard_input', 'screen_tracker', 'mouse', 'file_chooser', 'ocr', 'vlc_programmer'] require_relative '../lib/' + file end def go_sc(args) $VERBOSE = 1 if args.delete('-v') $DEBUG = 1 if args.delete('-d') if args.delete('--clear-cache') OCR.clear_cache! puts 'cleared cache' end $stderr.puts 'warning: currently windows only for certain parts currently' unless ENV['OS'] == 'Windows_NT' if args.detect{|arg| arg == '-h' || arg == '--help'} puts <<-END syntax: [player_description.yml] [delete_list.txt|test] [-t -v --clear-cache] (or just nothing at all--it will prompt for all things needed) If you specify "test" for the edit list, it will pause 4s, take a snapshot of the player, then exit. Useful for debugging your screen capture of the current player. You can also specify -v or -t if you want to enable more verbose (chatty) output. END for file in Dir[__dir__ + '../zamples/mute*/*'] puts "\n", "Example file:", file + "\n\n", File.read(file) end exit 1 else # allow for command line filenames player_description = args.shift.to_s if !File.exist?(player_description) puts 'Please Select Computer Player' player_description = FileChooser.choose_file(" SELECT COMPUTER PLAYER", __dir__ + "/../zamples/players") end edit_decision_list = args.shift.to_s if edit_decision_list == 'test' overlay = nil p 'got test...just doing screen dump' $VERBOSE=true # adds some extra output else if !File.exist? edit_decision_list puts 'Select Edit Decision List' edit_decision_list = FileChooser.choose_file(" SELECT EDIT DECISION LIST", __dir__ + "/../zamples/edit_decision_lists") end if !edit_decision_list puts "error: have to specify a scene descriptions file\n or specify \"test\" on the command line if you just want to snapshot your player" exit 1 end puts 'Selected scene descriptions file ' + File.basename(edit_decision_list) + "\n\t(full path: #{edit_decision_list})" Blanker.startup # todo start it late as it has an annoying startup blip overlay = OverLayer.new(edit_decision_list ) end if File.exist? player_description.to_s puts 'Selected player ' + File.basename(player_description) + "\n\t(full path: #{player_description})" # this one doesn't use any updates, so just pass in file contents, not filename screen_tracker = ScreenTracker.new_from_yaml File.binread(player_description), overlay does_not_need_mouse_jerk = YAML.load_file(player_description)["does_not_need_mouse_movement"] unless does_not_need_mouse_jerk p 'yes using mouse jitter' if $VERBOSE or $DEBUG Mouse.jitter_forever_in_own_thread # when this ends you know a snapshot was taken... else p 'not using mouse jitter' if $VERBOSE or $DEBUG end # exit early if we just wanted a screen dump...a little kludgey... unless overlay puts 'warning--only doing screen dump in t-minus 2s...' sleep 2 puts 'snap!' screen_tracker.dump_bmps exit 1 end screen_tracker.process_forever_in_thread else puts 'warning--not using any screen tracking...' end OCR.unserialize_cache_from_disk # do this every time so we don't delete it if they don't have one... puts "Opening the curtains... (please play in your other video player now)" overlay.start_thread true key_input = KeyboardInput.new overlay key_input.start_thread # status thread at_exit { Blanker.shutdown # lodo move this and the 'q' key to within overlayer OCR.serialize_cache_to_disk } begin key_input.handle_keystrokes_forever # blocking... ensure puts "syntax from command line: \"#{player_description}\" \"#{edit_decision_list}\"" end end end if __FILE__ == $0 puts 'Welcome to Sensible Cinema...' go_sc ARGV end