Added some video repository housekeeping functionality
This commit is contained in:
parent
4273bfbbae
commit
4c3ea4ea87
@ -1,5 +1,7 @@
|
|||||||
require_relative 'util.rb'
|
require_relative 'util.rb'
|
||||||
|
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
class Repository
|
class Repository
|
||||||
|
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
@ -15,4 +17,29 @@ class Repository
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def searchIngest
|
||||||
|
# create our ingest directory path
|
||||||
|
ingestPath = File.join(@basePath, 'ingest')
|
||||||
|
# search for files in ingest; ignore non-files (e.g. directories)
|
||||||
|
ingestFiles = Dir.entries(ingestPath).select { |f| File.file? File.join(ingestPath, f) }
|
||||||
|
|
||||||
|
return ingestFiles
|
||||||
|
end
|
||||||
|
|
||||||
|
def archiveFile(filename)
|
||||||
|
# create source and destination paths for the copy
|
||||||
|
ingestPath = File.join(@basePath, 'ingest', filename)
|
||||||
|
archivePath = File.join(@basePath, 'archive', filename)
|
||||||
|
|
||||||
|
# perform the copy, preserving file attributes
|
||||||
|
FileUtils.cp(ingestPath, archivePath, preserve: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cleanupFile(filename)
|
||||||
|
# create ingest path
|
||||||
|
ingestPath = File.join(@basePath, 'ingest', filename)
|
||||||
|
# remove the file
|
||||||
|
FileUtils.remove_file(ingestPath)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
23
src/transcoder.rb
Normal file
23
src/transcoder.rb
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
class Transcoder
|
||||||
|
|
||||||
|
def initialize(config, repository)
|
||||||
|
@config = config
|
||||||
|
@repository = repository
|
||||||
|
end
|
||||||
|
|
||||||
|
def start
|
||||||
|
puts "Starting transcoder..."
|
||||||
|
|
||||||
|
# search for files in ingest
|
||||||
|
ingestFiles = @repository.searchIngest()
|
||||||
|
ingestFiles.each { |ifile|
|
||||||
|
# archive the file
|
||||||
|
@repository.archiveFile(ifile)
|
||||||
|
# perform the transcode
|
||||||
|
# // TODO self.transcode(ifile)
|
||||||
|
# clean up the file from ingest
|
||||||
|
@repository.cleanupFile(ifile)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
require_relative 'config.rb'
|
require_relative 'config.rb'
|
||||||
require_relative 'repository.rb'
|
require_relative 'repository.rb'
|
||||||
|
require_relative 'transcoder.rb'
|
||||||
|
|
||||||
# create new configuration instance
|
# create new configuration instance
|
||||||
c = Config.new('~/.config/zealot.toml')
|
c = Config.new('~/.config/zealot.toml')
|
||||||
@ -9,5 +10,8 @@ c = Config.new('~/.config/zealot.toml')
|
|||||||
# create new repository instance
|
# create new repository instance
|
||||||
r = Repository.new(c.get('transcoder.repository'))
|
r = Repository.new(c.get('transcoder.repository'))
|
||||||
|
|
||||||
# print repository directory as a test
|
# create new transcoder instance
|
||||||
puts c.get('transcoder.repository')
|
t = Transcoder.new(c, r)
|
||||||
|
|
||||||
|
# start the transcoder
|
||||||
|
t.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user