Esempio n. 1
0
import manifest_utils
import http_utils
import sys
import os

if len(sys.argv) < 3:
    print 'Usage:\n\tpython %s <manifest url> <output path>' % os.path.basename(
        __file__)
    sys.exit(1)

_, manifestUrl, outputPath = sys.argv

code, headers, body = http_utils.getUrl(manifestUrl, {})
mimeType = headers['content-type'][0]
urls = manifest_utils.getManifestUrls(manifestUrl, body, mimeType, {})

for curUrl in [manifestUrl] + urls:
    fileName = os.path.join(outputPath, os.path.split(curUrl)[1].split('?')[0])
    if os.path.exists(fileName):
        print 'Error: %s already exists' % fileName
        break
    http_utils.downloadUrl(curUrl, fileName)
import manifest_utils
import http_utils
import sys
import os

if len(sys.argv) < 3:
	print 'Usage:\n\tpython %s <manifest url> <output path>' % os.path.basename(__file__)
	sys.exit(1)

_, manifestUrl, outputPath = sys.argv

code, headers, body = http_utils.getUrl(manifestUrl, {})
mimeType = headers['content-type'][0]
urls = manifest_utils.getManifestUrls(manifestUrl, body, mimeType, {})

for curUrl in [manifestUrl] + urls:
	fileName = os.path.join(outputPath, os.path.split(curUrl)[1])
	if os.path.exists(fileName):
		print 'Error: %s already exists' % fileName
		break
	http_utils.downloadUrl(curUrl, fileName)
def truncateFile(size):
    return StringReader(inputData[:size])

def truncateAtom(name, newSize):
    atomPos, atomHeaderSize, atomEndPos, _ = getAtom(inputAtoms, name)
    if atomHeaderSize != 8:
        raise Exception('only supported for atoms with 32 bit size')
    newAtomEndPos = atomPos + atomHeaderSize + newSize
    if newAtomEndPos + 8 > atomEndPos:
        raise Exception('not enough room to create padding atom')
    return StringReader(inputData[:atomPos] + struct.pack('>L', atomHeaderSize + newSize) + inputData[(atomPos + 4):newAtomEndPos] +
        struct.pack('>L', atomEndPos - newAtomEndPos) + 'padd' + inputData[(newAtomEndPos + 8):])

# download and read the input file
if not os.path.exists(TEMP_DOWNLOAD_PATH):
    http_utils.downloadUrl(TEST_FLAVOR_URL, TEMP_DOWNLOAD_PATH)

inputData = file(TEMP_DOWNLOAD_PATH, 'rb').read()

inputAtoms = parseAtoms(inputData, 0, len(inputData), '')

# initialize the api client
client = KalturaClient(GetConfig())

ks = client.generateSession(ADMIN_SECRET, USER_NAME, KalturaSessionType.ADMIN, PARTNER_ID, 86400, "")
client.setKs(ks)

# get source only conversion profile
sourceOnlyConvProfileId = None
for conversionProfile in client.conversionProfile.list().objects:
    if conversionProfile.name.lower() == 'source only':
def truncateFile(size):
    return StringReader(inputData[:size])

def truncateAtom(name, newSize):
    atomPos, atomHeaderSize, atomEndPos, _ = getAtom(inputAtoms, name)
    if atomHeaderSize != 8:
        raise Exception('only supported for atoms with 32 bit size')
    newAtomEndPos = atomPos + atomHeaderSize + newSize
    if newAtomEndPos + 8 > atomEndPos:
        raise Exception('not enough room to create padding atom')
    return StringReader(inputData[:atomPos] + struct.pack('>L', atomHeaderSize + newSize) + inputData[(atomPos + 4):newAtomEndPos] +
        struct.pack('>L', atomEndPos - newAtomEndPos) + 'padd' + inputData[(newAtomEndPos + 8):])

# download and read the input file
if not os.path.exists(TEMP_DOWNLOAD_PATH):
    http_utils.downloadUrl(TEST_FLAVOR_URL, TEMP_DOWNLOAD_PATH)

inputData = file(TEMP_DOWNLOAD_PATH, 'rb').read()

inputAtoms = parseAtoms(inputData, 0, len(inputData), '')

# initialize the api client
client = KalturaClient(GetConfig())

ks = client.generateSession(ADMIN_SECRET, USER_NAME, KalturaSessionType.ADMIN, PARTNER_ID, 86400, "")
client.setKs(ks)

# get source only conversion profile
sourceOnlyConvProfileId = None
for conversionProfile in client.conversionProfile.list().objects:
    if conversionProfile.name.lower() == 'source only':