Class: Kaltura::Service::MediaService

Inherits:
BaseService show all
Defined in:
lib/kaltura/service/media_service.rb

Overview

Examples:

Update an existing entry:

update_entry = Kaltura::MediaEntry.new
update_entry.description = "Pancakes are lame yo."
client.media_service.update('1_qua324a',update_entry)

Delete an existing entry:

client.media_service.delete('1_qua324a')

Update an Entry thumbnail via file upload:

thumbnail_file = File.open('/path/to/thumbnail_file')
client.media_service.update_thumbnail_from_jpeg('1_qua324a',thumbnail_file)

Update an entry thumbnail from a url:

client.media_service.update_thumbnail_from_url('1_qua324a','http://twitter.com/waffles/waffletastic.jpg')

Update an entry thumbnail from another entry:

client.media_service.update_thumbnail_from_source_entry('1_qua324a','0_k24aj1b',5)

Instance Attribute Summary

Attributes inherited from BaseService

#client

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #perform_request

Constructor Details

This class inherits a constructor from Kaltura::Service::BaseService

Instance Method Details

#add_from_bulk(media_entry, url, bulk_upload_id) ⇒ Kaltura::MediaEntry

This method creates a new media entry from either a HTTP or FTP URL given a batch ID.

The intention of this action is to import videos in large quantities from another service without overloading either the former service nor Kaltura. This is probably best handled from within the KMC with their batch importing wizard, even though this is exposed to anyone on API wrappers.

Parameters:

  • media_entry (Kaltura::MediaEntry)

    A newly insantiated media entry with metadata filled out that will be later returned with the ID field as stored on the database.

  • url (String)

    A HTTP or FTP URL. I would imagine the FTP cannot be password protected.

  • bulk_upload_id (Integer)

    The ID of the bulk upload job.

Returns:

  • (Kaltura::MediaEntry)

    Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Raises:

  • (Kaltura::APIError)

    Raises the default Kaltura errors plus ‘PROPERTY_VALIDATION_MIN_LENGTH’ when a specific attribute of the media entry doesn’t have a long enough length and ‘PROPERTY_VALIDATION_CANNOT_BE_NULL’ when a specific attribute is not allowed to be null.



63
64
65
66
67
68
69
# File 'lib/kaltura/service/media_service.rb', line 63

def add_from_bulk(media_entry, url, bulk_upload_id)
	kparams = {}
	client.add_param(kparams, 'mediaEntry', media_entry)
	client.add_param(kparams, 'url', url)
	client.add_param(kparams, 'bulkUploadId', bulk_upload_id)
	perform_request('media','addFromBulk',kparams,false)
end

#add_from_entry(media_entry, source_entry_id, source_flavor_params_id = nil) ⇒ Kaltura::MediaEntry

Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Parameters:

  • media_entry (Kaltura::MediaEntry)

    A newly insantiated media entry with metadata filled out that will be later returned with the ID field as stored on the database.

  • source_entry_id (String)

    The media entry to copy from.

  • source_flavor_params_id (Integer) (defaults to: nil)

    The encoding type to use as the original flavor for the new entry.

Returns:

  • (Kaltura::MediaEntry)

    Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Raises:

Since:

  • 0.4.7



213
214
215
216
217
218
219
# File 'lib/kaltura/service/media_service.rb', line 213

def add_from_entry(media_entry, source_entry_id,source_flavor_params_id=nil)
  kparams = {}
  client.add_params(kparams,'mediaEntry',media_entry)
  client.add_params(kparams,'sourceEntryId',source_entry_id)
  client.add_params(kparams,'sourceFlavorParamsId',source_flavor_params_id)
  perform_request('media','addFromEntry',kparams,false)
end

#add_from_flavor_asset(media_entry, source_flavor_asset_id) ⇒ Kaltura::MediaEntry

Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Parameters:

  • media_entry (Kaltura::MediaEntry)

    A newly insantiated media entry with metadata filled out that will be later returned with the ID field as stored on the database.

  • source_flavor_asset_id (String)

    A specific flavor to use as the source of the copy.

Returns:

  • (Kaltura::MediaEntry)

    Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Raises:

Since:

  • 0.4.7



236
237
238
239
240
241
# File 'lib/kaltura/service/media_service.rb', line 236

def add_from_flavor_asset(media_entry, source_flavor_asset_id)
  kparams = {}
  client.add_params(kparams,'mediaEntry',media_entry)
  client.add_params(kparams,'sourceFlavorAssetId',source_flavor_asset_id)
  perform_request('media','addFromFlavorAsset',kparams,false)
end

#add_from_recorded_webcam(media_entry, webcam_token_id) ⇒ Object



