Sha256: 55d6ab33e2bf0bebb14eb41e16e8a69967486dc9564bbc64c6fbf03760d942d6
Contents?: true
Size: 1.48 KB
Versions: 11
Compression:
Stored size: 1.48 KB
Contents
module XMorph require 'active_support' class Util def self.mediainfo_xml_to_hash(response) meta = { "Audio" => [] } begin response_json = Hash.from_xml(response) response_json["Mediainfo"]["File"]["track"].each do |track| type = track['type'] track = track.except("type") track['Encoding_settings'] = Rack::Utils.parse_nested_query(track['Encoding_settings'].split("/").map {|pair| pair.strip }.join("&")) unless track['Encoding_settings'].nil? (type == "Audio") ? meta["Audio"] << track : meta[type] = track if type == "Video" if track["Display_aspect_ratio"].present? track["Display_aspect_ratio"] = track["Display_aspect_ratio"] if track["Display_aspect_ratio"].include? (":") end if track["Original_display_aspect_ratio"].present? track["Display_aspect_ratio"] = track["Original_display_aspect_ratio"] if track["Original_display_aspect_ratio"].include? (":") end end end meta['audio_tracks'] = meta['Audio'].count.to_s rescue => ex puts ex return false, {"error" => "Failed to load mediainfo"} end return true, meta end def self.run_cmd_with_response(cmd) raw_response = `#{cmd}` successful = true exit_status = $?.exitstatus if exit_status != 0 successful = false end return successful, raw_response end end end
Version data entries
11 entries across 11 versions & 2 rubygems