Module: KalturaFu::Video
- Defined in:
- lib/kaltura_fu/video.rb
Overview
the Video module provides class methods to retrieve and set information specific to Kaltura Entries.
Instance Method Summary collapse
-
#check_video_status(video_id) ⇒ Number
Checks each flavor under a Kaltura entry for readiness.
-
#delete_video(video_id) ⇒ Boolean
Deletes a Kaltura entry.
-
#get_original_file_extension(video_id) ⇒ String
Returns the file extension of the original file uploaded to Kaltura for a given entry.
-
#get_original_flavor(video_id) ⇒ String
Returns the flavor of the original file uploaded to Kaltura.
-
#get_thumbnail(video_id, time = nil, width = @@config[:thumb_width], height = @@config[:thumb_height]) ⇒ String
Returns the URL of the requested video.
-
#get_video_info(video_id) ⇒ Kaltura::MediaEntry
Gets a Kaltura::MediaEntry given a Kaltura entry.
-
#set_syndication_url(video_id) ⇒ String
Returns a download URL suitable to be used for iTunes one-click syndication.
-
#set_video_description(video_id, description) ⇒ Boolean
Sets the Kaltura entry description metadata.
Instance Method Details
#check_video_status(video_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.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kaltura_fu/video.rb', line 17 def check_video_status(video_id) KalturaFu.check_for_client_session video_array = KalturaFu.client.flavor_asset_service.get_by_entry_id(video_id) status = Kaltura::Constants::FlavorAssetStatus::ERROR video_array.each do |video| status = video.status if video.status != Kaltura::Constants::FlavorAssetStatus::READY if video.status == Kaltura::Constants::FlavorAssetStatus::NOT_APPLICABLE status = Kaltura::Constants::FlavorAssetStatus::READY else break end end end status end |
#delete_video(video_id) ⇒ Boolean
Deletes a Kaltura entry.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kaltura_fu/video.rb', line 42 def delete_video(video_id) KalturaFu.check_for_client_session begin KalturaFu.client.media_service.delete(video_id) true rescue Kaltura::APIError => e false end end |
#get_original_file_extension(video_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 |
# File 'lib/kaltura_fu/video.rb', line 81 def get_original_file_extension(video_id) KalturaFu.check_for_client_session video_array = KalturaFu.client.flavor_asset_service.get_by_entry_id(video_id) source_extension = nil video_array.each do |video| if video.is_original source_extension = video.file_ext end end source_extension end |
#get_original_flavor(video_id) ⇒ String
Returns the flavor of the original file uploaded to Kaltura.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/kaltura_fu/video.rb', line 60 def get_original_flavor(video_id) KalturaFu.check_for_client_session video_array = KalturaFu.client.flavor_asset_service.get_by_entry_id(video_id) ret_flavor = nil video_array.each do |video| if video.is_original ret_flavor = video.id.to_s end end ret_flavor end |
#get_thumbnail(video_id, time = nil, width = @@config[:thumb_width], height = @@config[:thumb_height]) ⇒ String
Returns the URL of the requested video.
104 105 106 107 108 109 110 |
# File 'lib/kaltura_fu/video.rb', line 104 def get_thumbnail(video_id,time=nil,width=@@config[:thumb_width],height=@@config[:thumb_height]) config = KalturaFu.config thumbnail_string = "#{config[:service_url]}/p/#{config[:partner_id]}/thumbnail/entry_id/#{video_id}/width/#{width}/height/#{height}" thumbnail_string += "/vid_sec/#{time}" unless time.nil? return thumbnail_string end |
#get_video_info(video_id) ⇒ Kaltura::MediaEntry
Gets a Kaltura::MediaEntry given a Kaltura entry.
119 120 121 122 123 124 125 |
# File 'lib/kaltura_fu/video.rb', line 119 def get_video_info(video_id) KalturaFu.check_for_client_session response = self.video_exists?(video_id) raise "ID: #{video_id} Not found!" unless response response end |
#set_syndication_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.
135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/kaltura_fu/video.rb', line 135 def (video_id) KalturaFu.check_for_client_session video_array = KalturaFu.client.flavor_asset_service.get_by_entry_id(video_id) download_url = nil video_array.each do |video| if video.is_original download_url = 'http://www.kaltura.com/p/203822/sp/20382200/serveFlavor/flavorId/' + video.id.to_s + '/name/' + video.id.to_s + '.' + video.file_ext.to_s + '?novar=0' end end download_url end |
#set_video_description(video_id, description) ⇒ Boolean
Sets the Kaltura entry description metadata.
157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/kaltura_fu/video.rb', line 157 def set_video_description(video_id,description) KalturaFu.check_for_client_session if self.video_exists?(video_id) new_entry = Kaltura::MediaEntry.new new_entry.description = description KalturaFu.client.media_service.update(video_id,new_entry) true else false end end |