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