184
185
186
187
188
189
# File 'lib/kaltura/service/media_service.rb', line 184

def add_from_recorded_webcam(media_entry, webcam_token_id)
	kparams = {}
	client.add_param(kparams, 'mediaEntry', media_entry)
	client.add_param(kparams, 'webcamTokenId', webcam_token_id)
	perform_request('media','addFromRecordedWebcam',kparams,false)
end

#add_from_search_result(media_entry = nil, search_result = nil) ⇒ Kaltura::MediaEntry

Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Parameters:

  • media_entry (Kaltura::MediaEntry) (defaults to: nil)

    A newly insantiated media entry with metadata filled out that will be later returned with the ID field as stored on the database.

  • search_result (Kaltura::SearchResult) (defaults to: nil)

    A specific Kaltura entry provided from a search provided by Kaltura.

Returns:

  • (Kaltura::MediaEntry)

    Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Raises:

  • (Kaltura::APIError)

    Raises the default Kaltura errors plus ‘PROPERTY_VALIDATION_MIN_LENGTH’ when a specific attribute of the media entry doesn’t have a long enough length and ‘PROPERTY_VALIDATION_CANNOT_BE_NULL’ when a specific attribute is not allowed to be null.



119
120
121
122
123
124
# File 'lib/kaltura/service/media_service.rb', line 119

def add_from_search_result(media_entry=nil, search_result=nil)
	kparams = {}
	client.add_param(kparams, 'mediaEntry', media_entry)
	client.add_param(kparams, 'searchResult', search_result)
	perform_request('media','addFromSearchResult',kparams,false)
end

#add_from_uploaded_file(media_entry, upload_token_id) ⇒ Kaltura::MediaEntry

Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Examples:

This is how a full upload process looks like:

media_entry = Kaltura::MediaEntry.new
media_entry.media_type = Kaltura::Constants::Media::Type::VIDEO
video_file = File.open "/home/prob/video.mp4"
begin
  video_token = client.media_service.upload(video_file)
  created_entry = client.media_service.add_from_uploaded_file(media_entry,video_token)
rescue Kaltura::APIError => e
end

Parameters:

  • media_entry (Kaltura::MediaEntry)

    A newly insantiated media entry with metadata filled out that will be later returned with the ID field as stored on the database.

  • upload_token_id (String)

    An upload token returned from Kaltura::Service::MediaService#upload

Returns:

  • (Kaltura::MediaEntry)

    Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Raises:

  • (Kaltura::APIError)

    Raises the default Kaltura errors plus ‘PROPERTY_VALIDATION_MIN_LENGTH’ when a specific attribute of the media entry doesn’t have a long enough length and ‘PROPERTY_VALIDATION_CANNOT_BE_NULL’ when a specific attribute is not allowed to be null. Also raises ‘UPLOADED_FILE_NOT_FOUND_BY_TOKEN’ if the upload_token_id is invalid.



156
157
158
159
160
161
# File 'lib/kaltura/service/media_service.rb', line 156

def add_from_uploaded_file(media_entry, upload_token_id)
	kparams = {}
	client.add_param(kparams, 'mediaEntry', media_entry)
	client.add_param(kparams, 'uploadTokenId', upload_token_id)
	perform_request('media','addFromUploadedFile',kparams,false)
end

#add_from_url(media_entry, url) ⇒ Kaltura::MediaEntry

Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Parameters:

  • media_entry (Kaltura::MediaEntry)

    A newly insantiated media entry with metadata filled out that will be later returned with the ID field as stored on the database.

  • url (String)

    A HTTP or FTP URL. I would imagine the FTP cannot be password protected.

  • bulk_upload_id (Integer)

    The ID of the bulk upload job.

Returns:

  • (Kaltura::MediaEntry)

    Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Raises:

  • (Kaltura::APIError)

    Raises the default Kaltura errors plus ‘PROPERTY_VALIDATION_MIN_LENGTH’ when a specific attribute of the media entry doesn’t have a long enough length and ‘PROPERTY_VALIDATION_CANNOT_BE_NULL’ when a specific attribute is not allowed to be null.



93
94
95
96
97
98
# File 'lib/kaltura/service/media_service.rb', line 93

def add_from_url(media_entry, url)
	kparams = {}
	client.add_param(kparams, 'mediaEntry', media_entry)
	client.add_param(kparams, 'url', url)
	perform_request('media','addFromUrl',kparams,false)
end

#anonymous_rank(entry_id, rank) ⇒ nil

Rank a media entry. This does no validation to prevent duplicate rankings. Fairly worthless. It is suggested you maintain rankings on your own application.

Parameters:

  • The (String)

    Kaltura entry to be updated.

  • The (Integer)

    rank to apply.

Returns:

  • (nil)

    Returns nothing.

