Module: KalturaBox::Entry::ClassMethods
- Defined in:
- lib/kaltura_box/entry/class_methods.rb
Instance Method Summary collapse
- #add_thumbnail(entry_id, value, type = nil) ⇒ Object
- #update_all_videos!(options = {}) ⇒ Object
- #upload(upload_object, options = {}) ⇒ Object
- #video_list(keyword = nil) ⇒ Object
Instance Method Details
#add_thumbnail(entry_id, value, type = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kaltura_box/entry/class_methods.rb', line 25 def add_thumbnail(entry_id, value, type=nil) client = KalturaBox::Client.update_session media_service = Kaltura::KalturaMediaService.new(client) media = nil case type when :jpg media = media_service.update_thumbnail_jpeg(entry_id, value) when :url media = media_service.update_thumbnail_from_url(entry_id, value) else media = media_service.update_thumbnail(entry_id, value) end media.thumbnail_url end |
#update_all_videos!(options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/kaltura_box/entry/class_methods.rb', line 58 def update_all_videos!(={}) video_list.each do |v| entry = self.new( entry_id: v.id, title: v.name, description: v.description, thumbnail_url: v.thumbnail_url, data_url: v.data_url, download_url: v.download_url, ms_duration: v.ms_duration, plays: v.plays, views: v.views ) .each { |key, value| entry.send("#{key}=", value) } entry.tag_list = v. if entry.try(:tag_list) entry.save end end |
#upload(upload_object, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kaltura_box/entry/class_methods.rb', line 9 def upload(upload_object, ={}) client = KalturaBox::Client.update_session media_entry = Kaltura::KalturaMediaEntry.new .each do |key, value| media_entry.send("#{key}=", value) if valid_entry_attribute?(key) end media_entry.media_type = Kaltura::KalturaMediaType::VIDEO unless [:media_type] if [:source] == :file upload_token = client.media_service.upload(upload_object) client.media_service.add_from_uploaded_file(media_entry,upload_token).id end end |
#video_list(keyword = nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/kaltura_box/entry/class_methods.rb', line 41 def video_list(keyword = nil) client = KalturaBox::Client.update_session media = Kaltura::KalturaMediaService.new(client) if keyword filter = Kaltura::KalturaBaseEntryFilter.new filter.free_text = keyword media_list = media.list(filter) else media_list = media.list end return nil unless media_list.present? && media_list.objects media_list.objects.reject { |v| v.media_type != 1 } end |