Module: KalturaFu::Entry::Flavor
- Defined in:
- lib/kaltura_fu/entry/flavor.rb
Overview
The flavor module mixes in instance methods for a class that includes the Entry module. This module primarily provides means to operate on the original upload to Kaltura. It also contains a very important method for checking the overall status of a specific entry.
Instance Method Summary collapse
-
#check_status(entry_id) ⇒ Number
Checks each flavor under a Kaltura entry for readiness.
-
#original_download_url(video_id) ⇒ String
Returns a download URL suitable to be used for iTunes one-click syndication.
-
#original_file_extension(entry_id) ⇒ String
Returns the file extension of the original file uploaded to Kaltura for a given entry.
-
#original_flavor(entry_id) ⇒ String
Returns the flavor ID of the original file uploaded to Kaltura.
Instance Method Details
#check_status(entry_id) ⇒ Number
Checks each flavor under a Kaltura entry for readiness. It is possible under v3 of the Kaltura API to receive a ‘ready’ status for the entry while flavors are still encoding. Attempting to view the entry with a player will result in a ‘Media is converting’ error screen. This prevents that occurance.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kaltura_fu/entry/flavor.rb', line 20 def check_status(entry_id) KalturaFu.check_for_client_session entry_status = get_status(entry_id) if entry_status == Kaltura::Constants::Entry::Status::READY flavor_array = KalturaFu.client.flavor_asset_service.get_by_entry_id(entry_id) error_count = 0 not_ready_count = 0 ready_count = 0 flavor_array.each do |flavor| case flavor.status when Kaltura::Constants::FlavorAssetStatus::READY || Kaltura::Constants::FlavorAssetStatus::DELETED || Kaltura::Constants::FlavorAssetStatus::NOT_APPLICABLE ready_count +=1 when Kaltura::Constants::FlavorAssetStatus::ERROR error_count +=1 when Kaltura::Constants::FlavorAssetStatus::QUEUED || Kaltura::Constants::FlavorAssetStatus::CONVERTING not_ready_count +=1 end end #puts "errors: #{error_count} ready:#{ready_count} not_ready:#{not_ready_count} total:#{video_array.size} \n" if error_count > 0 Kaltura::Constants::FlavorAssetStatus::ERROR elsif not_ready_count > 0 Kaltura::Constants::FlavorAssetStatus::CONVERTING else Kaltura::Constants::FlavorAssetStatus::READY end else entry_status end end |
#original_download_url(video_id) ⇒ String
Returns a download URL suitable to be used for iTunes one-click syndication. serveFlavor is not documented in KalturaAPI v3 nor is the ?novar=0 paramter.
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/kaltura_fu/entry/flavor.rb', line 103 def original_download_url(video_id) KalturaFu.check_for_client_session service_url = KalturaFu.config[:service_url] || "http://www.kaltura.com" partner_id = KalturaFu.config[:partner_id] subpartner_id = (partner_id.to_i * 100).to_s flavor = original_flavor(video_id) extension = original_file_extension(video_id) "#{service_url}/p/#{partner_id}/sp/#{subpartner_id}/serveFlavor/flavorId/#{flavor}/name/#{flavor}.#{extension}?novar=0" end |
#original_file_extension(entry_id) ⇒ String
Returns the file extension of the original file uploaded to Kaltura for a given entry
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/kaltura_fu/entry/flavor.rb', line 81 def original_file_extension(entry_id) KalturaFu.check_for_client_session flavor_array = KalturaFu.client.flavor_asset_service.get_by_entry_id(entry_id) source_extension = nil flavor_array.each do |flavor| if flavor.is_original source_extension = flavor.file_ext break end end source_extension end |
#original_flavor(entry_id) ⇒ String
Returns the flavor ID of the original file uploaded to Kaltura.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/kaltura_fu/entry/flavor.rb', line 59 def original_flavor(entry_id) KalturaFu.check_for_client_session flavor_array = KalturaFu.client.flavor_asset_service.get_by_entry_id(entry_id) ret_flavor = nil flavor_array.each do |flavor| if flavor.is_original ret_flavor = flavor.id.to_s break end end ret_flavor end |