Raises:



538
539
540
541
542
543
# File 'lib/kaltura/service/media_service.rb', line 538

def anonymous_rank(entry_id, rank)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	client.add_param(kparams, 'rank', rank)
	perform_request('media','anonymousRank',kparams,false)
end

#approve(entry_id) ⇒ nil

Approves the media entry and marks all pending flags as moderated. This makes the entry playable.

Parameters:

  • entry_id (String)

    The Kaltura media entry to be updated.

Returns:

  • (nil)

    Returns nothing

Raises:



503
504
505
506
507
# File 'lib/kaltura/service/media_service.rb', line 503

def approve(entry_id)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	perform_request('media','approve',kparams,false)
end

#convert(entry_id, conversion_profile_id, dynamic_conversion_attributes = nil) ⇒ Integer

TODO:

Add Kaltura::ConversionAttribute.

Converts a media entry. This method was not originallly in kaltura-ruby and was added after peruising the API docs. I wouldn’t suggest using this method. Any upload action will already trigger a conversion, so instead use request conversion.

Parameters:

  • entry_id (String)

    The media entry to convert.

  • conversion_profile_id (Integer)

    The conversion profile to convert the entry with.

  • dynamic_conversion_attributes (Array) (defaults to: nil)

    An Array of Kaltura::ConversionAttribute . It would be helpful if that object type existed.

Returns:

  • (Integer)

    Returns the conversion profile that was converted on the entry_id.

Raises:

Since:

  • 0.4.7



260
261
262
263
264
265
266
# File 'lib/kaltura/service/media_service.rb', line 260

def convert(entry_id,conversion_profile_id,dynamic_conversion_attributes=nil)
  kparams = {}
  client.add_params(kparams,'entryId',entry_id)
  client.add_params(kparams,'conversionProfileId',conversion_profile_id)
  client.add_params(kparams,'dynamicConversionAttributes',dynamic_conversion_attributes)
  perform_request('media','convert',kparams,false)
end

#count(filter = nil) ⇒ Integer

Counts the total number of media entries that meet the filter criteria.

Parameters:

Returns:

  • (Integer)

    Returns the total.

Raises:



350
351
352
353
354
# File 'lib/kaltura/service/media_service.rb', line 350

def count(filter=nil)
	kparams = {}
	client.add_param(kparams, 'filter', filter)
	perform_request('media','count',kparams,false)
end

#delete(entry_id) ⇒ Object

Raises:



318
319
320
321
322
# File 'lib/kaltura/service/media_service.rb', line 318

def delete(entry_id)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	perform_request('media','delete',kparams,false)
end

#flag(moderation_flag) ⇒ nil

Flags an inappropriate media entry for moderation.

Parameters:

Returns:

  • (nil)

    Returns nothing

Raises:



471
472
473
474
475
# File 'lib/kaltura/service/media_service.rb', line 471

def flag(moderation_flag)
	kparams = {}
	client.add_param(kparams, 'moderationFlag', moderation_flag)
	perform_request('media','flag',kparams,false)
end

#get(entry_id, version = -1)) ⇒ Kaltura::MediaEntry

Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Returns:

  • (Kaltura::MediaEntry)

    Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Raises:



280
281
282
283
284
285
# File 'lib/kaltura/service/media_service.rb', line 280

def get(entry_id, version=-1)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	client.add_param(kparams, 'version', version)
	perform_request('media','get',kparams,false)
end

#list(filter = nil, pager = nil) ⇒ Kaltura::Response::MediaListResponse

Lists media entries given a filter and provides paging support for large lists.

Parameters:

Returns:

Raises:



334
335
336
337
338
339
# File 'lib/kaltura/service/media_service.rb', line 334

def list(filter=nil, pager=nil)
	kparams = {}
	client.add_param(kparams, 'filter', filter)
	client.add_param(kparams, 'pager', pager)
	perform_request('media','list',kparams,false)
end

#list_flags(entry_id, pager = nil) ⇒ Kaltura::Response::ModerationFlagListResponse

Lists all pending moderation flags for the media entry with paging support for numerous flags.

Parameters:

  • entry_id (String)

    The entry to locate moderation flags for.

  • The (Kaltura::FilterPager)

    default Kaltura pager.

Returns:

Raises:



519
520
521
522
523
524
# File 'lib/kaltura/service/media_service.rb', line 519

def list_flags(entry_id, pager=nil)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	client.add_param(kparams, 'pager', pager)
	perform_request('media','listFlags',kparams,false)
end

#reject(entry_id) ⇒ nil

Rejects the media entry and marks all pending flags as moderated. This makes the entry non-playable.

Parameters:

  • entry_id (String)

    The Kaltura media entry to be updated.

