Module: KalturaFu::Flavor

Defined in:
lib/kaltura_fu/flavor.rb

Overview

The Flavor module provides interactions for adding and removing specific encodings from a Kaltura entry.

Instance Method Summary collapse

Instance Method Details

#add_flavor_to_video(video_id, flavor_param_id) ⇒ nil

TODO:

Make this method return something.

Adds a specific encoding profile to a Kaltura entry.

Parameters:

  • video_id (String)

    The Kaltura media entry.

  • flavor_param_id (Integer)

    The ID of the FlavorParam (individual encoding profile) to use.

Returns:

  • (nil)

    Returns nothing.

Since:

  • 0.1.3



21
22
23
24
25
26
27
# File 'lib/kaltura_fu/flavor.rb', line 21

def add_flavor_to_video(video_id,flavor_param_id)
  self.check_for_client_session
  
  if video_exists?(video_id)
    @@client.flavor_asset_service.convert(video_id,flavor_param_id)
  end
end

#find_flavor_from_entry(video_id, flavor_param_id) ⇒ Kaltura::FlavorAsset

TODO:

Ensure a graceful error when the FlavorAsset isn’t found as well.

Finds a specific flavor object given a Kaltura entry and FlavorParam. This is useful if you want to delete a specific type of encoding from a Video programatically.

Parameters:

  • video_id (String)

    The Kaltura media entry.

  • flavor_param_id (Integer)

    The ID of the FlavorParam (individual encoding profile) to use.

Returns:

  • (Kaltura::FlavorAsset)

    Returns the requested FlavorAsset.

Raises:

  • (RuntimeError)

    Raises a runtime error if the video_id doesn’t exist.

Since:

  • 0.1.3



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/kaltura_fu/flavor.rb', line 44

def find_flavor_from_entry(video_id,flavor_param_id)
  self.check_for_client_session
  return_flavor = nil
  
  if video_exists?(video_id)
    flavor_array = @@client.flavor_asset_service.get_flavor_assets_with_params(video_id)
    flavor_array.each do |flavor_object|
      if flavor_object.flavor_params.id == flavor_param_id
        return_flavor = flavor_object.flavor_asset.id
      end
    end
  end
end

#remove_flavor_from_video(entry_or_flavor, flavor_param_id = nil) ⇒ Boolean

TODO:

Ensure that a missing FlavorParam or FlavorAsset doesn’t cause unexpected behavior.

Removes either a specific flavor asset. If you know the exact Flavor you wish to delete

you can specify it.  Otherwise, you can specify the videos entry_id and a specific 
FlavorParam (encoding profile) and it will locate and remove the Flavor for you.

Parameters:

  • entry_or_flavor (String)

    The Kaltura entry_id or the FlavorAsset ID.

  • flavor_param_id (Integer) (defaults to: nil)

    An optional flavorParam encoding profile to seek.

Returns:

  • (Boolean)

    Returns true if the removal was succesful.

Raises:

  • (RuntimeError)

    Raises a runtime error if the video’s entry_id doesn’t exist.

Since:

  • 0.1.3



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/kaltura_fu/flavor.rb', line 74

def remove_flavor_from_video(entry_or_flavor, flavor_param_id=nil)
  self.check_for_client_session
  ret_val = false
  
  if flavor_param_id.nil?
    @@client.flavor_asset_service.delete(entry_or_flavor)
    ret_val = true
  else
    flavor_to_delete = self.find_flavor_from_entry(entry_or_flavor,flavor_param_id)
    self.remove_flavor_from_video(flavor_to_delete)
  end
  ret_val
end