Added pandoc-ruby gem to import .docx scripts

This commit is contained in:
Gregory Ballantine 2023-03-07 10:01:34 -05:00
parent 9278216b4a
commit 26a4f25631
4 changed files with 15 additions and 1 deletions

View File

@ -9,6 +9,8 @@ gem 'sqlite3', '~> 1.6'
gem 'kramdown', '~> 2.4'
gem 'pandoc-ruby', '~> 2.1'
# Use rerun gem to auto-reload app
gem 'rerun'

View File

@ -11,6 +11,7 @@ GEM
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.8)
pandoc-ruby (2.1.7)
puma (6.1.1)
nio4r (~> 2.0)
rack (2.2.6.2)
@ -43,6 +44,7 @@ PLATFORMS
DEPENDENCIES
kramdown (~> 2.4)
pandoc-ruby (~> 2.1)
puma (~> 6.1)
rerun
sequel (~> 5.66)

View File

@ -1,4 +1,5 @@
require 'kramdown'
require 'pandoc-ruby'
class Video < Sequel::Model
@ -21,4 +22,11 @@ class Video < Sequel::Model
return Kramdown::Document.new(@values[:script]).to_html
end
def importScript()
scripts = Dir.glob("#{@values[:directory_path]}/*Script.docx")
script_content = PandocRuby.convert([scripts[0].dump()], from: :docx, to: :markdown)
@values[:script] = script_content
self.save()
end
end

View File

@ -21,7 +21,7 @@ unless ARGV.length == 1
end
channel = Channel.where(name: ARGV[0]).first()
channel_dir = channel.directory_path
channel_dir = File.join(channel.directory_path, 'Main')
subs = Dir["#{channel_dir}/*"]
subs.each do |d|
@ -49,6 +49,8 @@ subs.each do |d|
script: "# Introduction\n\n# Body\n\n# Conclusions"
)
video.importScript()
puts "Successfully added video ##{video.serial} - #{video.name} for channel '#{channel.name}' to the database."
end
end