implement the first version of the note playback
This commit is contained in:
parent
3467d912c7
commit
f1f56bd868
22
record-and-playback/note/scripts/note.nginx
Normal file
22
record-and-playback/note/scripts/note.nginx
Normal file
@ -0,0 +1,22 @@
|
||||
#
|
||||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
||||
#
|
||||
# Copyright (c) 2019 BigBlueButton Inc. and by respective authors (see below).
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free Software
|
||||
# Foundation; either version 3.0 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# BigBlueButton 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
location /note {
|
||||
root /var/bigbluebutton/published;
|
||||
index index.html index.htm;
|
||||
}
|
2
record-and-playback/note/scripts/note.yml
Normal file
2
record-and-playback/note/scripts/note.yml
Normal file
@ -0,0 +1,2 @@
|
||||
publish_dir: /var/bigbluebutton/published/note
|
||||
format: pdf
|
161
record-and-playback/note/scripts/process/note.rb
Normal file
161
record-and-playback/note/scripts/process/note.rb
Normal file
@ -0,0 +1,161 @@
|
||||
# Set encoding to utf-8
|
||||
# encoding: UTF-8
|
||||
|
||||
#
|
||||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
||||
#
|
||||
# Copyright (c) 2019 BigBlueButton Inc. and by respective authors (see below).
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free Software
|
||||
# Foundation; either version 3.0 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# BigBlueButton 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# For DEVELOPMENT
|
||||
# Allows us to run the script manually
|
||||
# require File.expand_path('../../../../core/lib/recordandplayback', __FILE__)
|
||||
|
||||
# For PRODUCTION
|
||||
require File.expand_path('../../../lib/recordandplayback', __FILE__)
|
||||
|
||||
require 'rubygems'
|
||||
require 'trollop'
|
||||
require 'yaml'
|
||||
require 'json'
|
||||
|
||||
opts = Trollop::options do
|
||||
opt :meeting_id, "Meeting id to archive", :default => '58f4a6b3-cd07-444d-8564-59116cb53974', :type => String
|
||||
end
|
||||
|
||||
meeting_id = opts[:meeting_id]
|
||||
|
||||
# This script lives in scripts/archive/steps while properties.yaml lives in scripts/
|
||||
props = YAML::load(File.open('../../core/scripts/bigbluebutton.yml'))
|
||||
note_props = YAML::load(File.open('note.yml'))
|
||||
format = note_props['format']
|
||||
|
||||
recording_dir = props['recording_dir']
|
||||
raw_archive_dir = "#{recording_dir}/raw/#{meeting_id}"
|
||||
log_dir = props['log_dir']
|
||||
|
||||
target_dir = "#{recording_dir}/process/note/#{meeting_id}"
|
||||
if not FileTest.directory?(target_dir)
|
||||
FileUtils.mkdir_p "#{log_dir}/note"
|
||||
logger = Logger.new("#{log_dir}/note/process-#{meeting_id}.log", 'daily' )
|
||||
BigBlueButton.logger = logger
|
||||
BigBlueButton.logger.info("Processing script note.rb")
|
||||
FileUtils.mkdir_p target_dir
|
||||
|
||||
begin
|
||||
# Create initial metadata.xml
|
||||
b = Builder::XmlMarkup.new(:indent => 2)
|
||||
metaxml = b.recording {
|
||||
b.id(meeting_id)
|
||||
b.state("processing")
|
||||
b.published(false)
|
||||
b.start_time
|
||||
b.end_time
|
||||
b.participants
|
||||
b.playback
|
||||
b.meta
|
||||
}
|
||||
metadata_xml = File.new("#{target_dir}/metadata.xml","w")
|
||||
metadata_xml.write(metaxml)
|
||||
metadata_xml.close
|
||||
BigBlueButton.logger.info("Created inital metadata.xml")
|
||||
|
||||
FileUtils.cp("#{raw_archive_dir}/note/note.#{format}", "#{target_dir}/note.#{format}")
|
||||
|
||||
# Get the real-time start and end timestamp
|
||||
@doc = Nokogiri::XML(File.open("#{raw_archive_dir}/events.xml"))
|
||||
|
||||
meeting_start = @doc.xpath("//event")[0][:timestamp]
|
||||
meeting_end = @doc.xpath("//event").last()[:timestamp]
|
||||
|
||||
match = /.*-(\d+)$/.match(meeting_id)
|
||||
real_start_time = match[1]
|
||||
real_end_time = (real_start_time.to_i + (meeting_end.to_i - meeting_start.to_i)).to_s
|
||||
|
||||
|
||||
# Add start_time, end_time and meta to metadata.xml
|
||||
## Load metadata.xml
|
||||
metadata = Nokogiri::XML(File.open("#{target_dir}/metadata.xml"))
|
||||
## Add start_time and end_time
|
||||
recording = metadata.root
|
||||
### Date Format for recordings: Thu Mar 04 14:05:56 UTC 2010
|
||||
start_time = recording.at_xpath("start_time")
|
||||
start_time.content = real_start_time
|
||||
end_time = recording.at_xpath("end_time")
|
||||
end_time.content = real_end_time
|
||||
|
||||
## Copy the breakout and breakout rooms node from
|
||||
## events.xml if present.
|
||||
breakout_xpath = @doc.xpath("//breakout")
|
||||
breakout_rooms_xpath = @doc.xpath("//breakoutRooms")
|
||||
meeting_xpath = @doc.xpath("//meeting")
|
||||
|
||||
if (meeting_xpath != nil)
|
||||
recording << meeting_xpath
|
||||
end
|
||||
|
||||
if (breakout_xpath != nil)
|
||||
recording << breakout_xpath
|
||||
end
|
||||
|
||||
if (breakout_rooms_xpath != nil)
|
||||
recording << breakout_rooms_xpath
|
||||
end
|
||||
|
||||
participants = recording.at_xpath("participants")
|
||||
participants.content = BigBlueButton::Events.get_num_participants(@doc)
|
||||
|
||||
## Remove empty meta
|
||||
metadata.search('//recording/meta').each do |meta|
|
||||
meta.remove
|
||||
end
|
||||
## Add the actual meta
|
||||
metadata_with_playback = Nokogiri::XML::Builder.with(metadata.at('recording')) do |xml|
|
||||
xml.meta {
|
||||
BigBlueButton::Events.get_meeting_metadata("#{raw_archive_dir}/events.xml").each { |k,v| xml.method_missing(k,v) }
|
||||
}
|
||||
end
|
||||
## Write the new metadata.xml
|
||||
metadata_file = File.new("#{target_dir}/metadata.xml","w")
|
||||
metadata = Nokogiri::XML(metadata.to_xml) { |x| x.noblanks }
|
||||
metadata_file.write(metadata.root)
|
||||
metadata_file.close
|
||||
BigBlueButton.logger.info("Created an updated metadata.xml with start_time and end_time")
|
||||
|
||||
process_done = File.new("#{recording_dir}/status/processed/#{meeting_id}-note.done", "w")
|
||||
process_done.write("Processed #{meeting_id}")
|
||||
process_done.close
|
||||
|
||||
# Update state in metadata.xml
|
||||
## Load metadata.xml
|
||||
metadata = Nokogiri::XML(File.open("#{target_dir}/metadata.xml"))
|
||||
## Update status
|
||||
recording = metadata.root
|
||||
state = recording.at_xpath("state")
|
||||
state.content = "processed"
|
||||
## Write the new metadata.xml
|
||||
metadata_file = File.new("#{target_dir}/metadata.xml","w")
|
||||
metadata_file.write(metadata.root)
|
||||
metadata_file.close
|
||||
BigBlueButton.logger.info("Created an updated metadata.xml with state=processed")
|
||||
|
||||
rescue Exception => e
|
||||
BigBlueButton.logger.error(e.message)
|
||||
e.backtrace.each do |traceline|
|
||||
BigBlueButton.logger.error(traceline)
|
||||
end
|
||||
exit 1
|
||||
end
|
||||
end
|
153
record-and-playback/note/scripts/publish/note.rb
Normal file
153
record-and-playback/note/scripts/publish/note.rb
Normal file
@ -0,0 +1,153 @@
|
||||
# Set encoding to utf-8
|
||||
# encoding: UTF-8
|
||||
|
||||
#
|
||||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
||||
#
|
||||
# Copyright (c) 2019 BigBlueButton Inc. and by respective authors (see below).
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free Software
|
||||
# Foundation; either version 3.0 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# BigBlueButton 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
performance_start = Time.now
|
||||
|
||||
require '../../core/lib/recordandplayback'
|
||||
require 'rubygems'
|
||||
require 'trollop'
|
||||
require 'yaml'
|
||||
require 'builder'
|
||||
require 'fastimage' # require fastimage to get the image size of the slides (gem install fastimage)
|
||||
|
||||
|
||||
# This script lives in scripts/archive/steps while properties.yaml lives in scripts/
|
||||
bbb_props = YAML::load(File.open('../../core/scripts/bigbluebutton.yml'))
|
||||
note_props = YAML::load(File.open('note.yml'))
|
||||
|
||||
opts = Trollop::options do
|
||||
opt :meeting_id, "Meeting id to archive", :default => '58f4a6b3-cd07-444d-8564-59116cb53974', :type => String
|
||||
end
|
||||
|
||||
meeting_id = opts[:meeting_id]
|
||||
puts meeting_id
|
||||
match = /(.*)-(.*)/.match meeting_id
|
||||
meeting_id = match[1]
|
||||
playback = match[2]
|
||||
|
||||
puts meeting_id
|
||||
puts playback
|
||||
|
||||
begin
|
||||
|
||||
if (playback == "note")
|
||||
|
||||
log_dir = bbb_props['log_dir']
|
||||
|
||||
logger = Logger.new("#{log_dir}/note/publish-#{meeting_id}.log", 'daily' )
|
||||
BigBlueButton.logger = logger
|
||||
|
||||
recording_dir = bbb_props['recording_dir']
|
||||
raw_archive_dir = "#{recording_dir}/raw/#{meeting_id}"
|
||||
process_dir = "#{recording_dir}/process/note/#{meeting_id}"
|
||||
publish_dir = note_props['publish_dir']
|
||||
format = note_props['format']
|
||||
playback_protocol = bbb_props['playback_protocol']
|
||||
playback_host = bbb_props['playback_host']
|
||||
target_dir = "#{recording_dir}/publish/note/#{meeting_id}"
|
||||
|
||||
if not FileTest.directory?(target_dir)
|
||||
BigBlueButton.logger.info("Making dir target_dir")
|
||||
FileUtils.mkdir_p target_dir
|
||||
|
||||
BigBlueButton.logger.info("copying: #{process_dir}/note.#{format} to -> #{target_dir}")
|
||||
FileUtils.cp("#{process_dir}/note.#{format}", target_dir)
|
||||
|
||||
@doc = Nokogiri::XML(File.open("#{raw_archive_dir}/events.xml"))
|
||||
recording_time = BigBlueButton::Events.get_recording_length(@doc)
|
||||
|
||||
BigBlueButton.logger.info("Creating metadata.xml")
|
||||
|
||||
#### INSTEAD OF CREATING THE WHOLE metadata.xml FILE AGAIN, ONLY ADD <playback>
|
||||
# Copy metadata.xml from process_dir
|
||||
FileUtils.cp("#{process_dir}/metadata.xml", target_dir)
|
||||
BigBlueButton.logger.info("Copied metadata.xml file")
|
||||
|
||||
# Update state and add playback to metadata.xml
|
||||
## Load metadata.xml
|
||||
metadata = Nokogiri::XML(File.open("#{target_dir}/metadata.xml"))
|
||||
## Update state
|
||||
recording = metadata.root
|
||||
state = recording.at_xpath("state")
|
||||
state.content = "published"
|
||||
published = recording.at_xpath("published")
|
||||
published.content = "true"
|
||||
## Remove empty playback
|
||||
metadata.search('//recording/playback').each do |playback|
|
||||
playback.remove
|
||||
end
|
||||
## Add the actual playback
|
||||
metadata_with_playback = Nokogiri::XML::Builder.with(metadata.at('recording')) do |xml|
|
||||
xml.playback {
|
||||
xml.format("note")
|
||||
xml.link("#{playback_protocol}://#{playback_host}/note/#{meeting_id}/note.#{format}")
|
||||
xml.duration("#{recording_time}")
|
||||
}
|
||||
end
|
||||
## Write the new metadata.xml
|
||||
metadata_file = File.new("#{target_dir}/metadata.xml","w")
|
||||
metadata = Nokogiri::XML(metadata.to_xml) { |x| x.noblanks }
|
||||
metadata_file.write(metadata.root)
|
||||
metadata_file.close
|
||||
BigBlueButton.logger.info("Added playback to metadata.xml")
|
||||
|
||||
|
||||
# Now publish this recording files by copying them into the publish folder.
|
||||
if not FileTest.directory?(publish_dir)
|
||||
FileUtils.mkdir_p publish_dir
|
||||
end
|
||||
|
||||
# Get raw size of recording files
|
||||
raw_dir = "#{recording_dir}/raw/#{meeting_id}"
|
||||
# After all the processing we'll add the published format and raw sizes to the metadata file
|
||||
BigBlueButton.add_raw_size_to_metadata(target_dir, raw_dir)
|
||||
BigBlueButton.add_playback_size_to_metadata(target_dir)
|
||||
|
||||
FileUtils.cp_r(target_dir, publish_dir) # Copy all the files.
|
||||
BigBlueButton.logger.info("Finished publishing script note.rb successfully.")
|
||||
|
||||
BigBlueButton.logger.info("Removing processed files.")
|
||||
FileUtils.rm_r(process_dir)
|
||||
|
||||
BigBlueButton.logger.info("Removing published files.")
|
||||
FileUtils.rm_r(target_dir)
|
||||
|
||||
publish_done = File.new("#{recording_dir}/status/published/#{meeting_id}-note.done", "w")
|
||||
publish_done.write("Published #{meeting_id}")
|
||||
publish_done.close
|
||||
|
||||
else
|
||||
BigBlueButton.logger.info("#{target_dir} is already there")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
rescue Exception => e
|
||||
BigBlueButton.logger.error(e.message)
|
||||
e.backtrace.each do |traceline|
|
||||
BigBlueButton.logger.error(traceline)
|
||||
end
|
||||
publish_done = File.new("#{recording_dir}/status/published/#{meeting_id}-note.fail", "w")
|
||||
publish_done.write("Failed Publishing #{meeting_id}")
|
||||
publish_done.close
|
||||
|
||||
exit 1
|
||||
end
|
Loading…
Reference in New Issue
Block a user