예제 #1
0
def thumbnail_add_from_url(client, entry_id, thumburl):
    msgs = []
    try:
        thumbnail_asset_service = KalturaThumbAssetService(client)
        thumb_asset = KalturaThumbAsset()
        thumb_asset = thumbnail_asset_service.add(entry_id, thumb_asset)
        thumb_id = thumb_asset.getId()
        msgs.append('ThumbAsset added to entry, id %s' % thumb_id)
        content_resource = KalturaUrlResource(url=thumburl)
        thumbnail_asset_service.setContent(thumb_id, content_resource)
        msgs.append('url %s applied to thumbnail with id %s' % (thumburl, thumb_id))
        return {'success': True, 'message': msgs}
    except Exception as e:
        msgs.append('Failed to add thumbnail from %s to media with entry_id %s' % (entry_id, thumburl))
        msgs.append('Exception: ' + str(e))
        return {'success': False, 'message': msgs}
예제 #2
0
def updateThumbnail(file_path, entry_id, client=None, set_default=False):
    try:
     # create session
        if client is None:
            raise Exception("Client can not be None")
        thumbnail_asset_service = KalturaThumbAssetService(client)
        thumb_asset = KalturaThumbAsset()
        thumb_asset = thumbnail_asset_service.addFromImage(entry_id, file(file_path, 'rb'))
        if set_default:
            thumbnail_set_default(client, thumb_asset.getId())
        #mediaEntry = client.baseEntry.updateThumbnailJpeg(
        #    entry_id, file(file_path, 'rb'))
        return (True, thumb_asset.getId())
    except:
        return (False,
                "Unexpected error:" + "<p>" + repr(sys.exc_info()) + "</p>")
예제 #3
0
def updateThumbnail(file_path, entry_id, client=None, set_default=False):
    try:
        # create session
        if client is None:
            raise Exception("Client can not be None")
        thumbnail_asset_service = KalturaThumbAssetService(client)
        thumb_asset = KalturaThumbAsset()
        thumb_asset = thumbnail_asset_service.addFromImage(
            entry_id, file(file_path, 'rb'))
        if set_default:
            thumbnail_set_default(client, thumb_asset.getId())
            # mediaEntry = client.baseEntry.updateThumbnailJpeg(
        #    entry_id, file(file_path, 'rb'))
        return (True, thumb_asset.getId())
    except:
        return (False,
                "Unexpected error:" + "<p>" + repr(sys.exc_info()) + "</p>")
예제 #4
0
def thumbnail_add_from_url(client, entry_id, thumburl):
    msgs = []
    try:
        thumbnail_asset_service = KalturaThumbAssetService(client)
        thumb_asset = KalturaThumbAsset()
        thumb_asset = thumbnail_asset_service.add(entry_id, thumb_asset)
        thumb_id = thumb_asset.getId()
        msgs.append('ThumbAsset added to entry, id %s' % thumb_id)
        content_resource = KalturaUrlResource(url=thumburl)
        thumbnail_asset_service.setContent(thumb_id, content_resource)
        msgs.append('url %s applied to thumbnail with id %s' %
                    (thumburl, thumb_id))
        return {'success': True, 'message': msgs}
    except Exception as e:
        msgs.append(
            'Failed to add thumbnail from %s to media with entry_id %s' %
            (entry_id, thumburl))
        msgs.append('Exception: ' + str(e))
        return {'success': False, 'message': msgs}