- separate each media into each own file and cleanup
This commit is contained in:
parent
6337713fb8
commit
0d2fbaebbf
@ -1,9 +1,10 @@
|
||||
path = File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
|
||||
$LOAD_PATH << path
|
||||
require 'recordandplayback/archiver'
|
||||
require 'recordandplayback/audio_archiver'
|
||||
require 'recordandplayback/collectors/events'
|
||||
require 'recordandplayback/collectors/audio'
|
||||
require 'recordandplayback/events_archiver'
|
||||
require 'recordandplayback/video_archiver'
|
||||
require 'recordandplayback/presentation_archiver'
|
||||
require 'recordandplayback/deskshare_archiver'
|
||||
require 'recordandplayback/generators/events'
|
||||
require 'recordandplayback/generators/audio'
|
||||
require 'recordandplayback/generators/matterhorn_processor'
|
||||
|
@ -1,55 +0,0 @@
|
||||
module BigBlueButton
|
||||
class AudioArchiver
|
||||
def self.archive(meeting_id, from, archive_dir)
|
||||
to_dir = "#{archive_dir}/#{meeting_id}/audio"
|
||||
if not FileTest.directory?(to_dir)
|
||||
FileUtils.mkdir_p to_dir
|
||||
end
|
||||
|
||||
Collector::Audio.collect_audio(meeting_id, from, to_dir)
|
||||
end
|
||||
end
|
||||
|
||||
class EventsArchiver
|
||||
def self.archive(archive_dir, meeting_id, redis_host, redis_port)
|
||||
redis = BigBlueButton::RedisWrapper.new(redis_host, redis_port)
|
||||
events_archiver = BigBlueButton::RedisEventsArchiver.new redis
|
||||
|
||||
events_archiver.save_events_to_file("#{archive_dir}/#{meeting_id}", events_archiver.store_events(meeting_id))
|
||||
end
|
||||
end
|
||||
|
||||
class PresentationArchiver
|
||||
def self.archive(meeting_id, from, archive_dir)
|
||||
to_dir = "#{archive_dir}/#{meeting_id}/presentations"
|
||||
if not FileTest.directory?(to_dir)
|
||||
FileUtils.mkdir_p to_dir
|
||||
end
|
||||
|
||||
Collector::Presentation.collect_presentation(meeting_id, from, to_dir)
|
||||
end
|
||||
end
|
||||
|
||||
class VideoArchiver
|
||||
def self.archive(meeting_id, from, archive_dir)
|
||||
to_dir = "#{archive_dir}/#{meeting_id}/video"
|
||||
if not FileTest.directory?(to_dir)
|
||||
FileUtils.mkdir_p to_dir
|
||||
end
|
||||
|
||||
Collector::Video.collect_video(meeting_id, from, to_dir)
|
||||
end
|
||||
end
|
||||
|
||||
class DeskshareArchiver
|
||||
def self.archive(meeting_id, from, archive_dir)
|
||||
to_dir = "#{archive_dir}/#{meeting_id}/deskshare"
|
||||
if not FileTest.directory?(to_dir)
|
||||
FileUtils.mkdir_p to_dir
|
||||
end
|
||||
|
||||
Collector::Deskshare.collect_deskshare(meeting_id, from, to_dir)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -1,133 +0,0 @@
|
||||
require 'fileutils'
|
||||
|
||||
module Collector
|
||||
class NoSuchDirectoryException < RuntimeError
|
||||
end
|
||||
|
||||
class NoAudioFileException < RuntimeError
|
||||
end
|
||||
|
||||
class NoVideoFileException < RuntimeError
|
||||
end
|
||||
|
||||
class NoPresentationException < RuntimeError
|
||||
end
|
||||
|
||||
class NoDeskshareException < RuntimeError
|
||||
end
|
||||
|
||||
class Audio
|
||||
def self.location_exist?(location)
|
||||
FileTest.directory?(location)
|
||||
end
|
||||
|
||||
def self.audio_present?(meeting_id, location)
|
||||
Dir.glob("#{location}/#{meeting_id}*.wav").empty?
|
||||
end
|
||||
|
||||
# Copies the audio recordings specified by meeting_id
|
||||
# from a directory to a target directory.
|
||||
def self.collect_audio(meeting_id, from_dir, to_dir)
|
||||
if not location_exist?(from_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{from_dir}"
|
||||
end
|
||||
|
||||
if not location_exist?(to_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{to_dir}"
|
||||
end
|
||||
|
||||
if (audio_present?(meeting_id, from_dir))
|
||||
raise NoAudioFileException, "No audio recording for #{meeting_id} in #{from_dir}"
|
||||
end
|
||||
|
||||
Dir.glob("#{from_dir}/#{meeting_id}*.wav").each { |file|
|
||||
FileUtils.cp(file, to_dir)
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Video
|
||||
def self.location_exist?(location)
|
||||
FileTest.directory?(location)
|
||||
end
|
||||
|
||||
def self.video_present?(meeting_id, location)
|
||||
Dir.glob("#{location}").empty?
|
||||
end
|
||||
|
||||
def self.collect_video(meeting_id, from_dir, to_dir)
|
||||
if not location_exist?(from_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{from_dir}"
|
||||
end
|
||||
|
||||
if not location_exist?(to_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{to_dir}"
|
||||
end
|
||||
|
||||
if (video_present?(meeting_id, from_dir))
|
||||
raise NoVideoFileException, "No video recording for #{meeting_id} in #{from_dir}"
|
||||
end
|
||||
|
||||
Dir.glob("#{from_dir}/*").each { |file|
|
||||
FileUtils.cp_r(file, to_dir)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
class Presentation
|
||||
def self.location_exist?(location)
|
||||
FileTest.directory?(location)
|
||||
end
|
||||
|
||||
def self.presentation_present?(meeting_id, location)
|
||||
Dir.glob("#{location}").empty?
|
||||
end
|
||||
|
||||
def self.collect_presentation(meeting_id, from_dir, to_dir)
|
||||
if not location_exist?(from_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{from_dir}"
|
||||
end
|
||||
|
||||
if not location_exist?(to_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{to_dir}"
|
||||
end
|
||||
|
||||
if (presentation_present?(meeting_id, from_dir))
|
||||
raise NoPresentationException, "No presentation for #{meeting_id} in #{from_dir}"
|
||||
end
|
||||
|
||||
Dir.glob("#{from_dir}/*").each { |file|
|
||||
FileUtils.cp_r(file, to_dir)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
class Deskshare
|
||||
def self.location_exist?(location)
|
||||
FileTest.directory?(location)
|
||||
end
|
||||
|
||||
def self.deskshare_present?(meeting_id, location)
|
||||
Dir.glob("#{location}").empty?
|
||||
end
|
||||
|
||||
def self.collect_deskshare(meeting_id, from_dir, to_dir)
|
||||
if not location_exist?(from_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{from_dir}"
|
||||
end
|
||||
|
||||
if not location_exist?(to_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{to_dir}"
|
||||
end
|
||||
|
||||
if (deskshare_present?(meeting_id, from_dir))
|
||||
raise NoDeskshareException, "No video recording for #{meeting_id} in #{from_dir}"
|
||||
end
|
||||
|
||||
Dir.glob("#{from_dir}/#{meeting_id}-*.flv").each { |file|
|
||||
FileUtils.cp(file, to_dir)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
@ -1,38 +0,0 @@
|
||||
require 'fileutils'
|
||||
|
||||
module Collector
|
||||
class NoSuchDirectoryException < RuntimeError
|
||||
end
|
||||
class NoAudioFileException < RuntimeError
|
||||
end
|
||||
|
||||
class Video
|
||||
def location_exist?(location)
|
||||
FileTest.directory?(location)
|
||||
end
|
||||
|
||||
def video_present?(meeting_id, location)
|
||||
Dir.glob("#{location}/*.flv").empty?
|
||||
end
|
||||
|
||||
|
||||
def collect_video(meeting_id, from_dir, to_dir)
|
||||
if not location_exist?(from_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{from_dir}"
|
||||
end
|
||||
|
||||
if not location_exist?(to_dir)
|
||||
raise NoSuchDirectoryException, "Directory not found #{to_dir}"
|
||||
end
|
||||
|
||||
if (audio_present?(meeting_id, from_dir))
|
||||
raise NoAudioFileException, "No audio recording for #{meeting_id} in #{from_dir}"
|
||||
end
|
||||
|
||||
Dir.glob("#{from_dir}/*.flv").each { |file|
|
||||
FileUtils.cp(file, to_dir)
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
31
record-and-playback/rap/lib/recordandplayback/deskshare_archiver.rb
Executable file
31
record-and-playback/rap/lib/recordandplayback/deskshare_archiver.rb
Executable file
@ -0,0 +1,31 @@
|
||||
require 'fileutils'
|
||||
|
||||
module BigBlueButton
|
||||
class DeskshareArchiver
|
||||
def self.location_exist?(location)
|
||||
FileTest.directory?(location)
|
||||
end
|
||||
|
||||
def self.deskshare_present?(meeting_id, location)
|
||||
Dir.glob("#{location}").empty?
|
||||
end
|
||||
|
||||
def self.archive(meeting_id, from_dir, to_dir)
|
||||
if not BigBlueButton.dir_exists?(from_dir)
|
||||
raise MissingDirectoryException, "Directory not found #{from_dir}"
|
||||
end
|
||||
|
||||
if not BigBlueButton.dir_exists?(to_dir)
|
||||
raise MissingDirectoryException, "Directory not found #{to_dir}"
|
||||
end
|
||||
|
||||
if Dir.glob("#{from_dir}").empty?
|
||||
raise FileNotFoundException, "No recording for #{meeting_id} in #{from_dir}"
|
||||
end
|
||||
|
||||
Dir.glob("#{from_dir}/#{meeting_id}-*.flv").each { |file|
|
||||
FileUtils.cp(file, to_dir)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
@ -2,7 +2,7 @@ require 'rubygems'
|
||||
require 'redis'
|
||||
require 'builder'
|
||||
|
||||
module BigBlueButton
|
||||
module BigBlueButton
|
||||
# Class to wrap Redis so we can mock
|
||||
# for testing
|
||||
class RedisWrapper
|
||||
@ -86,5 +86,4 @@ module BigBlueButton
|
||||
a_file.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
module BigBlueButton
|
||||
def self.directory_exist?(location)
|
||||
FileTest.directory?(location)
|
||||
end
|
||||
end
|
||||
|
||||
|
24
record-and-playback/rap/lib/recordandplayback/presentation_archiver.rb
Executable file
24
record-and-playback/rap/lib/recordandplayback/presentation_archiver.rb
Executable file
@ -0,0 +1,24 @@
|
||||
require 'fileutils'
|
||||
|
||||
module BigBlueButton
|
||||
class PresentationArchiver
|
||||
def self.archive(meeting_id, from_dir, to_dir)
|
||||
if not BigBlueButton.dir_exists?(from_dir)
|
||||
raise MissingDirectoryException, "Directory not found #{from_dir}"
|
||||
end
|
||||
|
||||
if not BigBlueButton.dir_exists?(to_dir)
|
||||
raise MissingDirectoryException, "Directory not found #{to_dir}"
|
||||
end
|
||||
|
||||
if Dir.glob("#{from_dir}").empty?
|
||||
raise FileNotFoundException, "No presentation for #{meeting_id} in #{from_dir}"
|
||||
end
|
||||
|
||||
Dir.glob("#{from_dir}/*").each { |file|
|
||||
FileUtils.cp_r(file, to_dir)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
24
record-and-playback/rap/lib/recordandplayback/video_archiver.rb
Executable file
24
record-and-playback/rap/lib/recordandplayback/video_archiver.rb
Executable file
@ -0,0 +1,24 @@
|
||||
require 'fileutils'
|
||||
|
||||
module BigBlueButton
|
||||
class VideoArchiver
|
||||
def self.archive(meeting_id, from_dir, to_dir)
|
||||
if not BigBlueButton.dir_exists?(from_dir)
|
||||
raise MissingDirectoryException, "Directory not found: [#{from_dir}]"
|
||||
end
|
||||
|
||||
if not BigBlueButton.dir_exists?(to_dir)
|
||||
raise MissingDirectoryException, "Directory not found: [#{to_dir}]"
|
||||
end
|
||||
|
||||
if Dir.glob("#{from_dir}").empty?
|
||||
raise FileNotFoundException, "Video for #{meeting_id} not found."
|
||||
end
|
||||
|
||||
Dir.glob("#{from_dir}").each do |file|
|
||||
FileUtils.cp_r(file, to_dir)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,52 +0,0 @@
|
||||
require 'spec_helper'
|
||||
require 'fileutils'
|
||||
|
||||
module Collector
|
||||
describe Audio do
|
||||
context "#success" do
|
||||
it "should copy audio recording to archive" do
|
||||
FileTest.stub(:directory?).and_return(true)
|
||||
FileUtils.stub(:cp)
|
||||
Dir.stub(:glob).and_return(['file1.wav', 'file2.wav'])
|
||||
from_dir = 'from'
|
||||
to_dir = 'to'
|
||||
meeting_id = 'meeting-id'
|
||||
|
||||
expect { Collector::Audio.collect_audio( meeting_id, from_dir, to_dir ) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context "#fail" do
|
||||
it "should raise from directory not found exception" do
|
||||
FileTest.stub(:directory?).and_return(false)
|
||||
FileUtils.stub(:cp)
|
||||
Dir.stub(:glob).and_return(['file1.wav', 'file2.wav'])
|
||||
from_dir = '/from-dir-not-found'
|
||||
to_dir = 'resources/archive'
|
||||
meeting_id = 'meeting-id'
|
||||
|
||||
expect {Collector::Audio.collect_audio( meeting_id, from_dir, to_dir )}.to raise_error(NoSuchDirectoryException)
|
||||
end
|
||||
it "should raise to directory not found exception" do
|
||||
from_dir = 'resources/raw/audio'
|
||||
to_dir = '/to-dir-not-found'
|
||||
meeting_id = 'meeting-id'
|
||||
FileTest.stub(:directory?).and_return(false)
|
||||
FileUtils.stub(:cp)
|
||||
Dir.stub(:glob).and_return(['file1.wav', 'file2.wav'])
|
||||
|
||||
expect { Collector::Audio.collect_audio( meeting_id, from_dir, to_dir ) }.to raise_error(NoSuchDirectoryException)
|
||||
end
|
||||
it "should raise audio files not found exception" do
|
||||
from_dir = 'resources/raw/audio'
|
||||
to_dir = '/to-dir-not-found'
|
||||
meeting_id = 'meeting-id'
|
||||
FileTest.stub(:directory?).and_return(true)
|
||||
FileUtils.stub(:cp)
|
||||
Dir.stub(:glob).and_return([])
|
||||
|
||||
expect { Collector::Audio.collect_audio( meeting_id, from_dir, to_dir ) }.to raise_error(NoAudioFileException)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,8 +1,8 @@
|
||||
require 'spec_helper'
|
||||
require 'fileutils'
|
||||
|
||||
module Collector
|
||||
describe Deskshare do
|
||||
module BigBlueButton
|
||||
describe DeskshareArchiver do
|
||||
context "#success" do
|
||||
it "should copy deskshare recordings to archive" do
|
||||
FileTest.stub(:directory?).and_return(true)
|
||||
@ -12,7 +12,7 @@ module Collector
|
||||
to_dir = 'to'
|
||||
meeting_id = 'meeting-id'
|
||||
|
||||
expect { Collector::Deskshare.collect_deskshare( meeting_id, from_dir, to_dir ) }.to_not raise_error
|
||||
expect { BigBlueButton::DeskshareArchiver.archive( meeting_id, from_dir, to_dir ) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
@ -25,7 +25,7 @@ module Collector
|
||||
to_dir = 'resources/archive'
|
||||
meeting_id = 'meeting-id'
|
||||
|
||||
expect {Collector::Deskshare.collect_deskshare( meeting_id, from_dir, to_dir )}.to raise_error(NoSuchDirectoryException)
|
||||
expect { BigBlueButton::DeskshareArchiver.archive( meeting_id, from_dir, to_dir )}.to raise_error(MissingDirectoryException)
|
||||
end
|
||||
it "should raise to directory not found exception" do
|
||||
from_dir = 'resources/raw/audio'
|
||||
@ -35,7 +35,7 @@ module Collector
|
||||
FileUtils.stub(:cp)
|
||||
Dir.stub(:glob).and_return(['file1.wav', 'file2.wav'])
|
||||
|
||||
expect { Collector::Deskshare.collect_deskshare( meeting_id, from_dir, to_dir ) }.to raise_error(NoSuchDirectoryException)
|
||||
expect { BigBlueButton::DeskshareArchiver.archive( meeting_id, from_dir, to_dir ) }.to raise_error(MissingDirectoryException)
|
||||
end
|
||||
it "should raise deskshare files not found exception" do
|
||||
from_dir = 'resources/raw/audio'
|
||||
@ -45,7 +45,7 @@ module Collector
|
||||
FileUtils.stub(:cp)
|
||||
Dir.stub(:glob).and_return([])
|
||||
|
||||
expect { Collector::Deskshare.collect_deskshare( meeting_id, from_dir, to_dir ) }.to raise_error(NoDeskshareException)
|
||||
expect { BigBlueButton::DeskshareArchiver.archive( meeting_id, from_dir, to_dir ) }.to raise_error(FileNotFoundException)
|
||||
end
|
||||
end
|
||||
end
|
@ -1,8 +1,8 @@
|
||||
require 'spec_helper'
|
||||
require 'fileutils'
|
||||
|
||||
module Collector
|
||||
describe Presentation do
|
||||
module BigBlueButton
|
||||
describe PresentationArchiver do
|
||||
context "#success" do
|
||||
it "should copy presentations to archive" do
|
||||
FileTest.stub(:directory?).and_return(true)
|
||||
@ -12,7 +12,7 @@ module Collector
|
||||
to_dir = 'to'
|
||||
meeting_id = 'meeting-id'
|
||||
|
||||
expect { Collector::Presentation.collect_presentation( meeting_id, from_dir, to_dir ) }.to_not raise_error
|
||||
expect { BigBlueButton::PresentationArchiver.archive( meeting_id, from_dir, to_dir ) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
@ -25,7 +25,7 @@ module Collector
|
||||
to_dir = 'resources/archive'
|
||||
meeting_id = 'meeting-id'
|
||||
|
||||
expect {Collector::Presentation.collect_presentation( meeting_id, from_dir, to_dir )}.to raise_error(NoSuchDirectoryException)
|
||||
expect { BigBlueButton::PresentationArchiver.archive( meeting_id, from_dir, to_dir )}.to raise_error(MissingDirectoryException)
|
||||
end
|
||||
it "should raise to directory not found exception" do
|
||||
from_dir = 'resources/raw/audio'
|
||||
@ -35,7 +35,7 @@ module Collector
|
||||
FileUtils.stub(:cp_r)
|
||||
Dir.stub(:glob).and_return(['flight-school', 'ecosystem'])
|
||||
|
||||
expect { Collector::Presentation.collect_presentation( meeting_id, from_dir, to_dir ) }.to raise_error(NoSuchDirectoryException)
|
||||
expect { BigBlueButton::PresentationArchiver.archive( meeting_id, from_dir, to_dir ) }.to raise_error(MissingDirectoryException)
|
||||
end
|
||||
it "should raise presentation files not found exception" do
|
||||
from_dir = 'resources/raw/audio'
|
||||
@ -45,7 +45,7 @@ module Collector
|
||||
FileUtils.stub(:cp)
|
||||
Dir.stub(:glob).and_return([])
|
||||
|
||||
expect { Collector::Presentation.collect_presentation( meeting_id, from_dir, to_dir ) }.to raise_error(NoPresentationException)
|
||||
expect { BigBlueButton::PresentationArchiver.archive( meeting_id, from_dir, to_dir ) }.to raise_error(FileNotFoundException)
|
||||
end
|
||||
end
|
||||
end
|
@ -1,8 +1,8 @@
|
||||
require 'spec_helper'
|
||||
require 'fileutils'
|
||||
|
||||
module Collector
|
||||
describe Video do
|
||||
module BigBlueButton
|
||||
describe VideoArchiver do
|
||||
context "#success" do
|
||||
it "should copy audio recording to archive" do
|
||||
FileTest.stub(:directory?).and_return(true)
|
||||
@ -12,7 +12,7 @@ module Collector
|
||||
to_dir = 'to'
|
||||
meeting_id = 'meeting-id'
|
||||
|
||||
expect { Collector::Video.collect_video( meeting_id, from_dir, to_dir ) }.to_not raise_error
|
||||
expect { BigBlueButton::VideoArchiver.archive( meeting_id, from_dir, to_dir ) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
@ -25,7 +25,7 @@ module Collector
|
||||
to_dir = 'resources/archive'
|
||||
meeting_id = 'meeting-id'
|
||||
|
||||
expect {Collector::Video.collect_video( meeting_id, from_dir, to_dir )}.to raise_error(NoSuchDirectoryException)
|
||||
expect {BigBlueButton::VideoArchiver.archive( meeting_id, from_dir, to_dir )}.to raise_error(MissingDirectoryException)
|
||||
end
|
||||
it "should raise to directory not found exception" do
|
||||
from_dir = 'resources/raw/audio'
|
||||
@ -35,7 +35,7 @@ module Collector
|
||||
FileUtils.stub(:cp_r)
|
||||
Dir.stub(:glob).and_return(['file1.wav', 'file2.wav'])
|
||||
|
||||
expect { Collector::Video.collect_video( meeting_id, from_dir, to_dir ) }.to raise_error(NoSuchDirectoryException)
|
||||
expect { BigBlueButton::VideoArchiver.archive( meeting_id, from_dir, to_dir ) }.to raise_error(MissingDirectoryException)
|
||||
end
|
||||
it "should raise audio files not found exception" do
|
||||
from_dir = 'resources/raw/audio'
|
||||
@ -45,7 +45,7 @@ module Collector
|
||||
FileUtils.stub(:cp_r)
|
||||
Dir.stub(:glob).and_return([])
|
||||
|
||||
expect { Collector::Video.collect_video( meeting_id, from_dir, to_dir ) }.to raise_error(NoVideoFileException)
|
||||
expect {BigBlueButton::VideoArchiver.archive( meeting_id, from_dir, to_dir ) }.to raise_error(FileNotFoundException)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user