Exemple #1
0
"""
USER = '******' # add Rambla user account name
PWD = 'xxx' # add Rambla user account pwd
RASS_SERVER = "xxx" # either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located)
LOCAL_FILE = "/path/to/local/video/file" # add path to local video file, to be uploaded to the CDN

import sys, json, time
import raws_json
from raws_json.raws_service import RawsService, Feed, Query, RequestError
from raws_json.meta.meta import *
from raws_json.meta.vocab import Vocab
from raws_json.rass.service import RassService
from raws_json.meta.service import MetaService

# initialize client
rass = RassService(username = USER, password = PWD, server = RASS_SERVER)
meta = MetaService(username = USER, password = PWD)

try:
    # upload some files to the the 'meta_sample' dir on the CDN (so we can attach metadata to them)
    item1 = rass.createItem("meta_sample/", "elephants_dream.mp4", LOCAL_FILE)
    item1b = rass.createItem("meta_sample/", "elephants_dream.jpg", LOCAL_FILE)
    print "Created item instances : %s + %s " % (item1["entry"]["id"], item1b["entry"]["id"])
    item2 = rass.createItem("meta_sample/", "big_buck_bunny.mp4", LOCAL_FILE)
    print "Created item instance : %s " % item2["entry"]["id"]
    item3 = rass.createItem("meta_sample/", "sintel.mp4", LOCAL_FILE)
    print "Created item instance : %s " % item3["entry"]["id"]
    item4 = rass.createItem("meta_sample/", "yo_frankie.mp4", LOCAL_FILE) # we will not attach metadata to this item
    print "Created item instance : %s " % item4["entry"]["id"]

    # create vocabs
Exemple #2
0
    
    Before running this sample, you must set your Rambla user account credentials and the path to a local video file (to be encoded) in the settings below.
"""
USER = '******' # add Rambla user account name
PWD = 'xxx' # add Rambla user account pwd
RASS_SERVER = "xxx" # either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located)
LOCAL_FILE = "/path/to/local/video/file" # add path to local video file, to be uploaded to the CDN

import sys, json, time
import raws_json
from raws_json.raws_service import RawsService, Feed, Query, RequestError
from raws_json.rass.service import RassService

try:
    # initialize client
    rass = RassService(username = USER, password = PWD, server = RASS_SERVER)

    # create a dir on the CDN
    dir = rass.createDir("crud_test/", True)
    print "Created dir with relative path = '%s'" % dir["entry"]["content"]["params"]["path"]

    # upload a file to a sub-directory (which will be created if it doesn't exist)
    item = rass.createItem("crud_test/subdir/", "filename.mp4", LOCAL_FILE)
    print "Created item with relative path = '%s' and size = %s" % (item["entry"]["content"]["params"]["path"], dir["entry"]["content"]["params"]["size"])
    
    # get list of all files in "crud_test/subdir/"
    print "Getting a list of all files in 'crud_test/subdir/' ..."
    feed = rass.getDirList(path = "crud_test/subdir/", query = Query(params = {"kind":"file"}))
    feed_obj = Feed(feed)
    for item in feed_obj.entries:
        print ".. found file with path = '%s', item instance url = %s" % (item["entry"]["content"]["params"]["path"], item["entry"]["id"])