Class: Gifboard
- Inherits:
-
Storyboard
- Object
- Storyboard
- Gifboard
- Defined in:
- lib/gifboard.rb
Constant Summary
Constants inherited from Storyboard
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#capture_points ⇒ Object
Returns the value of attribute capture_points.
-
#length ⇒ Object
Returns the value of attribute length.
-
#mime ⇒ Object
Returns the value of attribute mime.
-
#options ⇒ Object
Returns the value of attribute options.
-
#renderers ⇒ Object
Returns the value of attribute renderers.
-
#subtitles ⇒ Object
Returns the value of attribute subtitles.
-
#timings ⇒ Object
Returns the value of attribute timings.
Attributes inherited from Storyboard
Instance Method Summary collapse
- #choose_text ⇒ Object
-
#initialize(o) ⇒ Gifboard
constructor
A new instance of Gifboard.
- #run ⇒ Object
Methods inherited from Storyboard
#check_video, #cleanup, #consolidate_frames, current_encoding, current_encoding=, encode_regexp, encode_string, #extract_frames, ffprobe_installed?, #get_subtitles, magick_installed?, #mkv?, mkvtools_installed?, mp4box_insatlled?, needs_KFhimaji, path, #render_output, #run_scene_detection, #setup, #video_file?
Constructor Details
#initialize(o) ⇒ Gifboard
Returns a new instance of Gifboard.
24 25 26 |
# File 'lib/gifboard.rb', line 24 def initialize(o) super end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
22 23 24 |
# File 'lib/gifboard.rb', line 22 def cache @cache end |
#capture_points ⇒ Object
Returns the value of attribute capture_points.
21 22 23 |
# File 'lib/gifboard.rb', line 21 def capture_points @capture_points end |
#length ⇒ Object
Returns the value of attribute length.
22 23 24 |
# File 'lib/gifboard.rb', line 22 def length @length end |
#mime ⇒ Object
Returns the value of attribute mime.
22 23 24 |
# File 'lib/gifboard.rb', line 22 def mime @mime end |
#options ⇒ Object
Returns the value of attribute options.
21 22 23 |
# File 'lib/gifboard.rb', line 21 def @options end |
#renderers ⇒ Object
Returns the value of attribute renderers.
22 23 24 |
# File 'lib/gifboard.rb', line 22 def renderers @renderers end |
#subtitles ⇒ Object
Returns the value of attribute subtitles.
21 22 23 |
# File 'lib/gifboard.rb', line 21 def subtitles @subtitles end |
#timings ⇒ Object
Returns the value of attribute timings.
21 22 23 |
# File 'lib/gifboard.rb', line 21 def timings @timings end |
Instance Method Details
#choose_text ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/gifboard.rb', line 69 def choose_text matches = [] @subtitles.pages.each {|x| found = !x.lines.select {|l| l.downcase.match([:text].downcase) }.empty? matches << x if found } match = nil if matches.count == 0 raise "No matches found" elsif matches.count == 1 puts "Just one match found. Using it." match = matches.first else puts "Multiple matches found.. pick one!" matches.each_with_index {|m,i| print "#{i+1}:\t" m.lines.each_with_index{|l,j| print "\t" if j > 0 puts l } } while !match print "choice (default 1): " input = gets.chomp number = input.empty? ? 1 : input.to_i if number > matches.count || number < 1 puts "Try again. Choose a subtitle between 1 and #{matches.count}" else match = matches[number-1] end end end match end |
#run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/gifboard.rb', line 28 def run LOG.info("Processing #{[:file]}") setup @cache = Cache.new(Suby::MovieHasher.compute_hash(Path.new([:file]))) LOG.debug() if [:verbose] @subtitles = SRT.new([:subs] ? File.read([:subs]) : get_subtitles, ) # bit of a temp hack so I don't have to wait all the time. @subtitles.save if [:verbose] @cache.save if @options[:text] @renderers << Storyboard::GifRenderer.new(self) selected = choose_text @capture_points << selected.start_time (0.1).step(selected.end_time.value - selected.start_time.value, 0.1) {|i| @capture_points << selected.start_time + i } # @capture_points << selected.end_time not sure if it's better or worse to leave this yet @stop_frame = @capture_points.count extract_frames render_output else @subtitles.pages.each {|x| print "[#{x.start_time.to_srt}]\t" x.lines.each_with_index{|l,i| print "\t\t" if i > 0 puts l } } puts "\n\nYou need to specify what text to look for with the -t option. Listing all subtitles instead." puts "ex: gifboard -t 'a funny joke ha. ha' video.mkv" end end |