stage-manager/app/models/video.rb

36 lines
771 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'fileutils'
2023-03-04 11:14:54 -05:00
require 'kramdown'
require 'pandoc-ruby'
2023-03-04 11:14:54 -05:00
# Model handles Video projects
class Video < Sequel::Model
many_to_one :channel
def ensure_directory_structure
sub_dirs = %w[Audio B-Roll Clips Images Export]
sub_dirs.each do |d|
sub_path = File.join(
@values[:directory_path],
d
)
FileUtils.mkdir_p(sub_path)
end
end
def parse_script
Kramdown::Document.new(@values[:script]).to_html
2023-03-04 11:14:54 -05:00
end
def import_script
scripts = Dir.glob("#{@values[:directory_path]}/*Script.docx")
script_content = PandocRuby.convert([scripts[0].dump()], from: :docx, to: :markdown)
@values[:script] = script_content
# save changes to the model
save_changes()
end
end