Returns:

  • (nil)

    Returns nothing

Raises:



487
488
489
490
491
# File 'lib/kaltura/service/media_service.rb', line 487

def reject(entry_id)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	perform_request('media','request',kparams,false)
end

#request_conversion(entry_id, file_format) ⇒ Integer

Requests a new conversion job.

Use this over Kaltura::Service::MediaService#convert.

Parameters:

  • entry_id (String)

    The entry to be updated.

  • file_format (String)

    The format to convert to.

Returns:

  • (Integer)

    The Kalatura::FlavorParams ID converted.

Raises:



455
456
457
458
459
460
# File 'lib/kaltura/service/media_service.rb', line 455

def request_conversion(entry_id, file_format)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	client.add_param(kparams, 'fileFormat', file_format)
	perform_request('media','requestConversion',kparams,false)
end

#update(entry_id, media_entry) ⇒ Kaltura::MediaEntry

Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Returns:

  • (Kaltura::MediaEntry)

    Returns a media entry object with the metadata fields filled out with the additional database fields the Kaltura service set. It would be a good idea to store the ID somewhere.

Raises:



302
303
304
305
306
307
# File 'lib/kaltura/service/media_service.rb', line 302

def update(entry_id, media_entry)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	client.add_param(kparams, 'mediaEntry', media_entry)
	perform_request('media','update',kparams,false)
end

#update_thumbnail(entry_id, time_offset) ⇒ Kaltura::MediaEntry

Updates a specific media entries thumbnail by a specified time offset in seconds.

Parameters:

  • entry_id (String)

    The Kaltura entry ID.

  • time_offset (Integer)

    The offset in seconds to create the thumbnail.

Returns:

Raises:

  • (Kalutra::APIError)

    Raises default Kaltura errors.



384
385
386
387
388
389
# File 'lib/kaltura/service/media_service.rb', line 384

def update_thumbnail(entry_id, time_offset)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	client.add_param(kparams, 'timeOffset', time_offset)
	perform_request('media','updateThumbnail',kparams,false)
end

#update_thumbnail_from_source_entry(entry_id, source_entry_id, time_offset) ⇒ Kaltura::MediaEntry

Updates a media entries thumbnail from another media entry given a time offset.

Parameters:

  • entry_id (String)

    The entry to be updated.

  • source_entry_id (String)

    The entry to create the thumbnail from.

  • time_offset (Integer)

    The offset in seconds to create the thumbnail.

Returns:

Raises:



402
403
404
405
406
407
408
# File 'lib/kaltura/service/media_service.rb', line 402

def update_thumbnail_from_source_entry(entry_id, source_entry_id, time_offset)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	client.add_param(kparams, 'sourceEntryId', source_entry_id)
	client.add_param(kparams, 'timeOffset', time_offset)
	perform_request('media','updateThumbnailFromSourceEntry',kparams,false)
end

#update_thumbnail_from_url(entry_id, url) ⇒ Kaltura::MediaEntry

Updates a media entries thumbnail given a URL.

Parameters:

  • entry_id (String)

    The entry to be updated.

  • file_data (File)

    The URL of a JPEG file to use as the new thumbnail.

Returns:

Raises:



437
438
439
440
441
442
# File 'lib/kaltura/service/media_service.rb', line 437

def update_thumbnail_from_url(entry_id, url)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	client.add_param(kparams, 'url', url)
	perform_request('media','updateThumbnailFromUrl',kparams,false)
end

#update_thumbnail_jpeg(entry_id, file_data) ⇒ Kaltura::MediaEntry

Updates a media entries thumbnail from a JPEG file.

Parameters:

  • entry_id (String)

    The entry to be updated.

  • file_data (File)

    The JPEG file to use as the new thumbnail.

Returns:

Raises:



420
421
422
423
424
425
# File 'lib/kaltura/service/media_service.rb', line 420

def update_thumbnail_jpeg(entry_id, file_data)
	kparams = {}
	client.add_param(kparams, 'entryId', entry_id)
	client.add_param(kparams, 'fileData', file_data)
	perform_request('media','updateThumbnailJpeg',kparams,false)
end

#upload(file_data) ⇒ String

Uploads a media file to Kaltura.

This is the first step in creating a media entry from a local file.

Parameters:

  • file_data (File)

    The file to upload.

Returns:

  • (String)

    Returns the upload token ID to be used for entry creation.

Raises:

  • (Kalutra::APIError)

    Raises default Kaltura errors.

See Also:



368
369
370
371
372
# File 'lib/kaltura/service/media_service.rb', line 368

def upload(file_data)
	kparams = {}
	client.add_param(kparams, 'fileData', file_data)
	perform_request('media','upload',kparams,false)
end