lib/xmorph/base.rb in xmorph-0.1.2 vs lib/xmorph/base.rb in xmorph-0.1.3
- old
+ new
@@ -34,27 +34,29 @@
def initialize(asset_path)
self.asset_path = asset_path
self.set_profiles
end
- def self.get_transcode_template(host, domain, name, asset_path)
+ def self.get_transcode_template(host, domain, name, asset_path, return_loaded_filepath=false)
return nil unless domain
-
file_path = File.join(self.root, "xmorph", host, domain, "transcode.rb")
raise TranscoderError.new("Transcoding profile doesn't exist for account, #{name}.") unless File.exist? file_path
XMorph::Base.logger.debug("XMorph#get_transcode_template: loading file #{file_path} to transcode #{asset_path}")
load file_path
+ return Transcode.new(asset_path), file_path if return_loaded_filepath
return Transcode.new(asset_path)
end
def get_asset_details
mediainfo_command = "#{File.dirname(self.class.root)}/bin/mediainfo --output=XML #{self.asset_path}"
+ XMorph::Base.logger.debug("XMorph#get_asset_details: mediainfo_command: #{mediainfo_command}")
success, response = Util.run_cmd_with_response(mediainfo_command)
+ raise TranscoderError.new("Failed to get mediainfo for the asset.") unless success
begin
self.mediainfo_output = Util.mediainfo_xml_to_hash(response)[1]
rescue => e
- raise TranscoderError.new("Failed to get mediainfo for the asset.") unless success
+ raise TranscoderError.new("Failed to get mediainfo for the asset.")
end
set_validations
end
def set_validations
@@ -75,15 +77,16 @@
raise TranscoderError.new(self.error || "Failed to perform default video validations.") unless perform_default_video_validations
raise TranscoderError.new(self.error || "Failed to perform default audio validations.") unless perform_default_audio_validations
return true
end
- def get_profile
+ def get_profile(return_profile_name=false)
self.set_profile_name
if (self.profile_name.blank? or self.profiles[self.profile_name].blank?)
raise TranscoderError.new(self.error || "Media doesnt match any transcoding profiles.")
end
XMorph::Base.logger.debug("XMorph#get_profile: Command for #{self.asset_path}: #{self.profiles[self.profile_name]}")
+ return self.profile_name, self.profiles[self.profile_name] if return_profile_name
return self.profiles[self.profile_name]
end
def transcode(cmd)
raise TranscoderError.new("Command passed to transcode is empty.") unless cmd
\ No newline at end of file