class EnvoiImportUtility
Attributes
api_client[RW]
initial_args[RW]
Public Class Methods
new(args = { })
click to toggle source
# File lib/envoi/mam/agent/cli/commands/wiredrive.rb, line 74 def initialize(args = { }) @initial_args = args initialize_api_client(args) end
Public Instance Methods
after_initialize()
click to toggle source
# File lib/envoi/mam/agent/cli/commands/wiredrive.rb, line 79 def after_initialize @default_original_storage_id = args[:default_original_storage_id] @default_thumbnail_storage_id = args[:default_thumbnail_storage_id] end
import_wiredrive_presentation_asset(asset, options = { })
click to toggle source
# File lib/envoi/mam/agent/cli/commands/wiredrive.rb, line 88 def import_wiredrive_presentation_asset(asset, options = { }) title = asset['title'] || asset['label'] description = asset['description'] keywords = asset['keywords'] media_elements = asset['media'] media = media_elements.find { |me| me['type'] == 'original' } raise 'No original media found.' unless media url = media['url'] uri = URI(url) mime_type = media['mimeType'] size = media['fileSize'] url_path = uri.path.split('?').first filename = File.basename(url_path) original_storage_id = options[:original_storage_id] || options[:storage_id] || @default_original_storage_id create_args = { :name => title, :description => description, :file => { :mime => 'video/mp4', # mime_type, :path => url, :name => filename, :storage_key => url_path, :setting_id => original_storage_id, 'size' => size || 0 } } r = api_client.media_file_create(create_args) media_file_id = r['id'] raise 'No id found in response' unless media_file_id video_thumb = asset['thumbnails'].find { |e| e['category'] == 'max' } if video_thumb thumbnail_storage_id = options[:thumbnail_storage_id] || options[:storage_id] || @default_thumbnail_storage_id video_thumb_url = video_thumb['url'] video_thumb_uri = URI(video_thumb_url) video_thumb_path = video_thumb_uri.path.split('?').first media_file_file_add_args = { 'media_file_id' => media_file_id, 'shape_type' => 'thumb', 'shape_label' => 'Thumbnail', 'name' => File.basename(video_thumb_path), 'mime' => 'image/jpeg', 'path' => video_thumb_url, 'size' => 0, 'setting_id' => thumbnail_storage_id, 'storage_key' => video_thumb_path } r = api_client.media_file_file_add(media_file_file_add_args) end end
initialize_api_client(args = { })
click to toggle source
# File lib/envoi/mam/agent/cli/commands/wiredrive.rb, line 84 def initialize_api_client(args = { }) @api_client = Ubiquity::Envoi::API::Utilities.new(args) end